Add some tests for ENV.{append,prepend} behavior
This commit is contained in:
parent
f0bf64e1e9
commit
870e47e68c
@ -57,6 +57,52 @@ class EnvironmentTests < Test::Unit::TestCase
|
|||||||
assert_equal expected, @env.methods
|
assert_equal expected, @env.methods
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_append_existing_key
|
||||||
|
@env['foo'] = 'bar'
|
||||||
|
@env.append 'foo', '1'
|
||||||
|
assert_equal 'bar 1', @env['foo']
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_append_existing_key_empty
|
||||||
|
@env['foo'] = ''
|
||||||
|
@env.append 'foo', '1'
|
||||||
|
assert_equal '1', @env['foo']
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_append_missing_key
|
||||||
|
@env.append 'foo', '1'
|
||||||
|
assert_equal '1', @env['foo']
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_prepend_existing_key
|
||||||
|
@env['foo'] = 'bar'
|
||||||
|
@env.prepend 'foo', '1'
|
||||||
|
assert_equal '1 bar', @env['foo']
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_prepend_existing_key_empty
|
||||||
|
@env['foo'] = ''
|
||||||
|
@env.prepend 'foo', '1'
|
||||||
|
assert_equal '1', @env['foo']
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_prepend_missing_key
|
||||||
|
@env.prepend 'foo', '1'
|
||||||
|
assert_equal '1', @env['foo']
|
||||||
|
end
|
||||||
|
|
||||||
|
# NOTE: this may be a wrong behavior; we should probably reject objects that
|
||||||
|
# do not respond to #to_str. For now this documents existing behavior.
|
||||||
|
def test_append_coerces_value_to_string
|
||||||
|
@env.append 'foo', 42
|
||||||
|
assert_equal '42', @env['foo']
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_prepend_coerces_value_to_string
|
||||||
|
@env.prepend 'foo', 42
|
||||||
|
assert_equal '42', @env['foo']
|
||||||
|
end
|
||||||
|
|
||||||
def test_append_path
|
def test_append_path
|
||||||
@env.append_path 'FOO', '/usr/bin'
|
@env.append_path 'FOO', '/usr/bin'
|
||||||
assert_equal '/usr/bin', @env['FOO']
|
assert_equal '/usr/bin', @env['FOO']
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user