test_file_finder 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2816a3e4c0dfb810b9c4e8f743034d881fd4357e91c71d24f8d8053d10e1b267
4
- data.tar.gz: a76cdf4a161e97ed0d77b58caf18379411bc7f2e314dbd4871f4352ad31ae632
3
+ metadata.gz: 6270de89006e6f674e716156d8a92063126b235496cc7d149cadb09fe9bd6481
4
+ data.tar.gz: e8cfa86f850151e53e771a141e2fd2f34a77439d2347b6202c322825d1e2ce46
5
5
  SHA512:
6
- metadata.gz: 240c2558e97a7ff6260648f31288dcfe7df8801672a01b8dc0ec2077d2000fdf4a7437c7cc26256a621beca0ceec6d057f7e20829241a2cf97aa80a4ca542c07
7
- data.tar.gz: 86de0c8934ebf2f54e1ba9dd33c25c542d691ccc7d148abede0c7d0d17c240b37059f6db41696b98da99d475fc1972e0beb95f98a38810f7457b680e601b52aa
6
+ metadata.gz: 5ef8a72686e8360cc926c7b6d286e1b5769b4bdfedc5662d76d80e5527e15f3775af6138b484aa66075796c5b05145b16ef3ea6288e329f069a4b525e58293c0
7
+ data.tar.gz: cb524babc76288de16f90824e34e1da0d4a1e2ac20e833827aeb8201c9ec31104ea2a6e098dd6a5864c3f8f1e62d92cfe5049dd10028a7a5d12f75d373d070dc
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
+ .tool-versions
data/.gitlab-ci.yml CHANGED
@@ -1,19 +1,34 @@
1
- image: ruby:2.7.2
2
-
1
+ ---
3
2
  stages:
4
3
  - test
5
4
  - deploy
6
5
 
7
- rspec:
8
- script: bundle; bundle exec rspec
9
- rules:
10
- - if: $CI
6
+ variables:
7
+ BUNDLE_FROZEN: "true"
11
8
 
12
- check-executable:
13
- script: bundle; bundle exec rspec feature
14
- rules:
15
- - if: $CI
9
+ rspec:
10
+ stage: test
11
+ image: "ruby:$RUBY_VERSION"
12
+ cache:
13
+ paths:
14
+ - vendor/ruby
15
+ before_script:
16
+ - ruby -v # Print out ruby version for debugging
17
+ - gem install bundler -v 2.4.13
18
+ - bundle config set --local path "vendor/ruby/$RUBY_VERSION"
19
+ - bundle install
20
+ script:
21
+ - bundle exec rspec
22
+ - bundle exec rspec feature
23
+ parallel:
24
+ matrix:
25
+ - RUBY_VERSION:
26
+ - "2.7"
27
+ - "3.0"
28
+ - "3.1"
29
+ - "3.2"
16
30
 
17
31
  include:
32
+ - template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
18
33
  - project: 'gitlab-org/quality/pipeline-common'
19
34
  file: '/ci/gem-release.yml'
