Module: ChefSpec::API::SystemdUnitMatchers

Defined in:
lib/chefspec/api/systemd_unit.rb

Overview

Since:

  • 5.1.0

Instance Method Summary collapse

Instance Method Details

#create_systemd_unit(resource_name) ⇒ ChefSpec::Matchers::ResourceMatcher

Assert that a systemd_unit resource exists in the Chef run with the action :create. Given a Chef Recipe that creates the systemd_unit “sysstat-collect.timer”:

systemd_unit 'sysstat-collect.timer' do
  action :create
end

The Examples section demonstrates the different ways to test a systemd_unit resource with ChefSpec.

Examples:

Assert that a systemd_unit was created

expect(chef_run).to create_systemd_unit('sysstat-collect.timer')

Assert that a systemd_unit was not created

expect(chef_run).to_not create_systemd_unit('sysstat-collect.timer')

Parameters:

  • the name of the resource to match

Returns:

Since:

  • 5.1.0



31
32
33
# File 'lib/chefspec/api/systemd_unit.rb', line 31

def create_systemd_unit(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:systemd_unit, :create, resource_name)
end

#delete_systemd_unit(resource_name) ⇒ ChefSpec::Matchers::ResourceMatcher

Assert that a systemd_unit resource exists in the Chef run with the action :delete. Given a Chef Recipe that deletes the systemd_unit “sysstat-collect.timer”:

systemd_unit 'sysstat-collect.timer' do
  action :delete
end

The Examples section demonstrates the different ways to test a systemd_unit resource with ChefSpec.

Examples:

Assert that a systemd_unit was deleted

expect(chef_run).to delete_systemd_unit('sysstat-collect.timer')

Assert that a systemd_unit was not deleted

expect(chef_run).to_not delete_systemd_unit('sysstat-collect.timer')

Parameters:

  • the name of the resource to match

Returns:

Since:

  • 5.1.0



60
61
62
# File 'lib/chefspec/api/systemd_unit.rb', line 60

def delete_systemd_unit(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:systemd_unit, :delete, resource_name)
end

#disable_systemd_unit(resource_name) ⇒ ChefSpec::Matchers::ResourceMatcher

Assert that a systemd_unit resource exists in the Chef run with the action :disable. Given a Chef Recipe that disables the systemd_unit “sysstat-collect.timer”:

systemd_unit 'sysstat-collect.timer' do
  action :disable
end

The Examples section demonstrates the different ways to test a systemd_unit resource with ChefSpec.

Examples:

Assert that a systemd_unit was disabled

expect(chef_run).to disable_systemd_unit('sysstat-collect.timer')

Assert that a systemd_unit was not disabled

expect(chef_run).to_not disable_systemd_unit('sysstat-collect.timer')

Parameters:

  • the name of the resource to match

Returns:

Since:

  • 5.1.0



118
119
120
# File 'lib/chefspec/api/systemd_unit.rb', line 118

def disable_systemd_unit(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:systemd_unit, :disable, resource_name)
end

#enable_systemd_unit(resource_name) ⇒ ChefSpec::Matchers::ResourceMatcher

Assert that a systemd_unit resource exists in the Chef run with the action :enable. Given a Chef Recipe that enables the systemd_unit “sysstat-collect.timer”:

systemd_unit 'sysstat-collect.timer' do
  action :enables
end

The Examples section demonstrates the different ways to test a systemd_unit resource with ChefSpec.

Examples:

Assert that a systemd_unit was enabled

expect(chef_run).to enable_systemd_unit('sysstat-collect.timer')

Assert that a systemd_unit was not enabled

expect(chef_run).to_not enable_systemd_unit('sysstat-collect.timer')

Parameters:

  • the name of the resource to match

Returns:

Since:

  • 5.1.0



89
90
91
# File 'lib/chefspec/api/systemd_unit.rb', line 89

def enable_systemd_unit(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:systemd_unit, :enable, resource_name)
end

