chef 12.0.0.rc.0 → 12.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1 -1
  3. data/lib/chef/api_client/registration.rb +3 -1
  4. data/lib/chef/chef_fs/data_handler/group_data_handler.rb +4 -0
  5. data/lib/chef/config.rb +46 -38
  6. data/lib/chef/event_loggers/windows_eventlog.rb +5 -6
  7. data/lib/chef/exceptions.rb +13 -1
  8. data/lib/chef/file_content_management/tempfile.rb +33 -5
  9. data/lib/chef/knife.rb +11 -3
  10. data/lib/chef/knife/bootstrap.rb +8 -7
  11. data/lib/chef/mixin/deep_merge.rb +15 -54
  12. data/lib/chef/mixin/which.rb +37 -0
  13. data/lib/chef/node.rb +14 -25
  14. data/lib/chef/node/attribute.rb +227 -41
  15. data/lib/chef/node/attribute_collections.rb +117 -3
  16. data/lib/chef/node/immutable_collections.rb +6 -6
  17. data/lib/chef/platform/provider_priority_map.rb +3 -2
  18. data/lib/chef/platform/service_helpers.rb +37 -8
  19. data/lib/chef/provider/service/aixinit.rb +1 -1
  20. data/lib/chef/provider/service/arch.rb +1 -1
  21. data/lib/chef/provider/service/debian.rb +5 -1
  22. data/lib/chef/provider/service/init.rb +4 -0
  23. data/lib/chef/provider/service/insserv.rb +5 -1
  24. data/lib/chef/provider/service/invokercd.rb +5 -1
  25. data/lib/chef/provider/service/redhat.rb +5 -1
  26. data/lib/chef/provider/service/systemd.rb +50 -32
  27. data/lib/chef/provider/service/upstart.rb +5 -2
  28. data/lib/chef/provider_resolver.rb +30 -16
  29. data/lib/chef/resource.rb +2 -1
  30. data/lib/chef/resources.rb +7 -0
  31. data/lib/chef/run_context.rb +0 -5
  32. data/lib/chef/run_list/run_list_expansion.rb +2 -2
  33. data/lib/chef/shell.rb +2 -2
  34. data/lib/chef/util/selinux.rb +2 -10
  35. data/lib/chef/version.rb +1 -1
  36. data/lib/chef/workstation_config_loader.rb +1 -1
  37. data/spec/support/shared/unit/resource/static_provider_resolution.rb +1 -6
  38. data/spec/unit/api_client/registration_spec.rb +22 -0
  39. data/spec/unit/application/knife_spec.rb +6 -2
  40. data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +63 -0
  41. data/spec/unit/config_spec.rb +5 -5
  42. data/spec/unit/knife/bootstrap_spec.rb +27 -1
  43. data/spec/unit/knife_spec.rb +5 -0
  44. data/spec/unit/mixin/deep_merge_spec.rb +0 -40
  45. data/spec/unit/node/attribute_spec.rb +37 -50
  46. data/spec/unit/node_spec.rb +321 -13
  47. data/spec/unit/provider/file/content_spec.rb +23 -2
  48. data/spec/unit/provider/service/systemd_service_spec.rb +173 -158
  49. data/spec/unit/provider_resolver_spec.rb +175 -10
  50. data/spec/unit/resource/timestamped_deploy_spec.rb +8 -29
  51. data/spec/unit/runner_spec.rb +3 -1
  52. metadata +141 -191
  53. data/spec/.DS_Store +0 -0
  54. data/spec/data/.DS_Store +0 -0
  55. data/spec/data/lwrp/.DS_Store +0 -0
  56. data/spec/data/lwrp/providers/.DS_Store +0 -0
  57. data/spec/data/lwrp/resources/.DS_Store +0 -0
  58. data/spec/data/lwrp_override/.DS_Store +0 -0
  59. data/spec/data/lwrp_override/providers/.DS_Store +0 -0
  60. data/spec/data/lwrp_override/resources/.DS_Store +0 -0
@@ -70,12 +70,34 @@ describe Chef::Provider::File::Content do
70
70
  expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_false
