If you look at the stacktrace:
20: begin
21>> include_recipe "build-essential::#{node['platform_family']}"
22: rescue Chef::Exceptions::RecipeNotFound
23: Chef::Log.warn "A build-essential recipe does not exist for the platform_family: #{node['platform_family']}"
24: end
You'll see on line 21 that the build-essential cookbook is trying to load a recipe that corresponds to the current node's platform family. However, for ChefSpec, that data isn't set unless you specifically tell ChefSpec what kind of node to impersonate. In other words, node['platform_family']
is nil
, so it's trying to include a recipe named build-essential::(nothing)
, and that's not valid.
To fix this, you can either set the value for platform_family:
let(chef_run) do
ChefSpec::Runner.new do |node|
node.automatic['platform_family'] = 'ubuntu'
end.converge(described_recipe)
end
Or (preferred), you can tell ChefSpec to impersonate a node:
let(:chef_run) { ChefSpec::Runner.new(platform: 'ubuntu', version: '12.04').converge(described_recipe) }