summaryrefslogtreecommitdiff
path: root/spec/unit/mixin
diff options
context:
space:
mode:
authortyler-ball <tyleraball@gmail.com>2014-09-30 11:16:31 -0700
committertyler-ball <tyleraball@gmail.com>2014-10-07 15:34:34 -0700
commit25104da3b9be7545ca8911cb0f11a42f524989a3 (patch)
treebd279b75a00e1b0e27cbae7a2995b372d0242e31 /spec/unit/mixin
parentd4c52ac9722d67829e3d1393ba0b9cc59eb003ed (diff)
downloadchef-25104da3b9be7545ca8911cb0f11a42f524989a3.tar.gz
Moving documentation to a more logical place. Also no longer dis-allowing users from running brew as root.
Diffstat (limited to 'spec/unit/mixin')
-rw-r--r--spec/unit/mixin/homebrew_user_spec.rb20
1 files changed, 13 insertions, 7 deletions
diff --git a/spec/unit/mixin/homebrew_user_spec.rb b/spec/unit/mixin/homebrew_user_spec.rb
index a27a6a0460..7af04f0958 100644
--- a/spec/unit/mixin/homebrew_user_spec.rb
+++ b/spec/unit/mixin/homebrew_user_spec.rb
@@ -47,7 +47,7 @@ describe Chef::Mixin::HomebrewUser do
end
- describe 'when the homebrew user is not provided' do
+ shared_examples "successfully find executable" do
let(:user) { nil }
let(:brew_owner) { 2001 }
let(:default_brew_path) { '/usr/local/bin/brew' }
@@ -57,6 +57,10 @@ describe Chef::Mixin::HomebrewUser do
d
}
+ 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)
@@ -69,6 +73,11 @@ describe Chef::Mixin::HomebrewUser do
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)
@@ -76,13 +85,10 @@ describe Chef::Mixin::HomebrewUser do
expect { homebrew_user.find_homebrew_uid(user) }.to raise_error(Chef::Exceptions::CannotDetermineHomebrewOwner)
end
- describe "the executable is owned by root" do
+ context "the executable is owned by root" do
let(:brew_owner) { 0 }
-
- it 'raises an error' 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 raise_error(Chef::Exceptions::HomebrewOwnerIsRoot)
+ include_examples "successfully find executable" do
+ let(:brew_owner) { 0 }
end
end