I had the same problem trying to test a custom Chef handler, but I tried to use Berkshelf to pull dependencies using the built-in ChefSpec support for Berkshelf. Here is what worked for me:
Add spec / spec_helper.rb with
require 'chefspec' require 'chefspec/berkshelf'
Add the .rspec file to the root of the cookbook project with
--color --format progress --require spec_helper
Make sure your spec (spec / default_spec.rb) is configured correctly
describe 'my_chef_handlers::default' do handler_path = File.join('files', 'default') let(:chef_run) do chef_runner = ChefSpec::Runner.new do |node| node.set['chef_handler']['handler_path'] = handler_path node.set['statsd']['server'] = '127.0.0.1' end chef_runner.converge 'my_chef_handlers::default' end end
Setting up the ChefSpec runner outside the let statement caused the cookbook to fail to find errors.
Sneal source share