71
71
  end
72
72
 
73
- it "returns a tempfile in the destdir when :file_desployment_uses_destdir is not set" do
73
+ it "returns a tempfile in the destdir when :file_deployment_uses_destdir is set" do
74
74
  Chef::Config[:file_staging_uses_destdir] = true
75
75
  expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be_false
76
76
  expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_true
77
77
  end
78
78
 
79
+ context "when creating a tempfiles in destdir fails" do
80
+ let(:enclosing_directory) {
81
+ canonicalize_path("/nonexisting/path")
82
+ }
83
+
84
+ it "returns a tempfile in the tempdir when :file_deployment_uses_destdir is set to :auto" do
85
+ Chef::Config[:file_staging_uses_destdir] = :auto
86
+ expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be_true
87
+ expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_false
88
+ end
89
+
90
+ it "fails when :file_desployment_uses_destdir is set" do
91
+ Chef::Config[:file_staging_uses_destdir] = true
92
+ expect{content.tempfile}.to raise_error
93
+ end
94
+
95
+ it "returns a tempfile in the tempdir when :file_desployment_uses_destdir is not set" do
96
+ expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be_true
97
+ expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_false
98
+ end
99
+ end
100
+
79
101
  end
80
102
 
81
103
  describe "when the resource does not have a content attribute set" do
@@ -90,4 +112,3 @@ describe Chef::Provider::File::Content do
90
112
 
91
113
  end
92
114
  end
93
-
@@ -19,238 +19,253 @@
19
19
  require 'spec_helper'
20
20
 
21
21
  describe Chef::Provider::Service::Systemd do
22
+
23
+ let(:node) { Chef::Node.new }
24
+
25
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
26
+
27
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
28
+
29
+ let(:service_name) { "rsyslog.service" }
30
+
31
+ let(:new_resource) { Chef::Resource::Service.new(service_name) }
32
+
33
+ let(:provider) { Chef::Provider::Service::Systemd.new(new_resource, run_context) }
34
+
35
+ let(:shell_out_success) do
36
+ double('shell_out_with_systems_locale', :exitstatus => 0, :error? => false)
37
+ end
38
+
39
+ let(:shell_out_failure) do
40
+ double('shell_out_with_systems_locale', :exitstatus => 1, :error? => true)
41
+ end
42
+
43
+ let(:current_resource) { Chef::Resource::Service.new(service_name) }
44
+
22
45
  before(:each) do
23
- @node = Chef::Node.new
24
- @events = Chef::EventDispatch::Dispatcher.new
25
- @run_context = Chef::RunContext.new(@node, {}, @events)
26
- @new_resource = Chef::Resource::Service.new('rsyslog.service')
27
- @provider = Chef::Provider::Service::Systemd.new(@new_resource, @run_context)
28
-
29
- @shell_out_success = double('shell_out_with_systems_locale',
30
- :exitstatus => 0, :error? => false)
31
- @shell_out_failure = double('shell_out_with_systems_locale',
32
- :exitstatus => 1, :error? => true)
46
+ allow(Chef::Resource::Service).to receive(:new).with(service_name).and_return(current_resource)
33
47
  end
34
48
 
35
49
  describe "load_current_resource" do
36
- before(:each) do
37
- @current_resource = Chef::Resource::Service.new('rsyslog.service')
38
- allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
39
50
 
40
- allow(@provider).to receive(:is_active?).and_return(false)
41
- allow(@provider).to receive(:is_enabled?).and_return(false)
51
+ before(:each) do
52
+ allow(provider).to receive(:is_active?).and_return(false)
53
+ allow(provider).to receive(:is_enabled?).and_return(false)
42
54
  end
43
55
 
44
56
  it "should create a current resource with the name of the new resource" do
