Module: ChefSpec::API::DscScriptMatchers

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

Overview

Since:

  • 5.1.0

Instance Method Summary collapse

Instance Method Details

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

Assert that a dsc_script resource exists in the Chef run with the action :run. Given a Chef Recipe that runs “something” using dsc_script:

dsc_script 'something' do
  code "    something\n  EOH\n  action :run\nend\n"

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

Examples:

Assert that a dsc_script was run

expect(chef_run).to dsc_script('something')

Assert that a dsc_script was not run

expect(chef_run).to_not dsc_script('something')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 5.1.0



33
34
35
# File 'lib/chefspec/api/dsc_script.rb', line 33

def run_dsc_script(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:dsc_script, :run, resource_name)
end