Module: ChefSpec::API::AptRepositoryMatchers

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

Overview

Since:

  • 3.0.0

Instance Method Summary collapse

Instance Method Details

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

Assert that an apt_repository resource exists in the Chef run with the action :add. Given a Chef Recipe that adds “rsyslog” as an apt_repository:

apt_repository 'rsyslog' do
  uri 'ppa:adiscon/v8-stable'
  action :add
end

The Examples section demonstrates the different ways to test an apt_repository resource with ChefSpec.

Examples:

Assert that an apt_repository was added

expect(chef_run).to add_apt_repository('rsyslog')

Parameters:

  • the name of the resource to match

Returns:

Since:

  • 3.0.0



26
27
28
29
# File 'lib/chefspec/api/apt_repository.rb', line 26

def add_apt_repository(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:apt_repository, :add,
                                          resource_name)
end

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

Assert that an apt_repository resource exists in the Chef run with the action :remove. Given a Chef Recipe that removes “rsyslog” as an apt_repository:

apt_repository 'rsyslog' do
  uri 'ppa:adiscon/v8-stable'
  action :remove
end

The Examples section demonstrates the different ways to test an apt_repository resource with ChefSpec.

Examples:

Assert that an apt_repository was removed

expect(chef_run).to remove_apt_repository('rsyslog')

Parameters:

  • the name of the resource to match

Returns:

Since:

  • 3.0.0



51
52
53
54
# File 'lib/chefspec/api/apt_repository.rb', line 51

def remove_apt_repository(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:apt_repository, :remove,
                                          resource_name)
end