45
- expect(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
46
- @provider.load_current_resource
57
+ expect(Chef::Resource::Service).to receive(:new).with(new_resource.name).and_return(current_resource)
58
+ provider.load_current_resource
47
59
  end
48
60
 
49
61
  it "should set the current resources service name to the new resources service name" do
50
- expect(@current_resource).to receive(:service_name).with(@new_resource.service_name)
51
- @provider.load_current_resource
62
+ provider.load_current_resource
63
+ expect(current_resource.service_name).to eql(service_name)
52
64
  end
53
65
 
54
66
  it "should check if the service is running" do
55
- expect(@provider).to receive(:is_active?)
56
- @provider.load_current_resource
67
+ expect(provider).to receive(:is_active?)
68
+ provider.load_current_resource
57
69
  end
58
70
 
59
71
  it "should set running to true if the service is running" do
60
- allow(@provider).to receive(:is_active?).and_return(true)
61
- expect(@current_resource).to receive(:running).with(true)
62
- @provider.load_current_resource
72
+ allow(provider).to receive(:is_active?).and_return(true)
73
+ provider.load_current_resource
74
+ expect(current_resource.running).to be true
63
75
  end
64
76
 
65
77
  it "should set running to false if the service is not running" do
66
- allow(@provider).to receive(:is_active?).and_return(false)
67
- expect(@current_resource).to receive(:running).with(false)
68
- @provider.load_current_resource
78
+ allow(provider).to receive(:is_active?).and_return(false)
79
+ provider.load_current_resource
80
+ expect(current_resource.running).to be false
69
81
  end
70
82
 
71
83
  describe "when a status command has been specified" do
72
84
  before do
73
- allow(@new_resource).to receive(:status_command).and_return("/bin/chefhasmonkeypants status")
85
+ allow(new_resource).to receive(:status_command).and_return("/bin/chefhasmonkeypants status")
74
86
  end
75
87
 
76
88
  it "should run the services status command if one has been specified" do
77
- allow(@provider).to receive(:shell_out).and_return(@shell_out_success)
78
- expect(@current_resource).to receive(:running).with(true)
79
- @provider.load_current_resource
89
+ allow(provider).to receive(:shell_out).and_return(shell_out_success)
90
+ provider.load_current_resource
91
+ expect(current_resource.running).to be true
80
92
  end
81
93
 
82
94
  it "should run the services status command if one has been specified and properly set status check state" do
83
- allow(@provider).to receive(:shell_out).with("/bin/chefhasmonkeypants status").and_return(@shell_out_success)
84
- @provider.load_current_resource
85
- expect(@provider.instance_variable_get("@status_check_success")).to be_true
95
+ allow(provider).to receive(:shell_out).with("/bin/chefhasmonkeypants status").and_return(shell_out_success)
96
+ provider.load_current_resource
97
+ expect(provider.status_check_success).to be true
86
98
  end
87
99
 
88
100
  it "should set running to false if a status command fails" do
89
- allow(@provider).to receive(:shell_out).and_return(@shell_out_failure)
90
- expect(@current_resource).to receive(:running).with(false)
91
- @provider.load_current_resource
101
+ allow(provider).to receive(:shell_out).and_return(shell_out_failure)
102
+ provider.load_current_resource
103
+ expect(current_resource.running).to be false
92
104
  end
93
105
 
94
106
  it "should update state to indicate status check failed when a status command fails" do
95
- allow(@provider).to receive(:shell_out).and_return(@shell_out_failure)
96
- @provider.load_current_resource
97
- expect(@provider.instance_variable_get("@status_check_success")).to be_false
107
+ allow(provider).to receive(:shell_out).and_return(shell_out_failure)
108
+ provider.load_current_resource
109
+ expect(provider.status_check_success).to be false
98
110
  end
99
111
  end
100
112
 
101
113
  it "should check if the service is enabled" do
102
- expect(@provider).to receive(:is_enabled?)
103
- @provider.load_current_resource
114
+ expect(provider).to receive(:is_enabled?)
115
+ provider.load_current_resource
104
116
  end
105
117
 
106
118
  it "should set enabled to true if the service is enabled" do
107
- allow(@provider).to receive(:is_enabled?).and_return(true)
108
- expect(@current_resource).to receive(:enabled).with(true)
109
- @provider.load_current_resource
119
+ allow(provider).to receive(:is_enabled?).and_return(true)
120
+ provider.load_current_resource
121
+ expect(current_resource.enabled).to be true
110
122
  end
111
123
 
112
124
  it "should set enabled to false if the service is not enabled" do
113
- allow(@provider).to receive(:is_enabled?).and_return(false)
114
- expect(@current_resource).to receive(:enabled).with(false)
115
- @provider.load_current_resource
125
+ allow(provider).to receive(:is_enabled?).and_return(false)
126
+ provider.load_current_resource
127
+ expect(current_resource.enabled).to be false
116
128
  end
117
129
 
118
130
  it "should return the current resource" do
119
- expect(@provider.load_current_resource).to eql(@current_resource)
131
+ expect(provider.load_current_resource).to eql(current_resource)
120
132
  end
121
133
  end
122
134
 
123
- describe "start and stop service" do
124
- before(:each) do
125
- @current_resource = Chef::Resource::Service.new('rsyslog.service')
126
- allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
127
- @provider.current_resource = @current_resource
128
- end
129
-
130
- it "should call the start command if one is specified" do
131
- allow(@new_resource).to receive(:start_command).and_return("/sbin/rsyslog startyousillysally")
132
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog startyousillysally")
133
- @provider.start_service
134
- end
135
+ def setup_current_resource
136
+ provider.current_resource = current_resource
137
+ current_resource.service_name(service_name)
138
+ end
135
139
 
136
- it "should call '/bin/systemctl start service_name' if no start command is specified" do
137
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/bin/systemctl start #{@new_resource.service_name}").and_return(@shell_out_success)
138
- @provider.start_service
139
- end
140
+ %w{/usr/bin/systemctl /bin/systemctl}.each do |systemctl_path|
141
+ describe "when systemctl path is #{systemctl_path}" do
142
+ before(:each) do
143
+ setup_current_resource
144
+ allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path)
145
+ end
140
146
 
