首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ChefSpec找不到我的厨师资源

ChefSpec找不到我的厨师资源
EN

Stack Overflow用户
提问于 2014-07-21 14:04:22
回答 1查看 2K关注 0票数 1

我有一本食谱,里面有很多菜谱和LWRP的食谱。现在我想开始用ChefSpec来做报道,并写了一个例子:

代码语言:javascript
复制
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

我跑步的结果:

代码语言:javascript
复制
~/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没有注意到我的资源?

编辑:

按Seth的建议移动了ChefSpec::Coverage.start!

下面是发生这种情况的简单方法:

代码语言:javascript
复制
# 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'
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-21 15:23:54

根据ChefSpec报告文档的说法,您必须在之前包含覆盖调用,然后再使用

要生成覆盖报告,在需要任何“厨师”代码之前,请将以下内容添加到spec_helper.rb中: 要求‘厨师规格’ChefSpec::Coverage.start!

在您的代码中,您将在规范运行后调用覆盖率报告。移动:

代码语言:javascript
复制
ChefSpec::Coverage.start!

在你的describe块之前。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24867085

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档