Given recipe recipes\certificate_authorities.rb:
windows_certificate 'CN=example.com' do
store_name 'ROOT'
source 'C:/MyFile.pem'
end
Given spec file spec/unit/recipes/certificate_authorities_spec.rb:
describe 'whs_certificates::certificate_authorities' do
platform 'windows'
context 'When all attributes are default on Windows' do
it "should install certificate \"CN=example.com\"" do
is_expected.to create_windows_certificate('CN=example.com').with(store_name: end_with('ROOT')).with(source: end_with('MyFile.pem'))
end
end
end
Then chef exec rspec --format=d fails with:
1) whs_certificates::certificate_authorities When all attributes are default on Windows should install certificate "CN=example.com"
Failure/Error: is_expected.to create_windows_certificate('CN=example.com').with(store_name: end_with('ROOT')).with(source: end_with('MyFile.pem'))
expected "windows_certificate[CN=example.com]" to have parameters:
source #<RSpec::Matchers::BuiltIn::EndWith:0x0000000008fdad60 @actual_does_not_have_ordered_elements=false, @expected="MyFile.pem">, was "C:/MyFile.pem"
Diff:
@@ -1,2 +1,2 @@
-(end with "MyFile.pem")
+"C:/MyFile.pem"
I would expect this to match since obviously the source property does end with MyFile.pem. I've also tried the match(/MyFile\.pem/) matcher and had the same problem. I've tried combining the two with calls: .with(store_name: end_with('ROOT'), source: end_with('MyFile.pem')).
I expect this test to pass.
Given recipe
recipes\certificate_authorities.rb:Given spec file
spec/unit/recipes/certificate_authorities_spec.rb:Then
chef exec rspec --format=dfails with:I would expect this to match since obviously the
sourceproperty does end withMyFile.pem. I've also tried thematch(/MyFile\.pem/)matcher and had the same problem. I've tried combining the twowithcalls:.with(store_name: end_with('ROOT'), source: end_with('MyFile.pem')).I expect this test to pass.