Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
add Bundler.clean_system and Bundler.clean_exec
Browse files Browse the repository at this point in the history
  • Loading branch information
wuputah committed Feb 25, 2011
1 parent 5cf3fde commit 926836d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions spec/runtime/with_clean_env_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.