关于平台和版本的 Chef 警告 运行 ChefSpec 的覆盖范围

Chef warning about platform and version running Coverage for ChefSpec

我对 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() 指定平台和版本的示例。

你没有显示你的规格所以我不能具体说,但你必须将 platformversion 选项传递给你的 Runner 构造函数,就像错误所说的那样。例如 ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04')。您还可以在您的规范助手中为所有测试全局指定一次,说明在 ChefSpec 自述文件中。