rodjek / rspec-puppet

RSpec tests for your Puppet manifests
http://rspec-puppet.com
MIT License
364 stars 203 forks source link

Allow arbitary matchers to be used with parameter matcher. #634

Open rayward opened 6 years ago

rayward commented 6 years ago

It'd be great if the built-in rspec matchers (or anything that conforms to the protocol - https://github.com/rspec/rspec-expectations/blob/master/lib/rspec/matchers/matcher_protocol.rb) could be used when testing a class parameter.

I have class that takes a complex hash as one of its parameters, I'd like to test that this hash includes a particular key/value under a certain context.

Right now I have to convert the include matcher to a proc to make this work:

is_expected.to contain_class('foo').with_settings(include('hello' => 'world').method(:matches?).to_proc)

I'd be nice if this matcher could be composed in a more fluid manner.

rodjek commented 6 years ago

@rayward I'm not planning on changing the matcher API significantly in 2.x, but using the built in matchers is planned for 3.x

rayward commented 6 years ago

Awesome, great to hear its already coming!