data/Gemfile.lock CHANGED
@@ -1,50 +1,42 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- test_file_finder (0.1.4)
5
- faraday (~> 1.0)
4
+ test_file_finder (0.2.0)
5
+ faraday (>= 2.0.1, >= 1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- addressable (2.7.0)
11
- public_suffix (>= 2.0.2, < 5.0)
10
+ addressable (2.8.4)
11
+ public_suffix (>= 2.0.2, < 6.0)
12
12
  byebug (11.1.3)
13
- crack (0.4.4)
14
- diff-lcs (1.3)
15
- faraday (1.4.2)
16
- faraday-em_http (~> 1.0)
17
- faraday-em_synchrony (~> 1.0)
18
- faraday-excon (~> 1.1)
19
- faraday-net_http (~> 1.0)
20
- faraday-net_http_persistent (~> 1.1)
21
- multipart-post (>= 1.2, < 3)
13
+ crack (0.4.5)
14
+ rexml
15
+ diff-lcs (1.5.0)
16
+ faraday (2.7.10)
17
+ faraday-net_http (>= 2.0, < 3.1)
22
18
  ruby2_keywords (>= 0.0.4)
23
- faraday-em_http (1.0.0)
24
- faraday-em_synchrony (1.0.0)
25
- faraday-excon (1.1.0)
26
- faraday-net_http (1.0.1)
27
- faraday-net_http_persistent (1.1.0)
19
+ faraday-net_http (3.0.2)
28
20
  hashdiff (1.0.1)
29
- multipart-post (2.1.1)
30
- public_suffix (4.0.6)
21
+ public_suffix (5.0.1)
31
22
  rake (10.5.0)
32
- rspec (3.9.0)
33
- rspec-core (~> 3.9.0)
34
- rspec-expectations (~> 3.9.0)
35
- rspec-mocks (~> 3.9.0)
36
- rspec-core (3.9.2)
37
- rspec-support (~> 3.9.3)
38
- rspec-expectations (3.9.2)
23
+ rexml (3.2.5)
24
+ rspec (3.12.0)
25
+ rspec-core (~> 3.12.0)
26
+ rspec-expectations (~> 3.12.0)
27
+ rspec-mocks (~> 3.12.0)
28
+ rspec-core (3.12.2)
29
+ rspec-support (~> 3.12.0)
30
+ rspec-expectations (3.12.3)
39
31
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.9.0)
41
- rspec-mocks (3.9.1)
32
+ rspec-support (~> 3.12.0)
33
+ rspec-mocks (3.12.5)
42
34
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.9.0)
44
- rspec-support (3.9.3)
45
- ruby2_keywords (0.0.4)
46
- webmock (3.12.1)
47
- addressable (>= 2.3.6)
35
+ rspec-support (~> 3.12.0)
36
+ rspec-support (3.12.0)
37
+ ruby2_keywords (0.0.5)
38
+ webmock (3.18.1)
39
+ addressable (>= 2.8.0)
48
40
  crack (>= 0.3.2)
49
41
  hashdiff (>= 0.4.0, < 2.0.0)
50
42
 
@@ -57,7 +49,7 @@ DEPENDENCIES
57
49
  rake (~> 10.0)
58
50
  rspec (~> 3.0)
59
51
  test_file_finder!
60
- webmock (~> 3.12)
52
+ webmock (~> 3.18)
61
53
 
62
54
  BUNDLED WITH
63
- 2.1.4
55
+ 2.4.13
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TestFileFinder
2
2
 
3
- A Ruby gem for deteting test files associated with input files.
3
+ A Ruby gem for detecting test files associated with input files.
4
4
 
5
5
  ## Installation
6
6
 
@@ -46,21 +46,25 @@ $ rspec $(tff $(git diff --name-only master..head))
46
46
 
47
47
  ##### `-f mapping`
48
48
 
49
- `TestFileFinder` can be used with an optional YAML mapping file to specify the mapping from a source file to a test file.
49
+ `TestFileFinder` can be used with an optional YAML mapping file to specify the mapping from a `source` file to a `test` file. Both, `source` and `test` can be lists to map multiple files.
50
50
 
51
51
  The mapping file is a yaml file containing to entries to match file patterns to its test files. The patterns may include capturing groups to be used to identify the test file. To refer to a captured value in the test file, use the `%s` placeholder. For example:
52
52
 
53
53
  ```yaml
54
54
  mapping:
55
55
  # maps `app/file.rb` to `spec/file_spec.rb`
56
- - source: app/(.+)\.rb
57
- test: spec/%s_spec.rb
58
- # maps `db/schema.rb` to `spec/db/schema_spec.rb`
59
- - source: db/schema.rb
56
+ - source: 'app/(.+)\.rb'
57
+ test: 'spec/%s_spec.rb'
58
+ # maps `db/schema.rb` and `db/migrate/*` to `spec/db/schema_spec.rb`
59
+ - source:
60
+ - 'db/schema.rb'
61
+ - 'db/migrate/(.+)'
60
62
  test: spec/db/schema_spec.rb
61
- # maps `ee/app/models/ee/user.rb` to `ee/spec/models/user_spec.rb`
63
+ # maps `ee/app/models/ee/user.rb` to `ee/spec/models/user_spec.rb` and `spec/models/user_spec.rb`
62
64
  - source: ee/app/(.*/)ee/(.+)\.rb
