diff options
| author | Jack Nagel | 2013-01-22 04:32:26 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-01-22 13:57:07 -0600 |
| commit | 36715c0dbdfdffb4bbfbb4cc47b1d050dd9c9f54 (patch) | |
| tree | 6bed96b9b2fbabf7a66a338ae28af78a95f63101 | |
| parent | 6b339a7333bf57911225d89e6956a9afcd8e574f (diff) | |
| download | homebrew-36715c0dbdfdffb4bbfbb4cc47b1d050dd9c9f54.tar.bz2 | |
Add tests for ENV.with_build_environment
| -rw-r--r-- | Library/Homebrew/test/test_ENV.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Library/Homebrew/test/test_ENV.rb b/Library/Homebrew/test/test_ENV.rb index 1a1dd922b..8c1a72519 100644 --- a/Library/Homebrew/test/test_ENV.rb +++ b/Library/Homebrew/test/test_ENV.rb @@ -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 |
