Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for rspec-expectations 3.8.5+ #767

Merged
merged 4 commits into from
Oct 7, 2019

Conversation

pirj
Copy link
Contributor

@pirj pirj commented Oct 6, 2019

This change adds value expectation support to RSpec's built-in raise_error matcher that is quite often used in projects using rspec-puppet, e.g.:

subject(:catalogue) { lambda { load_catalogue } }
it { is_expected.to raise_error Puppet::Error }

Also, since block matchers are more strict by default and don't accept value targets (defined as lambdas), this change adds an indicator that built-in rspec-puppet matchers do support value expectations as well as block expectations. This means that both:

it { expect(catalogue).to contain_file('README') }
it { expect { catalogue }.to contain_file('README') }

will work.

I'm not 100% certain this will work. Tested with https://github.com/voxpupuli/puppet-cassandra.
Appreciate if you can point out.

cc @alexjfisher @cyberious do you mind testing this against some of the projects depending on rspec-puppet that you maintain?

Related:
RSpec issue regarding the removal of implicit block syntax in a patch version rspec/rspec-expectations#1134
RSpec pull request with the removal rspec/rspec-expectations#1125
https://blog.rubystyle.guide/rspec/2019/07/17/rspec-implicit-block-syntax.html
rubocop/rspec-style-guide#76

pirj added 2 commits October 6, 2019 17:06
`rspec-expectations` has removed unintentional support for implicit
block expectation syntax, i.e:

    subject { -> { fail } }
    it { is_expected.to raise_error }

This also affects custom matchers, that should now specify that they
both support block targets and value targets.
@coveralls
Copy link

coveralls commented Oct 6, 2019

Coverage Status

Coverage decreased (-0.4%) to 85.5% when pulling 97267a2 on pirj:pin-rspec-expectations into 85a0d71 on rodjek:master.

@rodjek
Copy link
Owner

rodjek commented Oct 7, 2019

Thanks so much @pirj! I've run this change against a bunch of modules and it looks good :)

@rodjek rodjek added this to the 2.7.7 milestone Oct 7, 2019
@rodjek rodjek merged commit 6db5fb0 into rodjek:master Oct 7, 2019
@pirj pirj deleted the pin-rspec-expectations branch October 7, 2019 11:48
@pirj
Copy link
Contributor Author

pirj commented Oct 7, 2019

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants