spec/rubocop/cop/rspec/message_expectation_spec.rb in rubocop-rspec-1.12.0 vs spec/rubocop/cop/rspec/message_expectation_spec.rb in rubocop-rspec-1.13.0
- old
+ new
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-describe RuboCop::Cop::RSpec::MessageExpectation, :config do
+RSpec.describe RuboCop::Cop::RSpec::MessageExpectation, :config do
subject(:cop) { described_class.new(config) }
context 'when EnforcedStyle is allow' do
let(:cop_config) do
{ 'EnforcedStyle' => 'allow' }
@@ -17,21 +17,12 @@
it 'approves of allow(...).to receive' do
expect_no_violations('allow(foo).to receive(:bar)')
end
- it 'generates a todo based on the usage of the correct style' do
- inspect_source(cop, 'allow(foo).to receive(:bar)', 'foo_spec.rb')
-
- expect(cop.config_to_allow_offenses).to eq('EnforcedStyle' => 'allow')
- 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' => 'expect')
- end
+ include_examples 'detects style', 'allow(foo).to receive(:bar)', 'allow'
+ include_examples 'detects style', 'expect(foo).to receive(:bar)', 'expect'
end
context 'when EnforcedStyle is expect' do
let(:cop_config) do
{ 'EnforcedStyle' => 'expect' }
@@ -46,18 +37,9 @@
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')
-
- expect(cop.config_to_allow_offenses).to eq('EnforcedStyle' => 'expect')
- end
-
- it 'generates a todo based on the usage of the alternate style' do
- inspect_source(cop, 'allow(foo).to receive(:bar)', 'foo_spec.rb')
-
- expect(cop.config_to_allow_offenses).to eq('EnforcedStyle' => 'allow')
- end
+ include_examples 'detects style', 'expect(foo).to receive(:bar)', 'expect'
+ include_examples 'detects style', 'allow(foo).to receive(:bar)', 'allow'
end
end