我有以下主厨资源
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 = ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2',file_cache_path: 'C:\Program Files (x86)\BigFix Enterprise')
runner.converge(described_recipe)