summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortyler-ball <tyleraball@gmail.com>2014-09-30 11:29:09 -0700
committertyler-ball <tyleraball@gmail.com>2014-10-07 08:50:20 -0700
commit51839229de39570ca23811baa2a3e3b01e08bf03 (patch)
treef3f5824dcec80c62df012b569f8b553ed05077ce
parentbcb83b45fa180e21c389ed61666e43287f93e863 (diff)
downloadchef-tball/homebrew-owner.tar.gz
-rw-r--r--spec/unit/mixin/homebrew_user_spec.rb35
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