Browse files

add Bundler.clean_system and Bundler.clean_exec

  • Loading branch information...
1 parent 5cf3fde commit 926836d9fbb5a1860dcbcb02d751b0b1f595db53 @wuputah wuputah committed Feb 25, 2011
Showing with 39 additions and 0 deletions.
  1. +8 −0 lib/bundler.rb
  2. +31 −0 spec/runtime/with_clean_env_spec.rb
View
8 lib/bundler.rb
@@ -200,6 +200,14 @@ def with_clean_env
end
end
+ def clean_system(*args)
+ with_clean_env { Kernel.system(*args) }
+ end
+
+ def clean_exec(*args)
+ with_clean_env { Kernel.exec(*args) }
+ end
+
def default_gemfile
SharedHelpers.default_gemfile
end
View
31 spec/runtime/with_clean_env_spec.rb
@@ -45,3 +45,34 @@
end
end
+
+describe "Bundler.clean_system" do
+
+ it "runs system inside with_clean_env" do
+ bundle_path = Bundler::ORIGINAL_ENV['BUNDLE_PATH']
+ Bundler::ORIGINAL_ENV['BUNDLE_PATH'] = "./Gemfile"
+
+ Bundler.clean_system(%{echo 'if [ "$BUNDLE_PATH" = "" ]; then exit 42; else exit 1; fi' | /bin/sh})
+ $?.exitstatus.should == 42
+
+ Bundler::ORIGINAL_ENV['BUNDLE_PATH'] = bundle_path
+ end
+
+end
+
+describe "Bundler.clean_exec" do
+
+ it "runs exec inside with_clean_env" do
+ bundle_path = Bundler::ORIGINAL_ENV['BUNDLE_PATH']
+ Bundler::ORIGINAL_ENV['BUNDLE_PATH'] = "./Gemfile"
+
+ pid = Kernel.fork do
+ Bundler.clean_exec(%{echo 'if [ "$BUNDLE_PATH" = "" ]; then exit 42; else exit 1; fi' | /bin/sh})
+ end
+ Process.wait(pid)
+ $?.exitstatus.should == 42
+
+ Bundler::ORIGINAL_ENV['BUNDLE_PATH'] = bundle_path
+ end
+
+end

0 comments on commit 926836d

Please sign in to comment.