#mask_systemd_unit(resource_name) ⇒ ChefSpec::Matchers::ResourceMatcher

Assert that a systemd_unit resource exists in the Chef run with the action :mask. Given a Chef Recipe that masks the systemd_unit “sysstat-collect.timer”:

systemd_unit 'sysstat-collect.timer' do
  action :mask
end

The Examples section demonstrates the different ways to test a systemd_unit resource with ChefSpec.

Examples:

Assert that a systemd_unit was masked

expect(chef_run).to mask_systemd_unit('sysstat-collect.timer')

Assert that a systemd_unit was not masked

expect(chef_run).to_not mask_systemd_unit('sysstat-collect.timer')

Parameters:

  • the name of the resource to match

Returns:

Since:

  • 5.1.0



147
148
149
# File 'lib/chefspec/api/systemd_unit.rb', line 147

def mask_systemd_unit(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:systemd_unit, :mask, resource_name)
end

#reload_or_restart_systemd_unit(resource_name) ⇒ ChefSpec::Matchers::ResourceMatcher

Assert that a systemd_unit resource exists in the Chef run with the action :reload_or_restart. Given a Chef Recipe that reloads or restarts the systemd_unit “sysstat-collect.timer”:

systemd_unit 'sysstat-collect.timer' do
  action :reload_or_restart
end

The Examples section demonstrates the different ways to test a systemd_unit resource with ChefSpec.

Examples:

Assert that a systemd_unit was reloaded or restarted

expect(chef_run).to reload_or_restart_systemd_unit('sysstat-collect.timer')

Assert that a systemd_unit was not reloaded or restarted

expect(chef_run).to_not reload_or_restart_systemd_unit('sysstat-collect.timer')

Parameters:

  • the name of the resource to match

Returns:

Since:

  • 5.1.0



321
322
323
# File 'lib/chefspec/api/systemd_unit.rb', line 321

def reload_or_restart_systemd_unit(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:systemd_unit, :reload_or_restart, resource_name)
end

#reload_or_try_restart_systemd_unit(resource_name) ⇒ ChefSpec::Matchers::ResourceMatcher

Assert that a systemd_unit resource exists in the Chef run with the action :reload_or_try_restart. Given a Chef Recipe that reloads or attempts to restart the systemd_unit “sysstat-collect.timer”:

systemd_unit 'sysstat-collect.timer' do
  action :reload_or_try_restart
end

The Examples section demonstrates the different ways to test a systemd_unit resource with ChefSpec.

Examples:

Assert that a systemd_unit was reloaded or try restarted

expect(chef_run).to reload_or_try_restart_systemd_unit('sysstat-collect.timer')

Assert that a systemd_unit was not reloaded or try restarted

expect(chef_run).to_not reload_or_try_restart_systemd_unit('sysstat-collect.timer')

Parameters:

  • the name of the resource to match

Returns:

Since:

  • 5.1.0



349
350
351
# File 'lib/chefspec/api/systemd_unit.rb', line 349

def reload_or_try_restart_systemd_unit(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:systemd_unit, :reload_or_try_restart, resource_name)
end

#restart_systemd_unit(resource_name) ⇒ ChefSpec::Matchers::ResourceMatcher

Assert that a systemd_unit resource exists in the Chef run with the action :restart. Given a Chef Recipe that restarts the systemd_unit “sysstat-collect.timer”:

systemd_unit 'sysstat-collect.timer' do
  action :restart
end

The Examples section demonstrates the different ways to test a systemd_unit resource with ChefSpec.

Examples:

Assert that a systemd_unit was restarted

expect(chef_run).to restart_systemd_unit('sysstat-collect.timer')

Assert that a systemd_unit was not restarted

expect(chef_run).to_not restart_systemd_unit('sysstat-collect.timer')

Parameters:

  • the name of the resource to match

Returns:

Since:

  • 5.1.0



