Search code examples
rspecrspec3

Rspec: be_succes(not be_success) passes


I noticed in one of my tests that I had a typo for the response check, expect(response).to be_succes instead of expect(response).to be_success. The test passed. Why did the test still pass?

response.succes? returns:

Failure/Error: response.succes?
     NoMethodError:
       undefined method `succes?' for #<ActionController::TestResponse:0x007fe6e22a2530>

Solution

  • I had a chat with the guys at RSpec about this issue and it turns out that this is a somewhat intentional operation and is due to the present_tense_predicate and predicate methods in RSpec: https://github.com/rspec/rspec-expectations/blob/master/lib/rspec/matchers/built_in/be.rb#L248.

    As a result of raising this issue, it has been proposed that this issue wil be removed in RSpec 4: https://github.com/rspec/rspec-expectations/issues/935.