class ContextTest

Attributes

context[R]

Public Instance Methods

setup() click to toggle source
Calls superclass method
# File test/context_test.rb, line 16
def setup
  super
  @stubs = {}
  @context = Context.new do |_, cmd|
    @stubs.fetch(cmd)
  end
end
test_editor() click to toggle source
# File test/context_test.rb, line 24
def test_editor
  stub_command_output 'var GIT_EDITOR', 'vim'
  assert_equal %wvim', context.git_editor
end
test_editor_with_argument() click to toggle source
# File test/context_test.rb, line 29
def test_editor_with_argument
  stub_command_output 'var GIT_EDITOR', 'subl -w'
  assert_equal %wsubl -w', context.git_editor
end
test_editor_with_curly_brackets_embedded_env_variable() click to toggle source
# File test/context_test.rb, line 60
def test_editor_with_curly_brackets_embedded_env_variable
  stub_command_output 'var GIT_EDITOR', 'my${EDITOR}2 -w'
  with_env('EDITOR', 'subl') do
    assert_equal %wmysubl2 -w', context.git_editor
  end
end
test_editor_with_embedded_env_variable() click to toggle source
# File test/context_test.rb, line 53
def test_editor_with_embedded_env_variable
  stub_command_output 'var GIT_EDITOR', '$EDITOR -w'
  with_env('EDITOR', 'subl') do
    assert_equal %wsubl -w', context.git_editor
  end
end
test_editor_with_env_variable() click to toggle source
# File test/context_test.rb, line 46
def test_editor_with_env_variable
  stub_command_output 'var GIT_EDITOR', '$EDITOR'
  with_env('EDITOR', 'subl -w') do
    assert_equal %wsubl -w', context.git_editor
  end
end
test_editor_with_spaces() click to toggle source
# File test/context_test.rb, line 34
def test_editor_with_spaces
  stub_command_output 'var GIT_EDITOR', '"my editor" -w arg2'
  assert_equal %wmy\ editor -w arg2', context.git_editor
end
test_editor_with_tilde() click to toggle source
# File test/context_test.rb, line 39
def test_editor_with_tilde
  stub_command_output 'var GIT_EDITOR', '~/bin/vi'
  with_env('HOME', '/home/mislav') do
    assert_equal %w/home/mislav/bin/vi', context.git_editor
  end
end