Skip to content

Instantly share code, notes, and snippets.

@Randommood
Forked from ranjib/recipe_spec.rb
Last active August 29, 2015 14:12
Show Gist options
  • Save Randommood/6a10263f34ac732ea86c to your computer and use it in GitHub Desktop.
Save Randommood/6a10263f34ac732ea86c to your computer and use it in GitHub Desktop.
let(:runner) do
memoized_runner('pd-gocd::agent') do |node|
#.....
end
end
def clear_runner(recipe)
@@runners.delete recipe
end
def memoized_runner(recipe, options={}, &block)
@@runners[recipe] ||= converged_runner(recipe, options, &block)
end
def converged_runner(recipe, options = {})
runner = ChefSpec::SoloRunner.new(
{file_cache_path: '/var/chef/cache'}.merge(options)
)
yield runner.node if block_given?
runner.converge(recipe)
runner
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment