diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/unit/provider/service/redhat_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb index 73cfec8a6f..78be98f533 100644 --- a/spec/unit/provider/service/redhat_spec.rb +++ b/spec/unit/provider/service/redhat_spec.rb @@ -83,6 +83,28 @@ describe "Chef::Provider::Service::Redhat" do expect(@provider.load_current_resource).to eql(@current_resource) expect(@current_resource.enabled).to be_falsey end + + it "sets the current enabled status to true if the service is enabled at specified run levels" do + status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "") + @current_resource.instance_variable_set(:@run_levels, [ 1, 2 ]) + @provider.should_receive(:shell_out).with("/sbin/service chef status").and_return(status) + chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:on 3:off 4:off 5:off 6:off", :stderr => "") + @provider.should_receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig) + @provider.instance_variable_get("@service_missing").should be_false + @provider.load_current_resource.should + @current_resource.enabled.should be_true + end + + it "sets the current enabled status to false if the service is not enabled at specified run levels" do + status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "") + @current_resource.instance_variable_set(:@run_levels, [ 2 ]) + @provider.should_receive(:shell_out).with("/sbin/service chef status").and_return(status) + chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:off 3:off 4:off 5:off 6:off", :stderr => "") + @provider.should_receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig) + @provider.instance_variable_get("@service_missing").should be_false + @provider.load_current_resource.should + @current_resource.enabled.should be_true + end end describe "define resource requirements" do @@ -144,6 +166,12 @@ describe "Chef::Provider::Service::Redhat" do expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig #{@new_resource.service_name} on") @provider.enable_service end + + it "should call chkconfig to add 'service_name' at specified run_levels" do + @provider.instance_variable_set(:@run_levels, [ 1,2 ]) + @provider.should_receive(:shell_out!).with("/sbin/chkconfig --level 12 #{@new_resource.service_name} on") + @provider.enable_service + end end describe "disable_service" do @@ -151,6 +179,12 @@ describe "Chef::Provider::Service::Redhat" do expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig #{@new_resource.service_name} off") @provider.disable_service end + + it "should call chkconfig to del 'service_name' at specified run_levels" do + @provider.instance_variable_set(:@run_levels, [ 1,2 ]) + @provider.should_receive(:shell_out!).with("/sbin/chkconfig --level 12 #{@new_resource.service_name} off") + @provider.disable_service + end end end |
