Skip to content

Verify the last argument is called in receive_message_chain

gitlab-qa-bot requested to merge github/fork/jdelStrother/message_chain into master

Created by: jdelStrother

Prior to this, something like -

  expect(object).to receive_message_chain(:foo, :bar => 1)
  object.foo

would pass, despite 'bar' not being called.

After applying these changes to message_chain.rb, the existing spec "raises when expect is used and the entire chain isn't called" started failing - it expects a single MockExpectationError to be raised, whereas you actually get one raised from the explicit call to verify_all (that farce wasn't called), then the implicit verify_all kicks in at the end of the spec and finds that length wasn't called either (which causes the spec to fail).

reset() seems to commonly be used to fix these sort problems in rspec's specs, but I couldn't figure out how to reset the right double with a message chain. Here, I work around it with begin; verify_all; rescue RSpec::Mocks::MockExpectationError; end. Any better suggestions?

Merge request reports