Skip to content

Commit 4d8ec6d

Browse files
Copilotdamacus
andcommitted
Revert to inline testing with converge_block method
Co-authored-by: damacus <[email protected]>
1 parent ea003cb commit 4d8ec6d

File tree

2 files changed

+16
-33
lines changed

2 files changed

+16
-33
lines changed

spec/service_spec.rb

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,24 @@
3434

3535
# Test default behavior (no restart)
3636
context 'with default configuration' do
37-
supported_platforms.each do |platform, versions|
38-
versions.each do |version|
39-
context "on #{platform.capitalize} #{version}" do
40-
let(:chef_run) do
41-
ChefSpec::ServerRunner.new(platform: platform, version: version, step_into: ['elasticsearch_service']) do |node, server|
42-
node_resources(node)
43-
stub_chef_zero(platform, version, server)
44-
end.converge('test::default_service')
45-
end
46-
47-
it 'creates systemd unit without restart policy' do
48-
systemd_unit = chef_run.systemd_unit('elasticsearch')
49-
expect(systemd_unit.content[:Service]).not_to have_key(:Restart)
50-
expect(systemd_unit.content[:Service]).not_to have_key(:RestartSec)
51-
end
37+
let(:chef_run) do
38+
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '20.04', step_into: ['elasticsearch_service']) do |node, server|
39+
node_resources(node)
40+
stub_chef_zero('ubuntu', '20.04', server)
41+
end.converge_block do
42+
elasticsearch_user 'elasticsearch'
43+
elasticsearch_install 'elasticsearch' do
44+
type 'package'
5245
end
46+
elasticsearch_configure 'elasticsearch'
47+
elasticsearch_service 'elasticsearch'
5348
end
5449
end
50+
51+
it 'creates systemd unit without restart policy' do
52+
systemd_unit = chef_run.systemd_unit('elasticsearch')
53+
expect(systemd_unit.content[:Service]).not_to have_key(:Restart)
54+
expect(systemd_unit.content[:Service]).not_to have_key(:RestartSec)
55+
end
5556
end
5657
end

test/fixtures/cookbooks/test/recipes/default_service.rb

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)