mirror of
https://github.com/mistydemeo/tigerbrew.git
synced 2026-12-02 13:39:47 -05:00
Add some tests for ENV.{append,prepend} behavior
This commit is contained in:
1 parent
c9f1a15a91
commit
896bb1bf72
1 file changed
+46
@@ -57,6 +57,52 @@ class EnvironmentTests < Test::Unit::TestCase
|
||||
assert_equal expected, @env.methods
|
||||
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
|
||||
@env.append_path 'FOO', '/usr/bin'
|
||||
assert_equal '/usr/bin', @env['FOO']
|
||||
|
||||
Reference in new issue
Block a user