avoid namespace conflict with Guard::Bundler

This commit is contained in:
Cezary Baginski 2015-06-06 23:17:41 +02:00
parent d170218fe1
commit 512e7f95d1
2 changed files with 26 additions and 5 deletions

View File

@ -50,7 +50,7 @@ module Guard
private
def maybe_bundle_with_env(&block)
if defined?(::Bundler)
Bundler.with_clean_env(&block)
::Bundler.with_clean_env(&block)
else
yield
end

View File

@ -32,11 +32,11 @@ describe Guard::Puppet::Runner do
end
describe '#run' do
context 'returns a non-zero value' do
before do
::Puppet::Util::CommandLine.expects(:new).raises(SystemExit.new(return_value))
end
context 'returns a non-zero value' do
let(:return_value) { 10 }
it 'should return the result of an exit call' do
@ -44,6 +44,27 @@ describe Guard::Puppet::Runner do
end
end
context 'when bundler is used' do
before do
module ::Guard
class Bundler
def self.with_clean_env
fail "Called with_clean_env on Guard::Bundler instead of Bundler"
end
end
end
end
it 'uses a clean env' do
ran = false
::Bundler.stubs(:with_clean_env).with() do
ran = true
end
runner.run
ran.should == true
end
end
context 'returns a zero value' do
let(:return_value) { 0 }
let(:messages) do