141
- it "should not call '/bin/systemctl start service_name' if it is already running" do
142
- allow(@current_resource).to receive(:running).and_return(true)
143
- expect(@provider).not_to receive(:shell_out_with_systems_locale!).with("/bin/systemctl start #{@new_resource.service_name}")
144
- @provider.start_service
145
- end
147
+ describe "start and stop service" do
146
148
 
147
- it "should call the restart command if one is specified" do
148
- allow(@current_resource).to receive(:running).and_return(true)
149
- allow(@new_resource).to receive(:restart_command).and_return("/sbin/rsyslog restartyousillysally")
150
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog restartyousillysally")
151
- @provider.restart_service
152
- end
149
+ it "should call the start command if one is specified" do
150
+ allow(new_resource).to receive(:start_command).and_return("/sbin/rsyslog startyousillysally")
151
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog startyousillysally")
152
+ provider.start_service
153
+ end
153
154
 
154
- it "should call '/bin/systemctl restart service_name' if no restart command is specified" do
155
- allow(@current_resource).to receive(:running).and_return(true)
156
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/bin/systemctl restart #{@new_resource.service_name}").and_return(@shell_out_success)
157
- @provider.restart_service
158
- end
155
+ it "should call '#{systemctl_path} start service_name' if no start command is specified" do
156
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} start #{service_name}").and_return(shell_out_success)
157
+ provider.start_service
158
+ end
159
159
 
160
- describe "reload service" do
161
- context "when a reload command is specified" do
162
- it "should call the reload command" do
163
- allow(@current_resource).to receive(:running).and_return(true)
164
- allow(@new_resource).to receive(:reload_command).and_return("/sbin/rsyslog reloadyousillysally")
165
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog reloadyousillysally")
166
- @provider.reload_service
160
+ it "should not call '#{systemctl_path} start service_name' if it is already running" do
161
+ current_resource.running(true)
162
+ expect(provider).not_to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} start #{service_name}")
163
+ provider.start_service
167
164
  end
168
- end
169
165
 
