Module: ChefSpec::API::LaunchdMatchers

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

Overview

Since:

  • 5.1.0

Instance Method Summary collapse

Instance Method Details

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

Assert that a launchd resource exists in the Chef run with the action :create_if_missing. Given a Chef Recipe that creates if missing the launchd daemon “com.chef.every15”:

launchd 'com.chef.every15' do
  action :create_if_missing
end

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

Examples:

Assert that a launchd was created

expect(chef_run).to create_if_missing_launchd('com.chef.every15')

Assert that a launchd was not created

expect(chef_run).to_not create_if_missing_launchd('com.chef.every15')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 5.1.0



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

def create_if_missing_launchd(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:launchd, :create_if_missing, resource_name)
end

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

Assert that a launchd resource exists in the Chef run with the action :create. Given a Chef Recipe that creates the launchd daemon “com.chef.every15”:

launchd 'com.chef.every15' do
  action :create
end

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

Examples:

Assert that a launchd was created

expect(chef_run).to create_launchd('com.chef.every15')

Assert that a launchd was not created

expect(chef_run).to_not create_launchd('com.chef.every15')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 5.1.0



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

def create_launchd(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:launchd, :create, resource_name)
end

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

Assert that a launchd resource exists in the Chef run with the action :delete. Given a Chef Recipe that deletes the launchd daemon “com.chef.every15”:

launchd 'com.chef.every15' do
  action :delete
end

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

Examples:

Assert that a launchd was deleted

expect(chef_run).to delete_launchd('com.chef.every15')

Assert that a launchd was not deleted

expect(chef_run).to_not delete_launchd('com.chef.every15')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 5.1.0



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

def delete_launchd(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:launchd, :delete, resource_name)
end

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

Assert that a launchd resource exists in the Chef run with the action :disable. Given a Chef Recipe that disables the launchd daemon “com.chef.every15”:

launchd 'com.chef.every15' do
  action :disable
end

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

Examples:

Assert that a launchd was disabled

expect(chef_run).to disable_launchd('com.chef.every15')

Assert that a launchd was not disabled

expect(chef_run).to_not disable_launchd('com.chef.every15')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 5.1.0



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

def disable_launchd(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:launchd, :disable, resource_name)
end

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

Assert that a launchd resource exists in the Chef run with the action :enable. Given a Chef Recipe that enables the launchd daemon “com.chef.every15”:

launchd 'com.chef.every15' do
  action :enables
end

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

Examples:

Assert that a launchd was enabled

expect(chef_run).to enable_launchd('com.chef.every15')

Assert that a launchd was not enabled

expect(chef_run).to_not enable_launchd('com.chef.every15')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 5.1.0



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

def enable_launchd(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:launchd, :enable, resource_name)
end