rubocop-rspec icon indicating copy to clipboard operation
rubocop-rspec copied to clipboard

Different message expectation methods for setup and assertion

Open Drenmi opened this issue 8 years ago • 2 comments

I will generally use allow for setup:

before do
  allow(foo).to receive(:bar).and_return(:baz)
end

and assertion:

it { expect(foo).to receive(:bar) }

If this makes sense, it could make a case for making MessageExpectation context aware. 🙂

Drenmi avatar Jun 14 '17 07:06 Drenmi

Ah yeah we made that disabled by default because no one besides me wanted to say "only use expect(...).to have_received(...) exclusively". I think it was superseded by MessageSpies? Might fit your use case better but let me know because I sort of forget the little details of these cops over time.

btw excited to see you opening issues on rubocop-rspec too :smile:

backus avatar Jun 14 '17 08:06 backus

I will play around a bit with the settings, and see if I can get something that fits. If not, at least I can make a more specific suggestion. 🙂

btw excited to see you opening issues on rubocop-rspec too 😄

Yes. I'm spilling over into the neighbouring communities. 😅

Drenmi avatar Jun 14 '17 08:06 Drenmi