Skip to content

Instantly share code, notes, and snippets.

@chuckg
chuckg / include_recipe_helper.rb
Last active October 19, 2017 07:33 — forked from hartmantis/spec_helper.rb
ChefSpec/RSpec 3 stubs for testing a recipe in isolation
# Updated for rspec 3.0:
module IncludeRecipeHelper
def enable_stubbed_include_recipe
# Don't worry about external cookbook dependencies
allow_any_instance_of(Chef::Cookbook::Metadata).to receive(:depends)
# Test each recipe in isolation, regardless of includes
@included_recipes = []
allow_any_instance_of(Chef::RunContext).to receive(:loaded_recipe?).and_return(false)
allow_any_instance_of(Chef::Recipe).to receive(:include_recipe) do |recipe, included_recipe|