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 run

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

Assert that an erl_call was run with predicate matchers

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

Assert that an erl_call was run with attributes

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

Assert that an erl_call was run 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 run

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

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