Module: ChefSpec::API::ErlCallMatchers

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

Overview

Since:

  • 3.0.0

Instance Method Summary collapse

Instance Method Details

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

Assert that an erl_call resource exists in the Chef run with the action :run. Given a Chef Recipe that runs “net_adm:names()” as an erl_call:

erl_call 'net_adm:names()' do
  action :run
end

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

Examples:

Assert that an erl_call was runed

expect(chef_run).to run_erl_call('net_adm:names()')

Assert that an erl_call was runed with predicate matchers

expect(chef_run).to run_erl_call('net_adm:names()').with_node_name('example')

Assert that an erl_call was runed with attributes

expect(chef_run).to run_erl_call('net_adm:names()').with(node_name: 'example')

Assert that an erl_call was runed using a regex

expect(chef_run).to run_erl_call('net_adm:names()').with(node_name: /[a-z]+/)

Assert that an erl_call was not runed

expect(chef_run).to_not run_erl_call('net_adm:names()')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 3.0.0



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

def run_erl_call(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:erl_call, :run, resource_name)
end