我有一本包含一堆食谱和 LWRP 的食谱。我现在想开始使用 ChefSpec 进行覆盖,并写了一个示例:
require 'chefspec'
require 'chefspec/berkshelf'
ChefSpec::Coverage.start!
RSpec.configure do |config|
config.platform = 'debian'
config.version = '7.0'
end
describe 'zilvercms-debian::default' do
let(:chef_run) { ChefSpec::Runner.new(platform: 'debian', version: '7.0').converge(described_recipe) }
it 'includes the `timezone-ii::debian` recipe' do
expect(chef_run).to include_recipe('timezone-ii::debian')
end
end
我的跑步结果:
~/cookbooks/test-debian$ rspec
[2014-07-21T15:57:58+02:00] WARN: Cloning resource attributes for execute[apt-get-update] from prior resource (CHEF-3694)
[2014-07-21T15:57:58+02:00] WARN: Previous execute[apt-get-update]: /tmp/d20140721-9408-jceoey/cookbooks/apt/recipes/default.rb:29:in `from_file'
[2014-07-21T15:57:58+02:00] WARN: Current execute[apt-get-update]: /tmp/d20140721-9408-jceoey/cookbooks/apt/recipes/default.rb:38:in `from_file'
.
Finished in 0.16909 seconds (files took 2.29 seconds to load)
1 example, 0 failures
No Chef resources found, skipping coverage calculation...
有没有人知道为什么 ChefSpec 没有注意到我的资源?
编辑:
按照赛斯的建议搬家ChefSpec::Coverage.start!
。
这是一个简单的食谱:
# Set timezone for debian machine
include_recipe 'timezone-ii::debian'
# Include recipe for managing repositories on Debian and automatic updating
include_recipe 'debian::default'
# Set NTP for Debian
include_recipe 'ntp::default'