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 44module StandardRunner
55 def self . included ( example_group )
66 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
710 example_group . around do |example |
811 Dir . mktmpdir do |code |
912 @code = code
@@ -21,10 +24,22 @@ def issues(output = @engine_output)
2124 end
2225
2326 def run_engine ( config = nil )
27+ @config = config
2428 io = StringIO . new
25- standard = CC ::Engine ::Standard . new ( @code , config , io )
29+ standard = CC ::Engine ::Standard . new ( @code , @ config, io )
2630 standard . run
2731
2832 @engine_output = io . string
2933 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
3045end
You can’t perform that action at this time.
0 commit comments