Module: ChefSpec::API::DeployMatchers

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

Overview

Since:

  • 3.0.0

Instance Method Summary collapse

Instance Method Details

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

Assert that a deploy resource exists in the Chef run with the action :deploy. Given a Chef Recipe that deploys “/tmp/path” as a deploy:

deploy '/tmp/path' do
  action :deploy
end

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

Examples:

Assert that a deploy was deployed

expect(chef_run).to deploy_deploy('/tmp/path')

Assert that a deploy was deployed with predicate matchers

expect(chef_run).to deploy_deploy('/tmp/path').with_repo('ssh://...')

Assert that a deploy was deployed with attributes

expect(chef_run).to deploy_deploy('/tmp/path').with(repo: 'ssh://...')

Assert that a deploy was deployed using a regex

expect(chef_run).to deploy_deploy('/tmp/path').with(repo: /ssh:(.+)/)

Assert that a deploy was not deployed

expect(chef_run).to_not deploy_deploy('/tmp/path')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 3.0.0



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

def deploy_deploy(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:deploy, :deploy, resource_name)
end

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

Assert that a deploy resource exists in the Chef run with the action :force_deploy. Given a Chef Recipe that force_deploys “/tmp/path” as a deploy:

deploy '/tmp/path' do
  action :force_deploy
end

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

Examples:

Assert that a deploy was force_deployed

expect(chef_run).to force_deploy_deploy('/tmp/path')

Assert that a deploy was force_deployed with predicate matchers

expect(chef_run).to force_deploy_deploy('/tmp/path').with_repo('ssh://...')

Assert that a deploy was force_deployed with attributes

expect(chef_run).to force_deploy_deploy('/tmp/path').with(repo: 'ssh://...')

Assert that a deploy was force_deployed using a regex

expect(chef_run).to force_deploy_deploy('/tmp/path').with(repo: /ssh:(.+)/)

Assert that a deploy was not force_deployed

expect(chef_run).to_not force_deploy_deploy('/tmp/path')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 3.0.0



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

def force_deploy_deploy(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:deploy, :force_deploy, resource_name)
end

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

Assert that a deploy resource exists in the Chef run with the action :rollback. Given a Chef Recipe that rolls back “/tmp/path” as a deploy:

deploy '/tmp/path' do
  action :rollback
end

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

Examples:

Assert that a deploy was rolled back

expect(chef_run).to rollback_deploy('/tmp/path')

Assert that a deploy was rolled back with predicate matchers

expect(chef_run).to rollback_deploy('/tmp/path').with_repo('ssh://...')

Assert that a deploy was rolled back with attributes

expect(chef_run).to rollback_deploy('/tmp/path').with(repo: 'ssh://...')

Assert that a deploy was rolled back using a regex

expect(chef_run).to rollback_deploy('/tmp/path').with(repo: /ssh:(.+)/)

Assert that a deploy was not rolled back

expect(chef_run).to_not rollback_deploy('/tmp/path')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 3.0.0



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

def rollback_deploy(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:deploy, :rollback, resource_name)
end