spec/unit/provider/service/init_service_spec.rb in microwave-1.0.4 vs spec/unit/provider/service/init_service_spec.rb in microwave-11.400.2
- old
+ new
@@ -19,11 +19,11 @@
require 'spec_helper'
describe Chef::Provider::Service::Init, "load_current_resource" do
before(:each) do
@node = Chef::Node.new
- @node[:command] = {:ps => "ps -ef"}
+ @node.automatic_attrs[:command] = {:ps => "ps -ef"}
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
@new_resource = Chef::Resource::Service.new("chef")
@@ -91,22 +91,35 @@
@provider.load_current_resource
end
end
+ describe "when an init command has been specified" do
+ before do
+ @new_resource.stub!(:init_command).and_return("/opt/chef-server/service/erchef")
+ @provider = Chef::Provider::Service::Init.new(@new_resource, @run_context)
+ end
+
+ it "should use the init_command if one has been specified" do
+ @provider.should_receive(:shell_out!).with("/opt/chef-server/service/erchef start")
+ @provider.start_service
+ end
+
+ end
+
describe "when the node has not specified a ps command" do
it "should raise an error if the node has a nil ps attribute" do
- @node[:command] = {:ps => nil}
+ @node.automatic_attrs[:command] = {:ps => nil}
@provider.load_current_resource
@provider.action = :start
@provider.define_resource_requirements
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
end
it "should raise an error if the node has an empty ps attribute" do
- @node[:command] = {:ps => ""}
+ @node.automatic_attrs[:command] = {:ps => ""}
@provider.load_current_resource
@provider.action = :start
@provider.define_resource_requirements
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
end
@@ -205,8 +218,18 @@
it "should should run the user specified reload command if one is specified and the service doesn't support reload" do
@new_resource.reload_command("/etc/init.d/chef lollerpants")
@provider.should_receive(:shell_out!).with("/etc/init.d/chef lollerpants")
@provider.reload_service()
+ end
+ end
+
+ describe "when a custom command has been specified" do
+ before do
+ @new_resource.start_command("/etc/init.d/chef startyousillysally")
+ end
+
+ it "should still pass all why run assertions" do
+ lambda { @provider.run_action(:start) }.should_not raise_error(Chef::Exceptions::Service)
end
end
end