170
- context "when a reload command is not specified" do
171
- it "should call '/bin/systemctl reload service_name' if the service is running" do
172
- allow(@current_resource).to receive(:running).and_return(true)
173
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/bin/systemctl reload #{@new_resource.service_name}").and_return(@shell_out_success)
174
- @provider.reload_service
166
+ it "should call the restart command if one is specified" do
167
+ current_resource.running(true)
168
+ allow(new_resource).to receive(:restart_command).and_return("/sbin/rsyslog restartyousillysally")
169
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog restartyousillysally")
170
+ provider.restart_service
175
171
  end
176
172
 
177
- it "should start the service if the service is not running" do
178
- allow(@current_resource).to receive(:running).and_return(false)
179
- expect(@provider).to receive(:start_service).and_return(true)
180
- @provider.reload_service
173
+ it "should call '#{systemctl_path} restart service_name' if no restart command is specified" do
174
+ current_resource.running(true)
175
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} restart #{service_name}").and_return(shell_out_success)
176
+ provider.restart_service
181
177
  end
182
- end
183
- end
184
178
 
185
- it "should call the stop command if one is specified" do
186
- allow(@current_resource).to receive(:running).and_return(true)
187
- allow(@new_resource).to receive(:stop_command).and_return("/sbin/rsyslog stopyousillysally")
188
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog stopyousillysally")
189
- @provider.stop_service
190
- end
179
+ describe "reload service" do
180
+ context "when a reload command is specified" do
181
+ it "should call the reload command" do
182
+ current_resource.running(true)
183
+ allow(new_resource).to receive(:reload_command).and_return("/sbin/rsyslog reloadyousillysally")
184
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog reloadyousillysally")
185
+ provider.reload_service
186
+ end
187
+ end
188
+
189
+ context "when a reload command is not specified" do
190
+ it "should call '#{systemctl_path} reload service_name' if the service is running" do
191
+ current_resource.running(true)
192
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} reload #{service_name}").and_return(shell_out_success)
193
+ provider.reload_service
194
+ end
195
+
196
+ it "should start the service if the service is not running" do
197
+ current_resource.running(false)
198
+ expect(provider).to receive(:start_service).and_return(true)
199
+ provider.reload_service
200
+ end
201
+ end
202
+ end
191
203
 
192
- it "should call '/bin/systemctl stop service_name' if no stop command is specified" do
193
- allow(@current_resource).to receive(:running).and_return(true)
194
- expect(@provider).to receive(:shell_out_with_systems_locale!).with("/bin/systemctl stop #{@new_resource.service_name}").and_return(@shell_out_success)
195
- @provider.stop_service
196
- end
204
+ it "should call the stop command if one is specified" do
205
+ current_resource.running(true)
206
+ allow(new_resource).to receive(:stop_command).and_return("/sbin/rsyslog stopyousillysally")
207
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog stopyousillysally")
208
+ provider.stop_service
209
+ end
197
210
 
198
- it "should not call '/bin/systemctl stop service_name' if it is already stopped" do
199
- allow(@current_resource).to receive(:running).and_return(false)
200
- expect(@provider).not_to receive(:shell_out_with_systems_locale!).with("/bin/systemctl stop #{@new_resource.service_name}")
201
- @provider.stop_service
202
- end
203
- end
211
+ it "should call '#{systemctl_path} stop service_name' if no stop command is specified" do
212
+ current_resource.running(true)
213
+ expect(provider).to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} stop #{service_name}").and_return(shell_out_success)
214
+ provider.stop_service
215
+ end
204
216
 
205
- describe "enable and disable service" do
206
- before(:each) do
207
- @current_resource = Chef::Resource::Service.new('rsyslog.service')
208
- allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
209
- @provider.current_resource = @current_resource
210
- end
217
+ it "should not call '#{systemctl_path} stop service_name' if it is already stopped" do
218
+ current_resource.running(false)
219
+ expect(provider).not_to receive(:shell_out_with_systems_locale!).with("#{systemctl_path} stop #{service_name}")
220
+ provider.stop_service
221
+ end
222
+ end
211
223
 
212
- it "should call '/bin/systemctl enable service_name' to enable the service" do
213
- expect(@provider).to receive(:shell_out!).with("/bin/systemctl enable #{@new_resource.service_name}").and_return(@shell_out_success)
214
- @provider.enable_service
215
- end
224
+ describe "enable and disable service" do
225
+ before(:each) do
226
+ provider.current_resource = current_resource
227
+ current_resource.service_name(service_name)
228
+ allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
229
+ end
216
230
 
