spec/rubocop/cop/rspec/receive_counts_spec.rb in rubocop-rspec-1.31.0 vs spec/rubocop/cop/rspec/receive_counts_spec.rb in rubocop-rspec-1.32.0
- old
+ new
@@ -76,13 +76,24 @@
expect(foo).to receive(:bar).at_most(2).times
^^^^^^^^^^^^^^^^^ Use `.at_most(:twice)` instead of `.at_most(2).times`.
RUBY
end
+ it 'allows exactly(1).times when not called on `receive`' do
+ expect_no_offenses(<<-RUBY)
+ expect(action).to have_published_event.exactly(1).times
+ RUBY
+ end
+
include_examples 'autocorrect',
'expect(foo).to receive(:bar).exactly(1).times { true }',
'expect(foo).to receive(:bar).once { true }'
include_examples 'autocorrect',
'expect(foo).to receive(:bar).at_least(2).times { true }',
'expect(foo).to receive(:bar).at_least(:twice) { true }'
+
+ # Does not auto-correct if not part of the RSpec API
+ include_examples 'autocorrect',
+ 'expect(foo).to have_published_event(:bar).exactly(2).times',
+ 'expect(foo).to have_published_event(:bar).exactly(2).times'
end