Module: ChefSpec::API::OhaiMatchers

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

Overview

Since:

  • 3.0.0

Instance Method Summary collapse

Instance Method Details

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

Assert that an ohai resource exists in the Chef run with the action :reload. Given a Chef Recipe that reloads “reload” as an ohai:

ohai 'reload' do
  action :reload
end

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

Examples:

Assert that an ohai was reloaded

expect(chef_run).to reload_ohai('reload')

Assert that an ohai was reloaded with predicate matchers

expect(chef_run).to reload_ohai('reload').with_system(true)

Assert that an ohai was reloaded with attributes

expect(chef_run).to reload_ohai('reload').with(system: true)

Assert that an ohai was reloaded using a regex

expect(chef_run).to reload_ohai('reload').with(system: /true/)

Assert that an ohai was not reloaded

expect(chef_run).to_not reload_ohai('reload')

Since:

  • 3.0.0


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

def reload_ohai(resource_name)
  ChefSpec::Matchers::ResourceMatcher.new(:ohai, :reload, resource_name)
end