diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-08-19 19:13:30 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-08-25 09:57:00 -0700 |
commit | 9e398d9540c70e5a0bcaab554f3648055d97e8ba (patch) | |
tree | a5f8fcc45093d9e5d704dac0989c35129173053d /spec/unit/provider/service/openbsd_service_spec.rb | |
parent | 16c56e408366e4af6bd469442342ecf597c5d9d9 (diff) | |
download | chef-9e398d9540c70e5a0bcaab554f3648055d97e8ba.tar.gz |
fix supports hash issues in service providers
- redhat provider now allows the user to override :status
- gentoo provider now allows the user to override :status and :restart
- service providers now dup the status hash and mutate their private
copy instead of mutating the new_resource
Diffstat (limited to 'spec/unit/provider/service/openbsd_service_spec.rb')
-rw-r--r-- | spec/unit/provider/service/openbsd_service_spec.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/spec/unit/provider/service/openbsd_service_spec.rb b/spec/unit/provider/service/openbsd_service_spec.rb index 1b5206470e..d3c150a14b 100644 --- a/spec/unit/provider/service/openbsd_service_spec.rb +++ b/spec/unit/provider/service/openbsd_service_spec.rb @@ -35,10 +35,12 @@ describe Chef::Provider::Service::Openbsd do node end + let(:supports) { {:status => false} } + let(:new_resource) do new_resource = Chef::Resource::Service.new("sndiod") new_resource.pattern("sndiod") - new_resource.supports({:status => false}) + new_resource.supports(supports) new_resource end @@ -106,9 +108,7 @@ describe Chef::Provider::Service::Openbsd do context "when the service supports status" do let(:status) { double(:stdout => "", :exitstatus => 0) } - before do - new_resource.supports({:status => true}) - end + let(:supports) { { :status => true } } it "should run '/etc/rc.d/service_name status'" do expect(provider).to receive(:shell_out).with("/etc/rc.d/#{new_resource.service_name} check").and_return(status) @@ -305,10 +305,12 @@ describe Chef::Provider::Service::Openbsd do end describe Chef::Provider::Service::Openbsd, "restart_service" do - it "should call 'restart' on the service_name if the resource supports it" do - new_resource.supports({:restart => true}) - expect(provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{new_resource.service_name} restart") - provider.restart_service() + context "when the new_resource supports restart" do + let(:supports) { { restart: true } } + it "should call 'restart' on the service_name if the resource supports it" do + expect(provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{new_resource.service_name} restart") + provider.restart_service() + end end it "should call the restart_command if one has been specified" do |