在 chefspec 中测试 windows_package 资源时出错

Error testing windows_package resource in chefspec

我有厨师资源如下

windows_package node['besclient']['exe_display_name'] do
  installer_type :installshield
  source "#{download_dir}\BESClient-installer.exe"
end

在属性文件中我有 default['besclient']['exe_display_name'] = 'IBM BigFix Client'download_dir = "#{Chef::Config[:file_cache_path]}\BESClient"

为了测试这个我有以下测试

it 'installs a windows_package with attributes' do
     expect(chef_run).to install_windows_package('IBM BigFix Client').with(
     installer_type: :installshield,
     source: "#{download_dir}\BESClient-installer.exe"
)
end

其中 download_dir = "C:\Program Files (x86)\BigFix Enterprise\BESClient" 但这不断给出以下错误:

besclient::windows
  Windows 2012R2: when all attributes are default
    converges successfully
    installs a windows_package with attributes (FAILED - 1)

Failures:

  1) besclient::windows Windows 2012R2: when all attributes are default installs
 a windows_package with attributes
     Failure/Error:
       expect(chef_run).to install_windows_package('IBM BigFix Client').with(
         installer_type: :installshield,
         source: "#{download_dir}\BESClient-installer.exe"
       )

       expected "windows_package[IBM BigFix Client]" to have parameters:

         source "C:\Program Files (x86)\BigFix Enterprise\BESClient\BESClien
t-installer.exe", was "c:\program files (x86)\bigfix enterprise\besclient\be
sclient-installer.exe"
     # ./spec/unit/recipes/windows_spec.rb:48:in `block (3 levels) in <top (requ
ired)>'

Finished in 4.74 seconds (files took 17.56 seconds to load)
2 examples, 1 failure

Failed examples:

rspec ./spec/unit/recipes/windows_spec.rb:47 # besclient::windows Windows 2012R2
: when all attributes are default installs a windows_package with attributes

我已经定义了runner如下

runner = ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2',file_cache_path: 'C:\Program Files (x86)\BigFix Enterprise')
runner.converge(described_recipe)

source 属性 通过一些强制逻辑,包括 downcase! 得到 运行。您必须调整测试以匹配。