File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 4
4
module StandardRunner
5
5
def self . included ( example_group )
6
6
example_group . include FilesystemHelpers
7
+ example_group . before do
8
+ allow_any_instance_of ( RuboCop ::AST ::ProcessedSource ) . to receive ( :registry ) . and_return ( registry )
9
+ end
7
10
example_group . around do |example |
8
11
Dir . mktmpdir do |code |
9
12
@code = code
@@ -21,10 +24,22 @@ def issues(output = @engine_output)
21
24
end
22
25
23
26
def run_engine ( config = nil )
27
+ @config = config
24
28
io = StringIO . new
25
- standard = CC ::Engine ::Standard . new ( @code , config , io )
29
+ standard = CC ::Engine ::Standard . new ( @code , @ config, io )
26
30
standard . run
27
31
28
32
@engine_output = io . string
29
33
end
34
+
35
+ def registry
36
+ # https://github.com/rubocop/rubocop/blob/master/lib/rubocop/rspec/cop_helper.rb
37
+ @registry ||= begin
38
+ keys = RuboCop ::Config . new ( @config || { } , "#{ Dir . pwd } /.rubocop.yml" ) . keys
39
+ cops = keys . map { |directive | RuboCop ::Cop ::Registry . global . find_cops_by_directive ( directive ) } . flatten
40
+ cops << cop_class if defined? ( cop_class ) && !cops . include? ( cop_class )
41
+ cops . compact!
42
+ RuboCop ::Cop ::Registry . new ( cops )
43
+ end
44
+ end
30
45
end
You can’t perform that action at this time.
0 commit comments