Module: ChefSpec::API::PowershellScriptMatchers

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

Overview

Since:

  • 3.0.0

Instance Method Summary collapse

Instance Method Details

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

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

powershell_script '/tmp' do
  action :run
end

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

Examples:

Assert that a powershell_script was runed

expect(chef_run).to run_powershell_script('/tmp')

Assert that a powershell_script was runed with predicate matchers

expect(chef_run).to run_powershell_script('/tmp').with_user('svargo')

Assert that a powershell_script was runed with attributes

expect(chef_run).to run_powershell_script('/tmp').with(user: 'svargo')

Assert that a powershell_script was runed using a regex

expect(chef_run).to run_powershell_script('/tmp').with(user: /sva(.+)/)

Assert that a powershell_script was not runed

expect(chef_run).to_not run_powershell_script('/tmp')

Parameters:

  • resource_name (String, Regex)

    the name of the resource to match

Returns:

Since:

  • 3.0.0



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

def run_powershell_script(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:powershell_script, :run, resource_name)
end