Module: ChefSpec::API::YumRepositoryMatchers

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

Overview

Since:

  • 3.0.0

Instance Method Summary collapse

Instance Method Details

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

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

yum_repository 'epel' do
  baseurl "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-#{node['platform_version'].to_i}&arch=$basearch"
  description 'Extra Packages for $releasever - $basearch'
  action :add
end

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

Examples:

Assert that an yum_repository was added

expect(chef_run).to add_yum_repository('epel')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 3.0.0



53
54
55
56
# File 'lib/chefspec/api/yum_repository.rb', line 53

def add_yum_repository(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :add,
                                          resource_name)
end

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

Assert that a yum_repository resource exists in the Chef run with the action :create. Given a Chef Recipe that creates “epel” as an yum_repository:

yum_repository 'epel' do
  baseurl "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-#{node['platform_version'].to_i}&arch=$basearch"
  description 'Extra Packages for $releasever - $basearch'
  action :create
end

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

Examples:

Assert that an yum_repository was created

expect(chef_run).to create_yum_repository('epel')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 3.0.0



27
28
29
30
# File 'lib/chefspec/api/yum_repository.rb', line 27

def create_yum_repository(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :create,
                                          resource_name)
end

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

Assert that a yum_repository resource exists in the Chef run with the action :delete. Given a Chef Recipe that deletes “epel” as an yum_repository:

yum_repository 'epel' do
  action :delete
end

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

Examples:

Assert that an yum_repository was deleted

expect(chef_run).to delete_yum_repository('epel')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 3.0.0



77
78
79
80
# File 'lib/chefspec/api/yum_repository.rb', line 77

def delete_yum_repository(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :delete,
                                          resource_name)
end

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

Assert that a yum_repository resource exists in the Chef run with the action :makecache. Given a Chef Recipe that makes cache for “epel” as a yum_repository:

yum_repository 'epel' do
  action :makecache
end

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

Examples:

Assert that an yum_repository was make cache’d

expect(chef_run).to makecache_yum_repository('epel')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 3.0.0



125
126
127
128
# File 'lib/chefspec/api/yum_repository.rb', line 125

def makecache_yum_repository(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :makecache,
                                          resource_name)
end

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

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

yum_repository 'epel' do
  action :remove
end

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

Examples:

Assert that an yum_repository was removed

expect(chef_run).to remove_yum_repository('epel')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 3.0.0



101
102
103
104
# File 'lib/chefspec/api/yum_repository.rb', line 101

def remove_yum_repository(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :remove,
                                          resource_name)
end