diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-02 19:07:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-02 19:07:55 +0000 |
commit | 719b0f8e3037e1033726b6487d7b0d9fc1412e7d (patch) | |
tree | c5a08c8c9abae9b7f0514f680f56553a7a03656a /test/rake/in_environment.rb | |
parent | a0f667c33e24928374d494c9c33d0082355785e1 (diff) | |
download | ruby-719b0f8e3037e1033726b6487d7b0d9fc1412e7d.tar.gz |
* lib/rake: updated to rake code to rake-0.8.7 source code base.
* lib/rake/loaders/makefile.rb (Rake::MakefileLoader#process_line):
respace dependencies too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rake/in_environment.rb')
-rw-r--r-- | test/rake/in_environment.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/rake/in_environment.rb b/test/rake/in_environment.rb new file mode 100644 index 0000000000..f0a340fac9 --- /dev/null +++ b/test/rake/in_environment.rb @@ -0,0 +1,30 @@ +module InEnvironment + private + + # Create an environment for a test. At the completion of the yielded + # block, the environment is restored to its original conditions. + def in_environment(settings) + original_settings = set_env(settings) + yield + ensure + set_env(original_settings) if original_settings + end + + # Set the environment according to the settings hash. + def set_env(settings) # :nodoc: + result = {} + settings.each do |k, v| + result[k] = ENV[k] + if k == 'PWD' + result[k] = Dir.pwd + Dir.chdir(v) + elsif v.nil? + ENV.delete(k) + else + ENV[k] = v + end + end + result + end + +end |