summaryrefslogtreecommitdiff
path: root/spec/unit/provider/service/systemd_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/provider/service/systemd_service_spec.rb')
-rw-r--r--spec/unit/provider/service/systemd_service_spec.rb22
1 files changed, 15 insertions, 7 deletions
diff --git a/spec/unit/provider/service/systemd_service_spec.rb b/spec/unit/provider/service/systemd_service_spec.rb
index 5ba3bed184..90b669a459 100644
--- a/spec/unit/provider/service/systemd_service_spec.rb
+++ b/spec/unit/provider/service/systemd_service_spec.rb
@@ -257,14 +257,22 @@ describe Chef::Provider::Service::Systemd do
end
end
- it "should return true if '#{systemctl_path} is-enabled service_name' returns 0" do
- expect(provider).to receive(:shell_out).with("#{systemctl_path} is-enabled #{service_name} --quiet").and_return(shell_out_success)
- expect(provider.is_enabled?).to be true
- end
+ describe "is_enabled?" do
+ before(:each) do
+ provider.current_resource = current_resource
+ current_resource.service_name(service_name)
+ allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
+ end
+
+ it "should return true if '#{systemctl_path} is-enabled service_name' returns 0" do
+ expect(provider).to receive(:shell_out).with("#{systemctl_path} is-enabled #{service_name} --quiet").and_return(shell_out_success)
+ expect(provider.is_enabled?).to be true
+ end
- it "should return false if '#{systemctl_path} is-enabled service_name' returns anything except 0" do
- expect(provider).to receive(:shell_out).with("#{systemctl_path} is-enabled #{service_name} --quiet").and_return(shell_out_failure)
- expect(provider.is_enabled?).to be false
+ it "should return false if '#{systemctl_path} is-enabled service_name' returns anything except 0" do
+ expect(provider).to receive(:shell_out).with("#{systemctl_path} is-enabled #{service_name} --quiet").and_return(shell_out_failure)
+ expect(provider.is_enabled?).to be false
+ end
end
end
end