我是Chef的新手,也是ChefSpec的新手。我尝试使用下面的Coverage
文件运行spec_helper.rb
以获取ChefSpec保险:
require 'chefspec'
require 'chefspec/berkshelf'
ChefSpec::Coverage.start! do
add_output do |reportOutput|
File.open( "coverage.json","w" ) do |f|
f.puts(reportOutput[:total])
f.puts(reportOutput[:touched])
f.puts(reportOutput[:coverage])
f.puts(reportOutput[:untouched_resources])
f.puts(reportOutput[:all_resources])
end
end
end
当我运行rspec
时,我在输出中得到了这个:
WARNING: you must specify a 'platform' and 'version' to your ChefSpec
Runner and/or Fauxhai constructor, in the future omitting these will
become a hard error. A list of available platforms is available at
https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
.WARNING: you must specify a 'platform' and 'version' to your ChefSpec
Runner and/or Fauxhai constructor, in the future omitting these will
become a hard error. A list of available platforms is available at
https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
我不确定如何在Coverage
中指定平台和版本 - 我看到了一些关于如何使用ChefSpec::ServerRunner.new()
进行操作的示例。
答案 0 :(得分:1)
您没有显示您的规范,因此我无法具体说明,但您必须将platform
和version
选项传递给Runner构造函数,就像错误所说的那样。例如ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04')
。您还可以在规范助手中为所有测试全局指定一次,说明在ChefSpec自述文件中。