Skip to content

Commit bcd4d32

Browse files
committed
Change step with new_cop command for rubocop-rspec_rails
before: ``` Do 4 steps: 1. Modify the description of RSpecRails/CopName in config/default.yml 2. Implement your new cop in the generated file! 3. Commit your new cop with a message such as e.g. "Add new `RSpecRails/CopName` cop" 4. Run `bundle exec rake changelog:new` to generate a changelog entry ``` after: ``` Do 4 steps: 1. Modify the description of RSpecRails/CopName in config/default.yml 2. Implement your new cop in the generated file! 3. Commit your new cop with a message such as e.g. "Add new `RSpecRails/CopName` cop" 4. Add an entry about new cop to CHANGELOG.md ```
1 parent 29eb4d3 commit bcd4d32

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Rakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,14 @@ task default: %i[build_config spec
8888
desc 'Generate a new cop template'
8989
task :new_cop, [:cop] do |_task, args|
9090
require 'rubocop'
91+
require_relative 'lib/rubocop/rspec_rails/cop/generator'
9192

9293
cop_name = args.fetch(:cop) do
9394
warn "usage: bundle exec rake 'new_cop[Department/Name]'"
9495
exit!
9596
end
9697

97-
generator = RuboCop::Cop::Generator.new(cop_name)
98+
generator = RuboCop::RSpecRails::Cop::Generator.new(cop_name)
9899
generator.write_source
99100
generator.write_spec
100101
generator.inject_require(
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
module RuboCop
4+
module RSpecRails
5+
module Cop
6+
# Source and spec generator for new cops
7+
#
8+
# This generator will take a cop name and generate a source file
9+
# and spec file when given a valid qualified cop name.
10+
# @api private
11+
class Generator < RuboCop::Cop::Generator
12+
def todo
13+
<<~TODO
14+
Do 4 steps:
15+
1. Modify the description of #{badge} in config/default.yml
16+
2. Implement your new cop in the generated file!
17+
3. Add an entry about new cop to CHANGELOG.md
18+
4. Commit your new cop with a message such as
19+
e.g. "Add new `#{badge}` cop"
20+
TODO
21+
end
22+
end
23+
end
24+
end
25+
end

0 commit comments

Comments
 (0)