Skip to content

Commit 4e7272b

Browse files
committed
Remove explicit subject(:cop) from specs
In rubocop/rubocop#7970 the shared context `config` was updated to include the following: let(:cop) do cop_class.new(config, cop_options) .tap { |cop| cop.processed_source = processed_source } end This is functionally equivalent to what we have all over our specs: subject(:cop) { described_class.new(config) } The downside is that our specs become a less explicit. Actually they now have a mystery guest, which may be considered a smell.
1 parent b9befd3 commit 4e7272b

30 files changed

+0
-60
lines changed

spec/rubocop/cop/rspec/capybara/feature_methods_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

33
RSpec.describe RuboCop::Cop::RSpec::Capybara::FeatureMethods, :config do
4-
subject(:cop) { described_class.new(config) }
5-
64
it 'flags violations for `background`' do
75
expect_offense(<<-RUBY)
86
describe 'some feature' do

spec/rubocop/cop/rspec/context_wording_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

33
RSpec.describe RuboCop::Cop::RSpec::ContextWording, :config do
4-
subject(:cop) { described_class.new(config) }
5-
64
let(:cop_config) { { 'Prefixes' => %w[when with] } }
75

86
it 'skips describe blocks' do

spec/rubocop/cop/rspec/described_class_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

33
RSpec.describe RuboCop::Cop::RSpec::DescribedClass, :config do
4-
subject(:cop) { described_class.new(config) }
5-
64
let(:cop_config) { {} }
75

86
context 'when SkipBlocks is `true`' do

spec/rubocop/cop/rspec/dialect_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

33
RSpec.describe RuboCop::Cop::RSpec::Dialect, :config do
4-
subject(:cop) { described_class.new(config) }
5-
64
let(:cop_config) do
75
{
86
'PreferredMethods' => {

spec/rubocop/cop/rspec/empty_example_group_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

33
RSpec.describe RuboCop::Cop::RSpec::EmptyExampleGroup, :config do
4-
subject(:cop) { described_class.new(config) }
5-
64
it 'flags an empty context' do
75
expect_offense(<<-RUBY)
86
describe Foo do

spec/rubocop/cop/rspec/empty_line_after_example_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

33
RSpec.describe RuboCop::Cop::RSpec::EmptyLineAfterExample, :config do
4-
subject(:cop) { described_class.new(config) }
5-
64
it 'flags a missing empty line after `it`' do
75
expect_offense(<<-RUBY)
86
RSpec.describe Foo do

spec/rubocop/cop/rspec/example_length_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

33
RSpec.describe RuboCop::Cop::RSpec::ExampleLength, :config do
4-
subject(:cop) { described_class.new(config) }
5-
64
let(:cop_config) { { 'Max' => 3 } }
75

86
it 'ignores non-spec blocks' do

spec/rubocop/cop/rspec/example_without_description_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

33
RSpec.describe RuboCop::Cop::RSpec::ExampleWithoutDescription, :config do
4-
subject(:cop) { described_class.new(config) }
5-
64
let(:cop_config) do
75
{ 'EnforcedStyle' => enforced_style }
86
end

spec/rubocop/cop/rspec/example_wording_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

33
RSpec.describe RuboCop::Cop::RSpec::ExampleWording, :config do
4-
subject(:cop) { described_class.new(config) }
5-
64
context 'with configuration' do
75
let(:cop_config) do
86
{

spec/rubocop/cop/rspec/expect_actual_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

33
RSpec.describe RuboCop::Cop::RSpec::ExpectActual, :config do
4-
subject(:cop) { described_class.new(config) }
5-
64
it 'flags numeric literal values within expect(...)' do
75
expect_offense(<<-RUBY)
86
describe Foo do

0 commit comments

Comments
 (0)