test_file_finder 0.1.3 → 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: 395e0c675e1c2f892395a6706c5c0505f8bf53a28416b3d60f424613b6eaefd1
4
- data.tar.gz: 7d574bfda0a48abce40083fbaed0ab007e56ea051bcb1a056dfee1ef6dc2f052
3
+ metadata.gz: 6270de89006e6f674e716156d8a92063126b235496cc7d149cadb09fe9bd6481
4
+ data.tar.gz: e8cfa86f850151e53e771a141e2fd2f34a77439d2347b6202c322825d1e2ce46
5
5
  SHA512:
6
- metadata.gz: f15af7348a90fd1f3eb13b48359f57db714e7f4badce355544b35fe1a261fe7881555f6852415fdcdc4544f49341efb8ffac968675c36a355530a6d4c86cb20f
7
- data.tar.gz: 2e7592eb12c547e5346362cdef16e3356d75b2cee3156390e720c55a0c45428b4a8f004dfe4750c9429b89d6fef9ca2b2a134d27493c3d3e15104b049586d0e6
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,38 +1,42 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- test_file_finder (0.1.3)
5
- faraday (~> 1.0.1)
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.0.1)
16
- 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)
18
+ ruby2_keywords (>= 0.0.4)
19
+ faraday-net_http (3.0.2)
17
20
  hashdiff (1.0.1)
18
- multipart-post (2.1.1)
19
- public_suffix (4.0.6)
21
+ public_suffix (5.0.1)
20
22
  rake (10.5.0)
21
- rspec (3.9.0)
22
- rspec-core (~> 3.9.0)
23
- rspec-expectations (~> 3.9.0)
24
- rspec-mocks (~> 3.9.0)
25
- rspec-core (3.9.2)
26
- rspec-support (~> 3.9.3)
27
- 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)
28
31
  diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.9.0)
30
- rspec-mocks (3.9.1)
32
+ rspec-support (~> 3.12.0)
33
+ rspec-mocks (3.12.5)
31
34
  diff-lcs (>= 1.2.0, < 2.0)
32
- rspec-support (~> 3.9.0)
33
- rspec-support (3.9.3)
34
- webmock (3.12.1)
35
- 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)
36
40
  crack (>= 0.3.2)
37
41
  hashdiff (>= 0.4.0, < 2.0.0)
38
42
 
@@ -40,12 +44,12 @@ PLATFORMS
40
44
  ruby
41
45
 
42
46
  DEPENDENCIES
43
- bundler (~> 1.17)
47
+ bundler (~> 2.1)
44
48
  byebug
45
49
  rake (~> 10.0)
46
50
  rspec (~> 3.0)
47
51
  test_file_finder!
48
- webmock (~> 3.12)
52
+ webmock (~> 3.18)
49
53
 
50
54
  BUNDLED WITH
51
- 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.3'
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.1'
36
+ spec.add_runtime_dependency 'faraday', ['>= 1.0', '>= 2.0.1']
37
37
 
38
- spec.add_development_dependency 'bundler', '~> 1.17'
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,43 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_file_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
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-04-13 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
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ - - ">="
18
21
  - !ruby/object:Gem::Version
19
- version: 1.0.1
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
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - - ">="
25
31
  - !ruby/object:Gem::Version
26
- version: 1.0.1
32
+ version: 2.0.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '1.17'
39
+ version: '2.1'
34
40
  type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: '1.17'
46
+ version: '2.1'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: byebug
43
49
  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
@@ -156,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
165
  - !ruby/object:Gem::Version
157
166
  version: '0'
158
167
  requirements: []
159
- rubygems_version: 3.1.4
168
+ rubygems_version: 3.1.6
160
169
  signing_key:
161
170
  specification_version: 4
162
171
  summary: Guesses spec file paths given input file paths.