Skip to content

Commit d6256f4

Browse files
committed
[Fix #334] Fix minitest extension for the cop generator
Instead of reopening the Generator class in a file with the same name of the Generator class in the main rubocop gem, we are now defining a module that get included in the Generator class, defined in a different file path, specific for this minitest plugin. This allows rubocop plugins that want to use minitest to test their code to be able to generate their own cops using the minitest extension. Fixes #334.
1 parent e6c38ca commit d6256f4

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ end
1717

1818
require 'rubocop/rake_task'
1919
require 'rake/testtask'
20-
require_relative 'lib/rubocop/cop/generator'
20+
require 'rubocop/cop/minitest_generator'
2121

2222
# JRuby and Windows don't support fork, so we can't use minitest-queue.
2323
if RUBY_ENGINE == 'jruby' || RuboCop::Platform.windows?
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#334](https://github.com/rubocop/rubocop-minitest/issues/334): Fix minitest extension for the cop generator. ([@rafaelfranca][])

lib/rubocop/cop/generator.rb renamed to lib/rubocop/cop/minitest_generator.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# frozen_string_literal: true
22

3+
require 'rubocop/cop/generator'
4+
35
module RuboCop
46
module Cop
57
# Source and test generator for new cops
68
#
79
# This generator will take a cop name and generate a source file
810
# and test file when given a valid qualified cop name.
9-
class Generator
11+
module MinitestGenerator
1012
TEST_TEMPLATE = <<~TEST
1113
# frozen_string_literal: true
1214
@@ -48,3 +50,5 @@ def generated_test
4850
end
4951
end
5052
end
53+
54+
RuboCop::Cop::Generator.include(RuboCop::Cop::MinitestGenerator)

0 commit comments

Comments
 (0)