Loading
Collapse consecutive stubs into receive_messages
What does this MR do?
The RSpec/ReceiveMessages cop flags multiple consecutive
allow(x).to receive(:msg).and_return(val) stubs on the same object that
can be collapsed into a single allow(x).to receive_messages(...) call.
This autocorrects 12 specs (bin, commands, components, controllers) to
use receive_messages and drops their entries from
.rubocop_todo/rspec/receive_messages.yml, continuing to chip away at
that TODO list.
Testing
bundle exec rubocop <files>
# => 12 files inspected, no offenses detected
bundle exec rspec <files>
# => 428 examples, 0 failuresAll affected specs pass locally. The two spec/bin/* files use
fast_spec_helper and are run individually (they cannot share a process
with spec_helper-loading specs); both pass. The "Missing metadata
feature_category" warnings from some examples are pre-existing and
unrelated to this change.
Author checklist
- RuboCop clean on all affected files
- All affected specs pass locally
- Each merged stub verified equivalent (no interleaved message expectations on the stubbed object)