Module: ChefSpec::API::SolarisPackageMatchers

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

Overview

Since:

  • 3.0.0

Instance Method Summary collapse

Instance Method Details

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

Assert that a solaris_package resource exists in the Chef run with the action :install. Given a Chef Recipe that installs “apache2” as a solaris_package:

solaris_package 'apache2' do
  action :install
end

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

Examples:

Assert that a solaris_package was installed

expect(chef_run).to install_solaris_package('apache2')

Assert that a solaris_package was installed with predicate matchers

expect(chef_run).to install_solaris_package('apache2').with_version('1.2.3')

Assert that a solaris_package was installed with attributes

expect(chef_run).to install_solaris_package('apache2').with(version: '1.2.3')

Assert that a solaris_package was installed using a regex

expect(chef_run).to install_solaris_package('apache2').with(version: /(\d+\.){2}\.\d+/)

Assert that a solaris_package was not installed

expect(chef_run).to_not install_solaris_package('apache2')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 3.0.0


39
40
41
# File 'lib/chefspec/api/solaris_package.rb', line 39

def install_solaris_package(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:solaris_package, :install, resource_name)
end

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

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

solaris_package 'apache2' do
  action :remove
end

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

Examples:

Assert that a solaris_package was removed

expect(chef_run).to remove_solaris_package('apache2')

Assert that a solaris_package was removed with predicate matchers

expect(chef_run).to remove_solaris_package('apache2').with_version('1.2.3')

Assert that a solaris_package was removed with attributes

expect(chef_run).to remove_solaris_package('apache2').with(version: '1.2.3')

Assert that a solaris_package was removed using a regex

expect(chef_run).to remove_solaris_package('apache2').with(version: /(\d+\.){2}\.\d+/)

Assert that a solaris_package was not removed

expect(chef_run).to_not remove_solaris_package('apache2')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 3.0.0


76
77
78
# File 'lib/chefspec/api/solaris_package.rb', line 76

def remove_solaris_package(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:solaris_package, :remove, resource_name)
end