1
1
require "spec_helper"
2
- require "rubocop "
2
+ require "standard "
3
3
require "cc/engine/file_list_resolver"
4
4
5
5
module CC ::Engine
6
6
describe FileListResolver do
7
7
include FilesystemHelpers
8
8
9
9
before { @code = Dir . mktmpdir }
10
- let ( :rubocop_config ) { RuboCop :: ConfigStore . new }
10
+ let ( :builds_config ) { :: Standard :: BuildsConfig . new . call ( [ ] ) }
11
11
12
12
it "uses default include path" do
13
13
Dir . chdir ( @code ) do
14
14
create_source_file ( "a.rb" , "def a; true; end" )
15
15
create_source_file ( "not_ruby.txt" , "some text" )
16
16
17
- resolver = FileListResolver . new ( root : @code , engine_config : { } , config_store : rubocop_config )
17
+ resolver = FileListResolver . new ( root : @code , engine_config : { } , builds_config : builds_config )
18
18
expect ( resolver . expanded_list ) . to eq [ Pathname . new ( "a.rb" ) . realpath . to_s ]
19
19
end
20
20
end
21
21
22
22
it "finds ruby scripts without extensions" do
23
23
Dir . chdir ( @code ) do
24
24
create_source_file ( "a.rb" , "def a; true; end" )
25
- create_source_file ( "bin /some_script" , "#!/usr/bin/env ruby" )
26
- create_source_file ( "bin /some_other_script" , "#!/usr/bin/env sh" )
25
+ create_source_file ( "scripts /some_script" , "#!/usr/bin/env ruby" )
26
+ create_source_file ( "scripts /some_other_script" , "#!/usr/bin/env sh" )
27
27
28
- resolver = FileListResolver . new ( root : @code , engine_config : { } , config_store : rubocop_config )
29
- expect ( resolver . expanded_list ) . to eq %w[ a.rb bin /some_script] . map { |fn | Pathname . new ( fn ) . realpath . to_s }
28
+ resolver = FileListResolver . new ( root : @code , engine_config : { } , builds_config : builds_config )
29
+ expect ( resolver . expanded_list ) . to eq %w[ a.rb scripts /some_script] . map { |fn | Pathname . new ( fn ) . realpath . to_s }
30
30
end
31
31
end
32
32
@@ -35,25 +35,35 @@ module CC::Engine
35
35
create_source_file ( "a.rb" , "def a; true; end" )
36
36
create_source_file ( "src/b.rb" , "def a; true; end" )
37
37
38
- resolver = FileListResolver . new ( root : @code , engine_config : { "include_paths" => %w[ src/ ] } , config_store : rubocop_config )
38
+ resolver = FileListResolver . new ( root : @code , engine_config : { "include_paths" => %w[ src/ ] } , builds_config : builds_config )
39
39
expect ( resolver . expanded_list ) . to eq [ Pathname . new ( "src/b.rb" ) . realpath . to_s ]
40
40
end
41
41
end
42
42
43
- it "respects rubocop excludes" do
43
+ it "respects default ignore list" do
44
+ Dir . chdir ( @code ) do
45
+ create_source_file ( "vendor/foo/a.rb" , "def a; true; end" )
46
+ create_source_file ( "bin/b.rb" , "def a; true; end" )
47
+ create_source_file ( "tmp/c.rb" , "def a; true; end" )
48
+ create_source_file ( "db/schema.rb" , "ActiveRecord::Schema.define(:version => #{ Time . current . to_i } ) do; end" )
49
+
50
+ resolver = FileListResolver . new ( root : @code , engine_config : { } , builds_config : builds_config )
51
+ expect ( resolver . expanded_list ) . to be_empty
52
+ end
53
+ end
54
+
55
+ it "respects ignore list in standard config" do
44
56
Dir . chdir ( @code ) do
45
57
create_source_file ( "Gemfile" , "source 'https://rubygems.org'" )
46
58
create_source_file ( "src/b.rb" , "def a; true; end" )
47
59
create_source_file ( "src/c.rb" , "def a; true; end" )
48
- create_source_file ( ".rubocop.yml" , <<~YML )
49
- AllCops:
50
- NewCops: enable
51
- Exclude:
52
- - src/c.rb
53
- - Gemfile
54
- YML
60
+ create_source_file ( ".standard.yml" , <<~YAML )
61
+ ignore:
62
+ - src/c.rb
63
+ - Gemfile
64
+ YAML
55
65
56
- resolver = FileListResolver . new ( root : @code , engine_config : { "include_paths" => %w[ Gemfile src/ ] } , config_store : rubocop_config )
66
+ resolver = FileListResolver . new ( root : @code , engine_config : { } , builds_config : builds_config )
57
67
expect ( resolver . expanded_list ) . to eq [ Pathname . new ( "src/b.rb" ) . realpath . to_s ]
58
68
end
59
69
end
@@ -62,7 +72,7 @@ module CC::Engine
62
72
Dir . chdir ( @code ) do
63
73
create_source_file ( "src/b.rb" , "def a; true; end" )
64
74
65
- resolver = FileListResolver . new ( root : @code , engine_config : { "include_paths" => %w[ src/ public/assets ] } , config_store : rubocop_config )
75
+ resolver = FileListResolver . new ( root : @code , engine_config : { "include_paths" => %w[ src/ public/assets ] } , builds_config : builds_config )
66
76
expect ( resolver . expanded_list ) . to eq [ Pathname . new ( "src/b.rb" ) . realpath . to_s ]
67
77
end
68
78
end
0 commit comments