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

Prevent block-only matchers from being used with value expectation target #1125

Commits on Sep 14, 2019

  1. Prevent block-only matchers from being used with value expectation ta…

    …rget
    
    https://blog.rubystyle.guide/rspec/2019/07/17/rspec-implicit-block-syntax.html
    https://rspec.rubystyle.guide/#implicit-block-expectations
    
    Spec changes are due to:
    
        matcher.matches?(invalid_value)
    
    doesn't work with block-only matchers, as no block is passed in, and it
    fails with a message:
    
        1) RSpec::Matchers::BuiltIn::Change behaves like an RSpec block-only matcher uses the `ObjectFormatter` for `failure_message`
           Failure/Error: expect(message).to include("detailed inspect")
             expected "expected `@k` to have changed, but was not given a block" to include "detailed inspect"
    
    The redundant (due to existing check in ExpectationTarget) `Proc ===
    @event_proc` checks could not be removed safely as well, since
    @actual_after is not initialized yet when we haven't executed the block:
    
         RuntimeError:
           Warnings were generated: rspec-dev/repos/rspec-expectations/lib/rspec/matchers/built_in/change.rb:407: warning: instance variable @actual_after not initialized
    
    Ruby 1.8-specific workarounds:
    
        multiple values for a block parameter (0 for 1)
    
    If a block expects an argument, it ought to be provided an argument in 1.8
    pirj committed Sep 14, 2019
    Configuration menu
    Copy the full SHA
    771da6d View commit details
    Browse the repository at this point in the history