217
- it "should call '/bin/systemctl disable service_name' to disable the service" do
218
- expect(@provider).to receive(:shell_out!).with("/bin/systemctl disable #{@new_resource.service_name}").and_return(@shell_out_success)
219
- @provider.disable_service
220
- end
221
- end
231
+ it "should call '#{systemctl_path} enable service_name' to enable the service" do
232
+ expect(provider).to receive(:shell_out!).with("#{systemctl_path} enable #{service_name}").and_return(shell_out_success)
233
+ provider.enable_service
234
+ end
222
235
 
223
- describe "is_active?" do
224
- before(:each) do
225
- @current_resource = Chef::Resource::Service.new('rsyslog.service')
226
- allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
227
- end
236
+ it "should call '#{systemctl_path} disable service_name' to disable the service" do
237
+ expect(provider).to receive(:shell_out!).with("#{systemctl_path} disable #{service_name}").and_return(shell_out_success)
238
+ provider.disable_service
239
+ end
240
+ end
228
241
 
229
- it "should return true if '/bin/systemctl is-active service_name' returns 0" do
230
- expect(@provider).to receive(:shell_out).with('/bin/systemctl is-active rsyslog.service --quiet').and_return(@shell_out_success)
231
- expect(@provider.is_active?).to be_true
232
- end
242
+ describe "is_active?" do
243
+ before(:each) do
244
+ provider.current_resource = current_resource
245
+ current_resource.service_name(service_name)
246
+ allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
247
+ end
233
248
 
234
- it "should return false if '/bin/systemctl is-active service_name' returns anything except 0" do
235
- expect(@provider).to receive(:shell_out).with('/bin/systemctl is-active rsyslog.service --quiet').and_return(@shell_out_failure)
236
- expect(@provider.is_active?).to be_false
237
- end
238
- end
249
+ it "should return true if '#{systemctl_path} is-active service_name' returns 0" do
250
+ expect(provider).to receive(:shell_out).with("#{systemctl_path} is-active #{service_name} --quiet").and_return(shell_out_success)
251
+ expect(provider.is_active?).to be true
252
+ end
239
253
 
240
- describe "is_enabled?" do
241
- before(:each) do
242
- @current_resource = Chef::Resource::Service.new('rsyslog.service')
243
- allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
244
- end
254
+ it "should return false if '#{systemctl_path} is-active service_name' returns anything except 0" do
255
+ expect(provider).to receive(:shell_out).with("#{systemctl_path} is-active #{service_name} --quiet").and_return(shell_out_failure)
256
+ expect(provider.is_active?).to be false
257
+ end
258
+ end
245
259
 
246
- it "should return true if '/bin/systemctl is-enabled service_name' returns 0" do
247
- expect(@provider).to receive(:shell_out).with('/bin/systemctl is-enabled rsyslog.service --quiet').and_return(@shell_out_success)
248
- expect(@provider.is_enabled?).to be_true
249
- end
260
+ it "should return true if '#{systemctl_path} is-enabled service_name' returns 0" do
261
+ expect(provider).to receive(:shell_out).with("#{systemctl_path} is-enabled #{service_name} --quiet").and_return(shell_out_success)
262
+ expect(provider.is_enabled?).to be true
263
+ end
250
264
 
251
- it "should return false if '/bin/systemctl is-enabled service_name' returns anything except 0" do
252
- expect(@provider).to receive(:shell_out).with('/bin/systemctl is-enabled rsyslog.service --quiet').and_return(@shell_out_failure)
253
- expect(@provider.is_enabled?).to be_false
265
+ it "should return false if '#{systemctl_path} is-enabled service_name' returns anything except 0" do
266
+ expect(provider).to receive(:shell_out).with("#{systemctl_path} is-enabled #{service_name} --quiet").and_return(shell_out_failure)
267
+ expect(provider.is_enabled?).to be false
268
+ end
254
269
  end
255
270
  end
256
271
  end