Introduce RSpec/AggregateExamples cop
Description of the proposal
It looks for opportunities to squash spec examples: https://www.rubydoc.info/gems/test-prof/0.11.2/RuboCop/Cop/RSpec/AggregateExamples
# bad
describe do
specify do
expect(number).to be_positive
expect(number).to be_odd
end
it { is_expected.to be_prime }
end
# good
describe do
specify do
expect(number).to be_positive
expect(number).to be_odd
is_expected.to be_prime
end
end
# fair - subject has side effects
describe do
specify do
expect(multiply_by(2)).to be_multiple_of(2)
end
specify do
expect(multiply_by(3)).to be_multiple_of(3)
end
end
Related discussion: https://gitlab.com/gitlab-org/plan/-/issues/145#note_411920773
The roll-out plan is to specify a file or directory to the Include
section of the cop and auto-correct (or fix) the existing offenses: #250316
Edited by Igor Drozdov