summaryrefslogtreecommitdiff
path: root/spec/unit/provider/service/debian_service_spec.rb
diff options
context:
space:
mode:
authorJack Foy <jfoy@whitepages.com>2013-07-20 21:26:15 -0700
committerBryan McLellan <btm@opscode.com>2013-10-10 11:29:23 -0700
commitec4bf3e18f4606bc789c8840802fba4f1c5de9e2 (patch)
treece63726237a6c4962b054e25ae22409ceb70f3a2 /spec/unit/provider/service/debian_service_spec.rb
parent9371c776731397606f613f932224ea771ec1bb5c (diff)
downloadchef-ec4bf3e18f4606bc789c8840802fba4f1c5de9e2.tar.gz
Further DRY up Service::Debian specs
Diffstat (limited to 'spec/unit/provider/service/debian_service_spec.rb')
-rw-r--r--spec/unit/provider/service/debian_service_spec.rb41
1 files changed, 21 insertions, 20 deletions
diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb
index 1aeb41d8b6..b873f194f5 100644
--- a/spec/unit/provider/service/debian_service_spec.rb
+++ b/spec/unit/provider/service/debian_service_spec.rb
@@ -282,15 +282,20 @@ insserv: remove service /etc/init.d/../rc0.d/K20chef-client
end
end
+ def expect_commands(provider, commands)
+ commands.each do |command|
+ provider.should_receive(:run_command).with({:command => command})
+ end
+ end
+
describe "enable_service" do
let(:service_name) { @new_resource.service_name }
context "when the service doesn't set a priority" do
it "calls update-rc.d 'service_name' defaults" do
- [ "/usr/sbin/update-rc.d -f #{service_name} remove",
+ expect_commands(@provider, [
+ "/usr/sbin/update-rc.d -f #{service_name} remove",
"/usr/sbin/update-rc.d #{service_name} defaults"
- ].each do |command|
- @provider.should_receive(:run_command).with({:command => command})
- end
+ ])
@provider.enable_service
end
end
@@ -301,11 +306,10 @@ insserv: remove service /etc/init.d/../rc0.d/K20chef-client
end
it "calls update-rc.d 'service_name' defaults" do
- [ "/usr/sbin/update-rc.d -f #{service_name} remove",
+ expect_commands(@provider, [
+ "/usr/sbin/update-rc.d -f #{service_name} remove",
"/usr/sbin/update-rc.d #{service_name} defaults 75 25"
- ].each do |command|
- @provider.should_receive(:run_command).with({:command => command})
- end
+ ])
@provider.enable_service
end
end
@@ -316,11 +320,10 @@ insserv: remove service /etc/init.d/../rc0.d/K20chef-client
end
it "calls update-rc.d 'service_name' with those priorities" do
- [ "/usr/sbin/update-rc.d -f #{service_name} remove",
+ expect_commands(@provider, [
+ "/usr/sbin/update-rc.d -f #{service_name} remove",
"/usr/sbin/update-rc.d #{service_name} start 20 2 . stop 55 3 . "
- ].each do |command|
- @provider.should_receive(:run_command).with({:command => command})
- end
+ ])
@provider.enable_service
end
end
@@ -330,11 +333,10 @@ insserv: remove service /etc/init.d/../rc0.d/K20chef-client
let(:service_name) { @new_resource.service_name }
context "when the service doesn't set a priority" do
it "calls update-rc.d -f 'service_name' remove + stop with default priority" do
- [ "/usr/sbin/update-rc.d -f #{service_name} remove",
+ expect_commands(@provider, [
+ "/usr/sbin/update-rc.d -f #{service_name} remove",
"/usr/sbin/update-rc.d -f #{service_name} stop 80 2 3 4 5 ."
- ].each do |command|
- @provider.should_receive(:run_command).with({:command => command})
- end
+ ])
@provider.disable_service
end
end
@@ -345,11 +347,10 @@ insserv: remove service /etc/init.d/../rc0.d/K20chef-client
end
it "calls update-rc.d -f 'service_name' remove + stop with the specified priority" do
- [ "/usr/sbin/update-rc.d -f #{service_name} remove",
+ expect_commands(@provider, [
+ "/usr/sbin/update-rc.d -f #{service_name} remove",
"/usr/sbin/update-rc.d -f #{service_name} stop #{100 - @new_resource.priority} 2 3 4 5 ."
- ].each do |command|
- @provider.should_receive(:run_command).with({:command => command})
- end
+ ])
@provider.disable_service
end
end