mirror of
https://github.com/mistydemeo/tigerbrew.git
synced 2026-11-27 03:19:46 -05:00
Add tests for ENV.with_build_environment
This commit is contained in:
1 parent
6b339a7333
commit
36715c0dbd
1 file changed
+13
-1
@@ -27,7 +27,7 @@ class EnvironmentTests < Test::Unit::TestCase
|
||||
assert_equal ENV['OBJC'], ENV['CC']
|
||||
end
|
||||
|
||||
def test_with_build_environment
|
||||
def test_with_build_environment_restores_env
|
||||
before = ENV.to_hash
|
||||
ENV.with_build_environment do
|
||||
ENV['foo'] = 'bar'
|
||||
@@ -35,4 +35,16 @@ class EnvironmentTests < Test::Unit::TestCase
|
||||
assert_nil ENV['foo']
|
||||
assert_equal before, ENV.to_hash
|
||||
end
|
||||
|
||||
def test_with_build_environment_ensures_env_restored
|
||||
ENV.expects(:replace).with(ENV.to_hash)
|
||||
begin
|
||||
ENV.with_build_environment { raise Exception }
|
||||
rescue Exception
|
||||
end
|
||||
end
|
||||
|
||||
def test_with_build_environment_returns_block_value
|
||||
assert_equal 1, ENV.with_build_environment { 1 }
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user