我的 Chef 食谱引发了我希望在 ChefSpec 测试中预期的编译时错误。
食谱片段
if !windows_version.windows_server_2012_r2?
error = "Not supported on this version of Windows"
raise error
end
windows_package 'Server2012 Only Package' do
action :install
end
单元测试片段
it 'Throws error' do
expect(chef_run).to raise_error
end
但这不会捕获错误并通过测试。相反,我收到编译时错误并且测试失败。