Skip to content

Fails to match anything against windows_certificate resource's source property #980

@splatteredbits

Description

@splatteredbits

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions