Module: ChefSpec::API::MacportsPackageMatchers

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

Overview

Since:

  • 3.0.0

Instance Method Summary collapse

Instance Method Details

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

Assert that a macports_package resource exists in the Chef run with the action :install. Given a Chef Recipe that installs “community-zero” as a macports_package:

macports_package 'community-zero' do
  action :install
end

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

Examples:

Assert that a macports_package was installed

expect(chef_run).to install_macports_package('community-zero')

Assert that a macports_package was installed with predicate matchers

expect(chef_run).to install_macports_package('community-zero').with_version('1.2.3')

Assert that a macports_package was installed with attributes

expect(chef_run).to install_macports_package('community-zero').with(version: '1.2.3')

Assert that a macports_package was installed using a regex

expect(chef_run).to install_macports_package('community-zero').with(version: /(\d+\.){2}\.\d+/)

Assert that a macports_package was not installed

expect(chef_run).to_not install_macports_package('community-zero')

Since:

  • 3.0.0


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

def install_macports_package(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:macports_package, :install, resource_name)
end

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

Assert that a macports_package resource exists in the Chef run with the action :purge. Given a Chef Recipe that purges “community-zero” as a macports_package:

macports_package 'community-zero' do
  action :purge
end

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

Examples:

Assert that a macports_package was purgeed

expect(chef_run).to purge_macports_package('community-zero')

Assert that a macports_package was purgeed with predicate matchers

expect(chef_run).to purge_macports_package('community-zero').with_version('1.2.3')

Assert that a macports_package was purgeed with attributes

expect(chef_run).to purge_macports_package('community-zero').with(version: '1.2.3')

Assert that a macports_package was purgeed using a regex

expect(chef_run).to purge_macports_package('community-zero').with(version: /(\d+\.){2}\.\d+/)

Assert that a macports_package was not purgeed

expect(chef_run).to_not purge_macports_package('community-zero')

Since:

  • 3.0.0


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

def purge_macports_package(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:macports_package, :purge, resource_name)
end

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

Assert that a macports_package resource exists in the Chef run with the action :remove. Given a Chef Recipe that removes “community-zero” as a macports_package:

macports_package 'community-zero' do
  action :remove
end

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

Examples:

Assert that a macports_package was removeed

expect(chef_run).to remove_macports_package('community-zero')

Assert that a macports_package was removeed with predicate matchers

expect(chef_run).to remove_macports_package('community-zero').with_version('1.2.3')

Assert that a macports_package was removeed with attributes

expect(chef_run).to remove_macports_package('community-zero').with(version: '1.2.3')

Assert that a macports_package was removeed using a regex

expect(chef_run).to remove_macports_package('community-zero').with(version: /(\d+\.){2}\.\d+/)

Assert that a macports_package was not removeed

expect(chef_run).to_not remove_macports_package('community-zero')

Since:

  • 3.0.0


113
114
115
# File 'lib/chefspec/api/macports_package.rb', line 113

def remove_macports_package(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:macports_package, :remove, resource_name)
end

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

Assert that a macports_package resource exists in the Chef run with the action :upgrade. Given a Chef Recipe that upgrades “community-zero” as a macports_package:

macports_package 'community-zero' do
  action :upgrade
end

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

Examples:

Assert that a macports_package was upgradeed

expect(chef_run).to upgrade_macports_package('community-zero')

Assert that a macports_package was upgradeed with predicate matchers

expect(chef_run).to upgrade_macports_package('community-zero').with_version('1.2.3')

Assert that a macports_package was upgradeed with attributes

expect(chef_run).to upgrade_macports_package('community-zero').with(version: '1.2.3')

Assert that a macports_package was upgradeed using a regex

expect(chef_run).to upgrade_macports_package('community-zero').with(version: /(\d+\.){2}\.\d+/)

Assert that a macports_package was not upgradeed

expect(chef_run).to_not upgrade_macports_package('community-zero')

Since:

  • 3.0.0


150
151
152
# File 'lib/chefspec/api/macports_package.rb', line 150

def upgrade_macports_package(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:macports_package, :upgrade, resource_name)
end