summaryrefslogtreecommitdiff
path: root/spec/unit/provider/service/windows_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/provider/service/windows_spec.rb')
-rw-r--r--spec/unit/provider/service/windows_spec.rb70
1 files changed, 35 insertions, 35 deletions
diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb
index 18ea004795..978d180026 100644
--- a/spec/unit/provider/service/windows_spec.rb
+++ b/spec/unit/provider/service/windows_spec.rb
@@ -98,7 +98,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
Win32::Service::DISABLED = 0x00000004
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "running"))
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name)
.and_return(chef_service_config_info)
@@ -502,8 +502,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "start_service" do
before(:each) do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "running"))
end
it "calls the start command if one is specified" do
@@ -528,7 +528,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "does nothing if the service is running" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "running"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
provider.start_service
@@ -537,7 +537,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "raises an error if the service is paused" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "paused"))
+ double("StatusStruct", current_state: "paused"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
expect { provider.start_service }.to raise_error( Chef::Exceptions::Service )
@@ -546,9 +546,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "waits and continues if the service is in start_pending" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "start pending"),
- double("StatusStruct", :current_state => "start pending"),
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "start pending"),
+ double("StatusStruct", current_state: "start pending"),
+ double("StatusStruct", current_state: "running"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
provider.start_service
@@ -557,7 +557,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "fails if the service is in stop_pending" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stop pending"))
+ double("StatusStruct", current_state: "stop pending"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
expect { provider.start_service }.to raise_error( Chef::Exceptions::Service )
@@ -597,8 +597,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
before(:each) do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"),
- double("StatusStruct", :current_state => "stopped"))
+ double("StatusStruct", current_state: "running"),
+ double("StatusStruct", current_state: "stopped"))
end
it "calls the stop command if one is specified" do
@@ -623,7 +623,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "does nothing if the service is stopped" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stopped"))
+ double("StatusStruct", current_state: "stopped"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
provider.stop_service
@@ -632,7 +632,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "raises an error if the service is paused" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "paused"))
+ double("StatusStruct", current_state: "paused"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service )
@@ -641,9 +641,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "waits and continue if the service is in stop_pending" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stop pending"),
- double("StatusStruct", :current_state => "stop pending"),
- double("StatusStruct", :current_state => "stopped"))
+ double("StatusStruct", current_state: "stop pending"),
+ double("StatusStruct", current_state: "stop pending"),
+ double("StatusStruct", current_state: "stopped"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
provider.stop_service
@@ -652,7 +652,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "fails if the service is in start_pending" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "start pending"))
+ double("StatusStruct", current_state: "start pending"))
provider.load_current_resource
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service )
@@ -661,7 +661,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "passes custom timeout to the stop command if provided" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "running"))
new_resource.timeout 1
expect(Win32::Service).to receive(:stop).with(new_resource.service_name)
Timeout.timeout(2) do
@@ -683,10 +683,10 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "stops then starts the service if it is running" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "running"),
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "running"),
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "running"))
expect(Win32::Service).to receive(:stop).with(new_resource.service_name)
expect(Win32::Service).to receive(:start).with(new_resource.service_name)
provider.restart_service
@@ -695,9 +695,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "just starts the service if it is stopped" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "stopped"),
- double("StatusStruct", :current_state => "running"))
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "stopped"),
+ double("StatusStruct", current_state: "running"))
expect(Win32::Service).to receive(:start).with(new_resource.service_name)
provider.restart_service
expect(new_resource.updated_by_last_action?).to be_truthy
@@ -716,11 +716,11 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "enable_service" do
before(:each) do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "disabled"))
+ double("ConfigStruct", start_type: "disabled"))
end
it "enables service" do
- expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::AUTO_START)
+ expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::AUTO_START)
provider.enable_service
expect(new_resource.updated_by_last_action?).to be_truthy
end
@@ -736,14 +736,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "action_enable" do
it "does nothing if the service is enabled" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "auto start"))
+ double("ConfigStruct", start_type: "auto start"))
expect(provider).not_to receive(:enable_service)
provider.action_enable
end
it "enables the service if it is not set to automatic start" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "disabled"))
+ double("ConfigStruct", start_type: "disabled"))
expect(provider).to receive(:enable_service)
provider.action_enable
end
@@ -752,14 +752,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "action_disable" do
it "does nothing if the service is disabled" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "disabled"))
+ double("ConfigStruct", start_type: "disabled"))
expect(provider).not_to receive(:disable_service)
provider.action_disable
end
it "disables the service if it is not set to disabled" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "auto start"))
+ double("ConfigStruct", start_type: "auto start"))
expect(provider).to receive(:disable_service)
provider.action_disable
end
@@ -768,7 +768,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "disable_service" do
before(:each) do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", :start_type => "auto start"))
+ double("ConfigStruct", start_type: "auto start"))
end
it "disables service" do
@@ -810,17 +810,17 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "set_start_type" do
it "when called with :automatic it calls Win32::Service#configure with Win32::Service::AUTO_START" do
- expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::AUTO_START)
+ expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::AUTO_START)
provider.send(:set_startup_type, :automatic)
end
it "when called with :manual it calls Win32::Service#configure with Win32::Service::DEMAND_START" do
- expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::DEMAND_START)
+ expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::DEMAND_START)
provider.send(:set_startup_type, :manual)
end
it "when called with :disabled it calls Win32::Service#configure with Win32::Service::DISABLED" do
- expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::DISABLED)
+ expect(Win32::Service).to receive(:configure).with(service_name: new_resource.service_name, start_type: Win32::Service::DISABLED)
provider.send(:set_startup_type, :disabled)
end