diff options
author | Bryan McLellan <btm@loftninjas.org> | 2016-02-26 15:14:34 -0500 |
---|---|---|
committer | Bryan McLellan <btm@loftninjas.org> | 2016-02-26 15:14:34 -0500 |
commit | bea0bdf39b421c62f30a86f29e67210e456799c6 (patch) | |
tree | 98588bf50f671a48141b3d4bc7a31cf99058a419 /spec | |
parent | bf2eb79da8ad8b9f9d0c97617d4e637ad3fa9a27 (diff) | |
parent | 37baee5b73d568ac9562bba6ebae0472b8146e85 (diff) | |
download | chef-bea0bdf39b421c62f30a86f29e67210e456799c6.tar.gz |
Merge pull request #4621 from chef/cd/fix-choco-error
Fix the Chocolatey-missing error again
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/provider/package/chocolatey_spec.rb | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb index a347aa7ebd..8a69cf3da4 100644 --- a/spec/unit/provider/package/chocolatey_spec.rb +++ b/spec/unit/provider/package/chocolatey_spec.rb @@ -462,17 +462,6 @@ munin-node|1.6.1.20130823 expect(new_resource).to be_updated_by_last_action end end - - describe "#choco_exe" do - it "calls #choco_install_path" do - # un-stub #choco_exe from the before{} block. - allow(provider).to receive(:choco_exe).and_call_original - expect(provider).to receive(:choco_install_path).and_return("spork") - provider.instance_variable_set("@choco_exe", nil) - - expect(provider.send(:choco_exe)).to match(%r{spork[/\\]bin[/\\]choco.exe}) - end - end end describe "behavior when Chocolatey is not installed" do @@ -486,19 +475,27 @@ describe "behavior when Chocolatey is not installed" do end before { - allow(provider).to receive(:choco_install_path).and_return("") + # the shellout sometimes returns "", but test nil to be safe. + allow(provider).to receive(:choco_install_path).and_return(nil) provider.instance_variable_set("@choco_install_path", nil) # we don't care what this returns, but we have to let it be called. allow(provider).to receive(:shell_out!).and_return(double(:stdout => "")) } - context "#define_resource_requirements" do + let(:error_regex) { + /Could not locate.*install.*cookbook.*PowerShell.*GetEnvironmentVariable/m + } + + context "#choco_exe" do it "triggers a MissingLibrary exception when Chocolatey is not installed" do - provider.action = :install - provider.load_current_resource - provider.define_resource_requirements - expect { provider.process_resource_requirements }.to raise_error(Chef::Exceptions::MissingLibrary, /Could not locate.*install.*cookbook.*PowerShell.*GetEnvironmentVariable/m) + expect { provider.send(:choco_exe) }.to raise_error(Chef::Exceptions::MissingLibrary, error_regex) + end + end + + context "#load_current_resource" do + it "triggers a MissingLibrary exception when Chocolatey is not installed" do + expect { provider.load_current_resource }.to raise_error(Chef::Exceptions::MissingLibrary, error_regex) end end end |