Skip to content

Commit

Permalink
Remove explicit subject(:cop) from specs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bquorning authored and mockdeep committed Jun 14, 2020
1 parent bf5a084 commit 7b43684
Show file tree
Hide file tree
Showing 30 changed files with 0 additions and 60 deletions.
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/capybara/feature_methods_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::Capybara::FeatureMethods, :config do
subject(:cop) { described_class.new(config) }

it 'flags violations for `background`' do
expect_offense(<<-RUBY)
describe 'some feature' do
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/context_wording_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::ContextWording, :config do
subject(:cop) { described_class.new(config) }

let(:cop_config) { { 'Prefixes' => %w[when with] } }

it 'skips describe blocks' do
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/described_class_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::DescribedClass, :config do
subject(:cop) { described_class.new(config) }

let(:cop_config) { {} }

context 'when SkipBlocks is `true`' do
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/dialect_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::Dialect, :config do
subject(:cop) { described_class.new(config) }

let(:cop_config) do
{
'PreferredMethods' => {
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/empty_example_group_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::EmptyExampleGroup, :config do
subject(:cop) { described_class.new(config) }

it 'flags an empty context' do
expect_offense(<<-RUBY)
describe Foo do
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/empty_line_after_example_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::EmptyLineAfterExample, :config do
subject(:cop) { described_class.new(config) }

it 'flags a missing empty line after `it`' do
expect_offense(<<-RUBY)
RSpec.describe Foo do
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/example_length_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::ExampleLength, :config do
subject(:cop) { described_class.new(config) }

let(:cop_config) { { 'Max' => 3 } }

it 'ignores non-spec blocks' do
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/example_without_description_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::ExampleWithoutDescription, :config do
subject(:cop) { described_class.new(config) }

let(:cop_config) do
{ 'EnforcedStyle' => enforced_style }
end
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/example_wording_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::ExampleWording, :config do
subject(:cop) { described_class.new(config) }

context 'with configuration' do
let(:cop_config) do
{
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/expect_actual_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::ExpectActual, :config do
subject(:cop) { described_class.new(config) }

it 'flags numeric literal values within expect(...)' do
expect_offense(<<-RUBY)
describe Foo do
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/expect_change_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::ExpectChange, :config do
subject(:cop) { described_class.new(config) }

let(:cop_config) do
{ 'EnforcedStyle' => enforced_style }
end
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/factory_bot/create_list_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::FactoryBot::CreateList, :config do
subject(:cop) { described_class.new(config) }

let(:cop_config) do
{ 'EnforcedStyle' => enforced_style }
end
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/file_path_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::FilePath, :config do
subject(:cop) { described_class.new(config) }

it 'registers an offense for a bad path' do
expect_offense(<<-RUBY, 'wrong_path_foo_spec.rb')
describe MyClass, 'foo' do; end
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/hook_argument_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::HookArgument, :config do
subject(:cop) { described_class.new(config) }

let(:cop_config) do
{ 'EnforcedStyle' => enforced_style }
end
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/implicit_expect_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::ImplicitExpect, :config do
subject(:cop) { described_class.new(config) }

context 'when EnforcedStyle is is_expected' do
let(:cop_config) do
{ 'EnforcedStyle' => 'is_expected' }
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/implicit_subject_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::ImplicitSubject, :config do
subject(:cop) { described_class.new(config) }

let(:cop_config) do
{ 'EnforcedStyle' => enforced_style }
end
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/instance_variable_spec.rb
Expand Up @@ -131,8 +131,6 @@ def serialize
end

context 'when configured with AssignmentOnly', :config do
subject(:cop) { described_class.new(config) }

let(:cop_config) do
{ 'AssignmentOnly' => true }
end
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/it_behaves_like_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::ItBehavesLike, :config do
subject(:cop) { described_class.new(config) }

let(:cop_config) do
{ 'EnforcedStyle' => enforced_style }
end
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/message_expectation_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

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' }
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/message_spies_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

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' }
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/multiple_expectations_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::MultipleExpectations, :config do
subject(:cop) { described_class.new(config) }

context 'without configuration' do
let(:cop_config) { {} }

Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/named_subject_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::NamedSubject, :config do
subject(:cop) { described_class.new(config) }

shared_examples_for 'checking subject outside of shared examples' do
it 'checks `it` and `specify` for explicit subject usage' do
expect_offense(<<-RUBY)
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/nested_groups_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::NestedGroups, :config do
subject(:cop) { described_class.new(config) }

it 'flags nested contexts' do
expect_offense(<<-RUBY)
describe MyClass do
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/not_to_not_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::NotToNot, :config do
subject(:cop) { described_class.new(config) }

context 'when EnforcedStyle is `not_to`' do
let(:cop_config) { { 'EnforcedStyle' => 'not_to' } }

Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/predicate_matcher_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::PredicateMatcher, :config do
subject(:cop) { described_class.new(config) }

let(:cop_config) do
{ 'EnforcedStyle' => enforced_style,
'Strict' => strict,
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/rails/http_status_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::Rails::HttpStatus, :config do
subject(:cop) { described_class.new(config) }

context 'when EnforcedStyle is `symbolic`' do
let(:cop_config) { { 'EnforcedStyle' => 'symbolic' } }

Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/return_from_stub_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::ReturnFromStub, :config do
subject(:cop) { described_class.new(config) }

let(:cop_config) do
{ 'EnforcedStyle' => enforced_style }
end
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/variable_definition_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::VariableDefinition, :config do
subject(:cop) { described_class.new(config) }

context 'when EnforcedStyle is `symbols`' do
let(:cop_config) { { 'EnforcedStyle' => 'symbols' } }

Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/variable_name_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::VariableName, :config do
subject(:cop) { described_class.new(config) }

context 'when configured for `snake_case`' do
let(:cop_config) { { 'EnforcedStyle' => 'snake_case' } }

Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/rspec/verified_doubles_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::VerifiedDoubles, :config do
subject(:cop) { described_class.new(config) }

it 'finds a `double` instead of an `instance_double`' do
expect_offense(<<-RUBY)
it do
Expand Down

0 comments on commit 7b43684

Please sign in to comment.