63
- test: ee/spec/%s%s_spec.rb
65
+ test:
66
+ - 'spec/%s%s_spec.rb'
67
+ - 'ee/spec/%s%s_spec.rb'
64
68
  ```
65
69
 
66
70
  Command line example:
@@ -12,16 +12,53 @@ RSpec.describe 'tff exe' do
12
12
  let(:files) { 'app/models/test_file_finder_gem_executable_widget.rb' }
13
13
 
14
14
  it 'prints matching test files using default rails mapping' do
15
- expect(subject).to eq("spec/models/test_file_finder_gem_executable_widget_spec.rb\n")
15
+ expect(subject).to eq <<~OUTPUT
16
+ spec/models/test_file_finder_gem_executable_widget_spec.rb
17
+ OUTPUT
16
18
  end
17
19
  end
18
20
 
19
21
  context 'with a yaml mapping' do
20
22
  let(:options) { '-f mapping.yml' }
21
- let(:files) { 'db/schema.rb' }
22
23
 
23
- it 'prints matching test files using given yaml mapping' do
24
- expect(subject).to eq("spec/db/schema_spec.rb\n")
24
+ context 'with multiple sources' do
25
+ ['db/schema.rb', 'db/migrate/001_init.rb'].each do |file|
26
+ context "for file #{file}" do
27
+ let(:files) { file }
28
+
29
+ it 'prints matching test files using given yaml mapping' do
30
+ expect(subject).to eq <<~OUTPUT
31
+ spec/db/schema_spec.rb
32
+ OUTPUT
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ context 'with multiple tests' do
39
+ let(:files) { 'spec/models/project_spec.rb' }
40
+
41
+ it 'prints matching test files using given yaml mapping' do
42
+ expect(subject).to eq <<~OUTPUT
43
+ spec/models/project_spec.rb
44
+ spec/smoke_spec.rb
45
+ OUTPUT
46
+ end
47
+ end
48
+
49
+ context 'with multiple sources and tests' do
50
+ ['views/main.html.haml', 'assets/application.css'].each do |file|
51
+ context "for file #{file}" do
52
+ let(:files) { file }
53
+
54
+ it 'prints matching test files using given yaml mapping' do
55
+ expect(subject).to eq <<~OUTPUT
56
+ spec/views/main_spec.rb
57
+ features/smoke.feature
58
+ OUTPUT
59
+ end
60
+ end
61
+ end
25
62
  end
26
63
  end
27
64
 
@@ -30,7 +67,11 @@ RSpec.describe 'tff exe' do
30
67
  let(:files) { 'db/schema.rb app/models/project.rb ' }
31
68
 
32
69
  it 'prints matching test files using both yaml and json mappings' do
33
- expect(subject.split("\n")).to match_array(%w[spec/db/schema_spec.rb spec/models/project_spec.rb spec/controllers/projects_controller_spec.rb])
70
+ expect(subject).to eq <<~OUTPUT
71
+ spec/models/project_spec.rb
72
+ spec/controllers/projects_controller_spec.rb
73
+ spec/db/schema_spec.rb
74
+ OUTPUT
34
75
  end
35
76
  end
36
77
 
@@ -39,11 +80,10 @@ RSpec.describe 'tff exe' do
39
80
  let(:files) { 'app/models/test_file_finder_gem_executable_widget.rb app/models/project.rb' }
40
81
 
41
82
  it 'prints matching test files using json mapping' do
42
- expect(subject.split("\n")).to match_array(%w[spec/models/project_spec.rb spec/controllers/projects_controller_spec.rb])
43
- end
44
-
45
- it 'does not match test file using rails mapping' do
46
- expect(subject.split("\n")).not_to include('spec/models/test_file_finder_gem_executable_widget_spec.rb')
83
+ expect(subject).to eq <<~OUTPUT
84
+ spec/models/project_spec.rb
85
+ spec/controllers/projects_controller_spec.rb
86
+ OUTPUT
47
87
  end
48
88
  end
49
89
  end
@@ -0,0 +1 @@
1
+ features tests
data/fixtures/mapping.yml CHANGED
@@ -1,9 +1,19 @@
1
1
  mapping:
2
- - source: app/(.+)\.rb
3
- test: spec/%s_spec.rb
4
- - source: lib/(.+)\.rb
5
- test: spec/lib/%s_spec.rb
6
- - source: db/schema.rb
7
- test: spec/db/schema_spec.rb
8
- - source: spec/(.+)_spec.rb
9
- test: spec/%s_spec.rb
2
+ - source: 'app/(.+)\.rb'
3
+ test: 'spec/%s_spec.rb'
4
+ - source: 'lib/(.+)\.rb'
5
+ test: 'spec/lib/%s_spec.rb'
6
+ - source:
7
+ - 'db/schema\.rb'
8
+ - 'db/migrate/(.+)\.rb'
9
+ test: 'spec/db/schema_spec.rb'
10
+ - source: 'spec/(.+)_spec.rb'
11
+ test:
12
+ - 'spec/%s_spec.rb'
13
+ - 'spec/smoke_spec.rb'
14
+ - source:
15
+ - 'views/.+\.html\.haml'
16
+ - 'assets/.+'
17
+ test:
18
+ - 'spec/views/main_spec.rb'
19
+ - 'features/smoke.feature'
@@ -0,0 +1 @@
1
+ smoke specs
@@ -0,0 +1 @@
1
+ main page specs
@@ -11,9 +11,11 @@ module TestFileFinder
11
11
 
12
12
  new do |mapping|
13
13
  maps.each do |map|
14
- source = map['source']
15
- test = map['test']
16
- mapping.relate(source, test)
14
+ Array(map['source']).each do |source|
15
+ Array(map['test']).each do |test|
16
+ mapping.relate(source, test)
17
+ end
18
+ end
17
19
  end
18
20
  end
19
21
  end
@@ -1,3 +1,3 @@
1
1
  module TestFileFinder
2
- VERSION = '0.1.4'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -33,11 +33,11 @@ Gem::Specification.new do |spec|
33
33
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
34
  spec.require_paths = ['lib']
35
35
 
36
- spec.add_runtime_dependency 'faraday', '~> 1.0'
36
+ spec.add_runtime_dependency 'faraday', ['>= 1.0', '>= 2.0.1']
37
37
 
38
38
  spec.add_development_dependency 'bundler', '~> 2.1'
39
39
  spec.add_development_dependency 'byebug'
40
40
  spec.add_development_dependency 'rake', '~> 10.0'
41
41
  spec.add_development_dependency 'rspec', '~> 3.0'
42
- spec.add_development_dependency 'webmock', '~> 3.12'
42
+ spec.add_development_dependency 'webmock', '~> 3.18'
43
43
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_file_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-14 00:00:00.000000000 Z
11
+ date: 2023-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.1
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +92,14 @@ dependencies:
86
92
  requirements:
87
93
  - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: '3.12'
95
+ version: '3.18'
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
100
  - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: '3.12'
102
+ version: '3.18'
97
103
  description: A command-line tool for guessing which spec files are relavant to a passed-in
98
104
  set of file paths.
99
105
  email:
@@ -116,12 +122,15 @@ files:
116
122
  - docs/release_process.md
117
123
  - exe/tff
118
124
  - feature/tff_exe_spec.rb
125
+ - fixtures/features/smoke.feature
119
126
  - fixtures/mapping.json
120
127
  - fixtures/mapping.yml
121
128
  - fixtures/spec/controllers/projects_controller_spec.rb
122
129
  - fixtures/spec/db/schema_spec.rb
123
130
  - fixtures/spec/models/project_spec.rb
124
131
  - fixtures/spec/models/test_file_finder_gem_executable_widget_spec.rb
132
+ - fixtures/spec/smoke_spec.rb
133
+ - fixtures/spec/views/main_spec.rb
125
134
  - fixtures/test_reports.json
126
135
  - lib/test_file_finder.rb
127
136
  - lib/test_file_finder/file_finder.rb