263
264
265
# File 'lib/chefspec/api/systemd_unit.rb', line 263

def restart_systemd_unit(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:systemd_unit, :restart, resource_name)
end

#start_systemd_unit(resource_name) ⇒ ChefSpec::Matchers::ResourceMatcher

Assert that a systemd_unit resource exists in the Chef run with the action :start. Given a Chef Recipe that starts the systemd_unit “sysstat-collect.timer”:

systemd_unit 'sysstat-collect.timer' do
  action :start
end

The Examples section demonstrates the different ways to test a systemd_unit resource with ChefSpec.

Examples:

Assert that a systemd_unit was started

expect(chef_run).to start_systemd_unit('sysstat-collect.timer')

Assert that a systemd_unit was not started

expect(chef_run).to_not start_systemd_unit('sysstat-collect.timer')

Parameters:

  • the name of the resource to match

Returns:

Since:

  • 5.1.0



205
206
207
# File 'lib/chefspec/api/systemd_unit.rb', line 205

def start_systemd_unit(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:systemd_unit, :start, resource_name)
end

#stop_systemd_unit(resource_name) ⇒ ChefSpec::Matchers::ResourceMatcher

Assert that a systemd_unit resource exists in the Chef run with the action :stop. Given a Chef Recipe that stops the systemd_unit “sysstat-collect.timer”:

systemd_unit 'sysstat-collect.timer' do
  action :stop
end

The Examples section demonstrates the different ways to test a systemd_unit resource with ChefSpec.

Examples:

Assert that a systemd_unit was stopped

expect(chef_run).to stop_systemd_unit('sysstat-collect.timer')

Assert that a systemd_unit was not stopped

expect(chef_run).to_not stop_systemd_unit('sysstat-collect.timer')

Parameters:

  • the name of the resource to match

Returns:

Since:

  • 5.1.0



234
235
236
# File 'lib/chefspec/api/systemd_unit.rb', line 234

def stop_systemd_unit(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:systemd_unit, :stop, resource_name)
end

#try_restart_systemd_unit(resource_name) ⇒ ChefSpec::Matchers::ResourceMatcher

Assert that a systemd_unit resource exists in the Chef run with the action :try_restart. Given a Chef Recipe that tries to restarts the systemd_unit “sysstat-collect.timer”:

systemd_unit 'sysstat-collect.timer' do
  action :try_restart
end

The Examples section demonstrates the different ways to test a systemd_unit resource with ChefSpec.

Examples:

Assert that a systemd_unit was try_restart’d

expect(chef_run).to try_restart_systemd_unit('sysstat-collect.timer')

Assert that a systemd_unit was not try_restart’d

expect(chef_run).to_not try_restart_systemd_unit('sysstat-collect.timer')

Parameters:

  • the name of the resource to match

Returns:

Since:

  • 5.1.0



292
293
294
# File 'lib/chefspec/api/systemd_unit.rb', line 292

def try_restart_systemd_unit(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:systemd_unit, :try_restart, resource_name)
end

#unmask_systemd_unit(resource_name) ⇒ ChefSpec::Matchers::ResourceMatcher

Assert that a systemd_unit resource exists in the Chef run with the action :unmask. Given a Chef Recipe that masks the systemd_unit “sysstat-collect.timer”:

systemd_unit 'sysstat-collect.timer' do
  action :unmask
end

The Examples section demonstrates the different ways to test a systemd_unit resource with ChefSpec.

Examples:

Assert that a systemd_unit was unmasked

expect(chef_run).to unmask_systemd_unit('sysstat-collect.timer')

Assert that a systemd_unit was not unmasked

expect(chef_run).to_not unmask_systemd_unit('sysstat-collect.timer')

Parameters:

  • the name of the resource to match

Returns:

Since:

  • 5.1.0



176
177
178
# File 'lib/chefspec/api/systemd_unit.rb', line 176

def unmask_systemd_unit(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:systemd_unit, :unmask, resource_name)
end