ChefSpec – testinginclude_reciepe时的覆盖率

我正在尝试为我们的一些Cookbook写ChefSpectesting。 其中之一是包括许多其他的食谱,build立一个jenkinsCI环境。

Iam想知道其他人是如何testing包括的recepies。 我的“_spec.rb”在这一刻看起来像这样(例如testing,包括jenkins大师):

it 'includes the `jenkins` recipe' do expect(chef_run).to include_recipe('jenkins::master') end 

现在覆盖率下降了,因为我没有testing包含的食谱(他们有自己的chefspectesting)。

如果有人有一个例子或好的想法…会很好。

好吧,find一个Issu,看起来这是我的CodeCoverage的“问题” – 在Windows上的IAM: https : //github.com/sethvargo/chefspec/issues/594

在Ubuntu下同样的问题,没有OSXvalidation问题( – :

如果您只想testing从另一本食谱中收录的食谱,则可以对包含调用进行存根。

它在ChefSpec自述文件中的示例logging在https://github.com/sethvargo/chefspec#include_recipe

“保持包含食谱的资源不会被加载到厨师跑,但testing,配方包括”:

 describe 'example::default' do let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) } before do allow_any_instance_of(Chef::Recipe).to receive(:include_recipe).and_call_original allow_any_instance_of(Chef::Recipe).to receive(:include_recipe).with('other_cookbook::default') end it 'includes the other_cookbook' do expect_any_instance_of(Chef::Recipe).to receive(:include_recipe).with('other_cookbook::default') chef_run end end