Wrong error message generated by have_received matcher when method was called 2 or more times than expected

The wrong error message is generated when a `have_received` matcher is used with counts the exceed the expected due to use prematurely raising an exception. If we catch the exception everything works as is.

It's being in demented below in the ensure too, the one in the
conditional is only used when raising

On Thursday, 2 October 2014, Myron Marston <notifications@github.com> wrote:

> In lib/rspec/mocks/message_expectation.rb:
>
> >          args.unshift(orig_object) if yield_receiver_to_implementation_block?
> >
> > -        if negative? || ((@exactly || @at_most) && (@actual_received_count == @expected_received_count))
> > +        if negative? || (allowed_to_fail && (@exactly || @at_most) && (@actual_received_count == @expected_received_count))
> >            @actual_received_count += increment
>
> allowed_to_fail causes @actual_received_count to not be incremented.
> Won't that cause bugs? Seems like maybe allowed_to_fail should just be
> checked before @error_generator.raise_exepectation_error?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/rspec/rspec-mocks/pull/793/files#r18324084>.
>