diff options
author | tyler-ball <tyleraball@gmail.com> | 2014-09-30 11:29:09 -0700 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2014-10-07 15:34:34 -0700 |
commit | e6a9db3bdadcbef85951677bcc2f7cf7470a9a6c (patch) | |
tree | 382ffff1af107eaf08e830e9ff89d03d0b3ea4e9 | |
parent | 25104da3b9be7545ca8911cb0f11a42f524989a3 (diff) | |
download | chef-e6a9db3bdadcbef85951677bcc2f7cf7470a9a6c.tar.gz |
Fixing test
-rw-r--r-- | spec/unit/mixin/homebrew_user_spec.rb | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/spec/unit/mixin/homebrew_user_spec.rb b/spec/unit/mixin/homebrew_user_spec.rb index 7af04f0958..4e30455765 100644 --- a/spec/unit/mixin/homebrew_user_spec.rb +++ b/spec/unit/mixin/homebrew_user_spec.rb @@ -57,36 +57,39 @@ describe Chef::Mixin::HomebrewUser do d } - before do - expect(Etc).to receive(:getpwuid).with(brew_owner).and_return(OpenStruct.new(:name => "name")) - end + context "debug statement prints owner name" do - it 'returns the owner of the brew executable when it is at a default location' do - expect(File).to receive(:exist?).with(default_brew_path).and_return(true) - expect(File).to receive(:stat).with(default_brew_path).and_return(stat_double) - expect(homebrew_user.find_homebrew_uid(user)).to eq(brew_owner) - end + before do + expect(Etc).to receive(:getpwuid).with(brew_owner).and_return(OpenStruct.new(:name => "name")) + end + + it 'returns the owner of the brew executable when it is at a default location' do + expect(File).to receive(:exist?).with(default_brew_path).and_return(true) + expect(File).to receive(:stat).with(default_brew_path).and_return(stat_double) + expect(homebrew_user.find_homebrew_uid(user)).to eq(brew_owner) + end + + it 'returns the owner of the brew executable when it is not at a default location' do + expect(File).to receive(:exist?).with(default_brew_path).and_return(false) + homebrew_user.stub_chain(:shell_out, :stdout, :strip).and_return("/foo") + expect(File).to receive(:stat).with("/foo").and_return(stat_double) + expect(homebrew_user.find_homebrew_uid(user)).to eq(brew_owner) + end - it 'returns the owner of the brew executable when it is not at a default location' do - expect(File).to receive(:exist?).with(default_brew_path).and_return(false) - homebrew_user.stub_chain(:shell_out, :stdout, :strip).and_return("/foo") - expect(File).to receive(:stat).with("/foo").and_return(stat_double) - expect(homebrew_user.find_homebrew_uid(user)).to eq(brew_owner) end end describe 'when the homebrew user is not provided' do - include_examples "successfully find executable" - it 'raises an error if no executable is found' do expect(File).to receive(:exist?).with(default_brew_path).and_return(false) homebrew_user.stub_chain(:shell_out, :stdout, :strip).and_return("") expect { homebrew_user.find_homebrew_uid(user) }.to raise_error(Chef::Exceptions::CannotDetermineHomebrewOwner) end + include_examples "successfully find executable" + context "the executable is owned by root" do - let(:brew_owner) { 0 } include_examples "successfully find executable" do let(:brew_owner) { 0 } end |