Module: ChefSpec::API::AptUpdateMatchers

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

Overview

Since:

  • 3.0.0

Instance Method Summary collapse

Instance Method Details

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

Assert that an apt_update resource exists in the Chef run with the action :periodic. Given a Chef Recipe that updates “rsyslog” as an apt_update: periodically

apt_update 'rsyslog' do
  action :periodic
end

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

Examples:

Assert that an apt_update was updated periodically

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

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 3.0.0



48
49
50
51
# File 'lib/chefspec/api/apt_update.rb', line 48

def periodic_apt_update(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:apt_update, :periodic,
                                          resource_name)
end

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

Assert that an apt_update resource exists in the Chef run with the action :update. Given a Chef Recipe that adds “rsyslog” as a repository to update.

apt_repository 'rsyslog' do
  action :update
end

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

Examples:

Assert that an apt_update was run

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

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 3.0.0



24
25
26
27
# File 'lib/chefspec/api/apt_update.rb', line 24

def update_apt_update(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:apt_update, :update,
                                          resource_name)
end