spec/rubocop/cop/rspec/message_spies_spec.rb in rubocop-rspec-1.12.0 vs spec/rubocop/cop/rspec/message_spies_spec.rb in rubocop-rspec-1.13.0

- old
+ new

@@ -1,8 +1,8 @@ # frozen_string_literal: true -describe RuboCop::Cop::RSpec::MessageSpies, :config do +RSpec.describe RuboCop::Cop::RSpec::MessageSpies, :config do subject(:cop) { described_class.new(config) } context 'when EnforcedStyle is have_received' do let(:cop_config) do { 'EnforcedStyle' => 'have_received' } @@ -67,22 +67,15 @@ it 'approves of expect(...).to have_received' do expect_no_violations('expect(foo).to have_received(:bar)') end - it 'generates a todo based on the usage of the correct style' do - inspect_source(cop, 'expect(foo).to have_received(:bar)', 'foo_spec.rb') + include_examples 'detects style', 'expect(foo).to receive(:bar)', 'receive' - expect(cop.config_to_allow_offenses) - .to eq('EnforcedStyle' => 'have_received') - end - - it 'generates a todo based on the usage of the alternate style' do - inspect_source(cop, 'expect(foo).to receive(:bar)', 'foo_spec.rb') - - expect(cop.config_to_allow_offenses).to eq('EnforcedStyle' => 'receive') - end + include_examples 'detects style', + 'expect(foo).to have_received(:bar)', + 'have_received' end context 'when EnforcedStyle is receive' do let(:cop_config) do { 'EnforcedStyle' => 'receive' } @@ -147,19 +140,12 @@ it 'approves of expect(...).to receive' do expect_no_violations('expect(foo).to receive(:bar)') end - it 'generates a todo based on the usage of the correct style' do - inspect_source(cop, 'expect(foo).to receive(:bar)', 'foo_spec.rb') + include_examples 'detects style', 'expect(foo).to receive(:bar)', 'receive' - expect(cop.config_to_allow_offenses).to eq('EnforcedStyle' => 'receive') - end - - it 'generates a todo based on the usage of the alternate style' do - inspect_source(cop, 'expect(foo).to have_received(:bar)', 'foo_spec.rb') - - expect(cop.config_to_allow_offenses) - .to eq('EnforcedStyle' => 'have_received') - end + include_examples 'detects style', + 'expect(foo).to have_received(:bar)', + 'have_received' end end