diff options
Diffstat (limited to 'spec/unit/provider/service/macosx_spec.rb')
-rw-r--r-- | spec/unit/provider/service/macosx_spec.rb | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb index fab7a11248..29ebf2da11 100644 --- a/spec/unit/provider/service/macosx_spec.rb +++ b/spec/unit/provider/service/macosx_spec.rb @@ -43,7 +43,7 @@ describe Chef::Provider::Service::Macosx do context "when service name is given as" do let(:node) { Chef::Node.new } - let(:events) {Chef::EventDispatch::Dispatcher.new} + let(:events) { Chef::EventDispatch::Dispatcher.new } let(:run_context) { Chef::RunContext.new(node, {}, events) } let(:provider) { described_class.new(new_resource, run_context) } let(:launchctl_stdout) { StringIO.new } @@ -61,30 +61,30 @@ XML ["Daemon", "Agent"].each do |service_type| ["redis-server", "io.redis.redis-server"].each do |service_name| ["10.9", "10.10", "10.11"].each do |platform_version| - let(:plist) {"/Library/LaunchDaemons/io.redis.redis-server.plist"} + let(:plist) { "/Library/LaunchDaemons/io.redis.redis-server.plist" } let(:session) { StringIO.new } if service_type == "Agent" - let(:plist) {"/Library/LaunchAgents/io.redis.redis-server.plist"} - let(:session) {"-S Aqua "} - let(:su_cmd) {"su -l igor -c"} + let(:plist) { "/Library/LaunchAgents/io.redis.redis-server.plist" } + let(:session) { "-S Aqua " } + let(:su_cmd) { "su -l igor -c" } if platform_version == "10.9" - let(:su_cmd) {"su igor -c"} + let(:su_cmd) { "su igor -c" } end end - let(:service_label) {"io.redis.redis-server"} + let(:service_label) { "io.redis.redis-server" } before do allow(Dir).to receive(:glob).and_return([plist], []) allow(Etc).to receive(:getlogin).and_return("igor") allow(node).to receive(:[]).with("platform_version").and_return(platform_version) cmd = "launchctl list #{service_label}" allow(provider).to receive(:shell_out_with_systems_locale). - with(/(#{su_cmd} '#{cmd}'|#{cmd})/). - and_return(double("Status", + with(/(#{su_cmd} '#{cmd}'|#{cmd})/). + and_return(double("Status", :stdout => launchctl_stdout, :exitstatus => 0)) allow(File).to receive(:exists?).and_return([true], []) allow(provider).to receive(:shell_out_with_systems_locale!). - with(/plutil -convert xml1 -o/). - and_return(double("Status", :stdout => plutil_stdout)) + with(/plutil -convert xml1 -o/). + and_return(double("Status", :stdout => plutil_stdout)) end context "#{service_name} that is a #{service_type} running Osx #{platform_version}" do @@ -109,8 +109,8 @@ XML allow(Dir).to receive(:glob).and_return([]) allow(File).to receive(:exists?).and_return([true], []) allow(provider).to receive(:shell_out!). - with(/plutil -convert xml1 -o/). - and_raise(Mixlib::ShellOut::ShellCommandFailed) + with(/plutil -convert xml1 -o/). + and_raise(Mixlib::ShellOut::ShellCommandFailed) end it "works for action :nothing" do @@ -166,7 +166,7 @@ SVC_LIST allow(File).to receive(:exists?).and_return([true], []) end it "should throw an exception when reload action is attempted" do - expect {provider.run_action(:reload)}.to raise_error(Chef::Exceptions::UnsupportedAction) + expect { provider.run_action(:reload) }.to raise_error(Chef::Exceptions::UnsupportedAction) end end context "when launchctl returns empty service pid" do @@ -265,8 +265,8 @@ SVC_LIST it "starts service via launchctl if service found" do cmd = "launchctl load -w " + session + plist expect(provider).to receive(:shell_out_with_systems_locale). - with(/(#{su_cmd} .#{cmd}.|#{cmd})/). - and_return(0) + with(/(#{su_cmd} .#{cmd}.|#{cmd})/). + and_return(0) provider.start_service end @@ -295,10 +295,10 @@ SVC_LIST end it "stops the service via launchctl if service found" do - cmd = "launchctl unload -w "+ plist + cmd = "launchctl unload -w " + plist expect(provider).to receive(:shell_out_with_systems_locale). - with(/(#{su_cmd} .#{cmd}.|#{cmd})/). - and_return(0) + with(/(#{su_cmd} .#{cmd}.|#{cmd})/). + and_return(0) provider.stop_service end |