Skip to content

Commit

Permalink
Tweak new cop template
Browse files Browse the repository at this point in the history
Follow #9421.

This PR tweaks new cop template.

New cop development will rarely need `subject(:cop) { described_class.new(config) }`.
So I think there aren't any development tips lost by replacing it with
`RSpec.describe ..., :config`.

Perhaps `let(:config) { RuboCop::Config.new }` can also be removed,
but I'll look at it separately. Maybe not as explicitly unnecessary
as `subject(:cop) { described_class.new(config) }`.
  • Loading branch information
koic committed Jan 27, 2021
1 parent fdf25f2 commit 62c9e3f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions lib/rubocop/cop/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ def on_send(node)
SPEC_TEMPLATE = <<~SPEC
# frozen_string_literal: true
RSpec.describe RuboCop::Cop::%<department>s::%<cop_name>s do
subject(:cop) { described_class.new(config) }
RSpec.describe RuboCop::Cop::%<department>s::%<cop_name>s, :config do
let(:config) { RuboCop::Config.new }
# TODO: Write test code
Expand Down
4 changes: 1 addition & 3 deletions spec/rubocop/cop/generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ def on_send(node)
generated_source = <<~SPEC
# frozen_string_literal: true
RSpec.describe RuboCop::Cop::Style::FakeCop do
subject(:cop) { described_class.new(config) }
RSpec.describe RuboCop::Cop::Style::FakeCop, :config do
let(:config) { RuboCop::Config.new }
# TODO: Write test code
Expand Down

0 comments on commit 62c9e3f

Please sign in to comment.