rspec-big-infer 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78e761a682c1b7714b753d094a6fc3243828b036f5ae1f2d9e8d1b54dc0e1a08
4
- data.tar.gz: 5b94f872e3112278687d9af0274b04cc1ea752f8b7527655ba053e19504cd6fe
3
+ metadata.gz: 2d2ddea7669bd0be18eee681c20b8e6d5088a1a2002c53ab52af10c7f60935fa
4
+ data.tar.gz: ffa4f684720c88b363c5df24fecb54b7879650e2c44ed644028706e07d36abef
5
5
  SHA512:
6
- metadata.gz: 1aeda066d27c1538ca9a4ab999654cb34f22b87c69800db4e23b23c640dee232e3270e97969e5873b093b754bdab23310c2674670c674dca0f3fe2bdaae32daf
7
- data.tar.gz: bd4d76f00a3b41e896722539ce40eb0ce060dc6ff361e0b44295612d0240de6b7ab1fda46808cced918ab2a41b3d4404718bba76d3c6f779390a6e6ffe08e125
6
+ metadata.gz: 41423c065b1d9c97f6993f3f8f06b18cc5252f608e1f42278245b4ac1d6772c1b8524971cfb2ee21ded17e2382828e44703267c2d6dc6b0f100b13c826b07517
7
+ data.tar.gz: b038efc5501ac5007eb20858ec29e257b43ce04eaa41e4d28d19e1324daffef0e669ce38b9c35aef6ba07d5aebdac2c045e571c85fd26e46751db05f2ad7415d
data/Gemfile CHANGED
@@ -10,3 +10,7 @@ gem "rake", "~> 13.0"
10
10
  gem "minitest", "~> 5.0"
11
11
 
12
12
  gem "rubocop", "~> 1.7"
13
+
14
+ group :development do
15
+ gem "rspec", "~> 3"
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rspec-big-infer (0.7.0)
5
+ rspec-core (~> 3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.3)
11
+ diff-lcs (1.6.2)
12
+ json (2.12.2)
13
+ language_server-protocol (3.17.0.5)
14
+ lint_roller (1.1.0)
15
+ minitest (5.25.5)
16
+ parallel (1.27.0)
17
+ parser (3.3.8.0)
18
+ ast (~> 2.4.1)
19
+ racc
20
+ prism (1.4.0)
21
+ racc (1.8.1)
22
+ rainbow (3.1.1)
23
+ rake (13.3.0)
24
+ regexp_parser (2.10.0)
25
+ rspec (3.13.1)
26
+ rspec-core (~> 3.13.0)
27
+ rspec-expectations (~> 3.13.0)
28
+ rspec-mocks (~> 3.13.0)
29
+ rspec-core (3.13.4)
30
+ rspec-support (~> 3.13.0)
31
+ rspec-expectations (3.13.5)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.13.0)
34
+ rspec-mocks (3.13.5)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.13.0)
37
+ rspec-support (3.13.4)
38
+ rubocop (1.76.0)
39
+ json (~> 2.3)
40
+ language_server-protocol (~> 3.17.0.2)
41
+ lint_roller (~> 1.1.0)
42
+ parallel (~> 1.10)
43
+ parser (>= 3.3.0.2)
44
+ rainbow (>= 2.2.2, < 4.0)
45
+ regexp_parser (>= 2.9.3, < 3.0)
46
+ rubocop-ast (>= 1.45.0, < 2.0)
47
+ ruby-progressbar (~> 1.7)
48
+ unicode-display_width (>= 2.4.0, < 4.0)
49
+ rubocop-ast (1.45.0)
50
+ parser (>= 3.3.7.2)
51
+ prism (~> 1.4)
52
+ ruby-progressbar (1.13.0)
53
+ unicode-display_width (3.1.4)
54
+ unicode-emoji (~> 4.0, >= 4.0.4)
55
+ unicode-emoji (4.0.4)
56
+
57
+ PLATFORMS
58
+ ruby
59
+ x86_64-linux
60
+
61
+ DEPENDENCIES
62
+ minitest (~> 5.0)
63
+ rake (~> 13.0)
64
+ rspec (~> 3)
65
+ rspec-big-infer!
66
+ rubocop (~> 1.7)
67
+
68
+ BUNDLED WITH
69
+ 2.6.7
data/README.md CHANGED
@@ -16,3 +16,30 @@ bundle add rspec-big-infer
16
16
  * It works based on `described_class` and `const_source_location`
17
17
  2. (optional) Printout tests that will be run based on infer: `git diff --name-only --diff-filter=D origin/develop | bundle exec rspec-big-infer tmp/rspec_infer.json`
18
18
  3. Run tests with `bundle exec rspec $(git diff --name-only --diff-filter=D origin/develop | bundle exec rspec-big-infer tmp/rspec_infer.json)` to run tests based on the changes in the codebase.
19
+
20
+ ## Example runner file
21
+
22
+ `bin/run-infer-rspec`
23
+ ```bash
24
+ #!/bin/bash
25
+
26
+ set -e
27
+
28
+ if [ -z "$(git status --porcelain)" ]; then
29
+ echo "Working directory is clean. Proceeding with the infer script..."
30
+ else
31
+ echo "WARNING! Changes detected in the working directory. Infer script will not work correctly"
32
+ fi
33
+
34
+ echo "Updating git repository to get the latest changes from develop branch..."
35
+ git fetch origin develop > /dev/null 2>&1 || echo "Warning: Could not fetch from origin/develop. Continuing without update."
36
+
37
+ echo "Calculating relationships between files..."
38
+ bundle exec rspec --dry-run --format RSpec::Big::Infer::Formatter --out tmp/rspec_infer.json 2> /dev/null
39
+
40
+ echo "Parsing rspec_infer.json and suggesting tests to run..."
41
+ git diff --name-only origin/develop | bundle exec rspec-big-infer tmp/rspec_infer.json
42
+
43
+ echo "Running the tests..."
44
+ bundle exec rspec $(git diff --name-only origin/develop | bundle exec rspec-big-infer tmp/rspec_infer.json)
45
+ ```
@@ -0,0 +1,15 @@
1
+ # 0001 Add RSpec development dependency
2
+
3
+ Date: 2025-05-22
4
+
5
+ ## Status
6
+ Accepted
7
+
8
+ ## Context
9
+ RSpec is used for testing this gem, but it was not included in the Gemfile. Without it, running specs via Bundler fails.
10
+
11
+ ## Decision
12
+ Add `gem "rspec", "~> 3"` under the `development` group in the Gemfile. Running `bundle install` will lock the dependency.
13
+
14
+ ## Consequences
15
+ Developers can run `bundle exec rake spec` without globally installed RSpec. The gemspec remains unchanged.
@@ -0,0 +1,16 @@
1
+ # 1. Use `/usr/bin/env ruby` for shebang
2
+
3
+ Date: 2025-06-05
4
+
5
+ ## Status
6
+ Accepted
7
+
8
+ ## Context
9
+ The executable `exe/rspec-big-infer` previously used `#!/bin/env ruby` as its shebang.
10
+ Some systems do not provide `/bin/env`, but most provide `/usr/bin/env`.
11
+
12
+ ## Decision
13
+ Update the shebang line in `exe/rspec-big-infer` to `#!/usr/bin/env ruby` to increase portability.
14
+
15
+ ## Consequences
16
+ The script now uses the more common path for `env`, improving compatibility across environments.
data/exe/rspec-big-infer CHANGED
@@ -1,4 +1,4 @@
1
- #!/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "json"
@@ -9,12 +9,14 @@ if ARGV[0]
9
9
  all_rspec_examples = JSON.parse(File.read(path))["examples"]
10
10
  changed_files = $stdin.read.split("\n")
11
11
 
12
- all_rspec_examples.compact.uniq.each do |test|
13
- if changed_files.include?(test["described_class_defined_source_location"]) ||
14
- changed_files.include?(test["test_file_path"])
15
- puts test["test_file_path"]
16
- end
17
- end
12
+ puts(
13
+ all_rspec_examples.compact.map do |test|
14
+ if changed_files.include?(test["described_class_defined_source_location"]) ||
15
+ changed_files.include?(test["test_file_path"])
16
+ test["test_file_path"]
17
+ end
18
+ end.compact.uniq.join("\n")
19
+ )
18
20
 
19
21
  else
20
22
  warn "Usage: git diff --name-only origin/develop | rspec-big-infer <path to JSON test map file>"
@@ -12,7 +12,9 @@ module RSpec
12
12
  private
13
13
 
14
14
  def format_example(example)
15
- return unless example.example_group.described_class.is_a?(Class)
15
+ return if already_processed?(example.file_path)
16
+
17
+ already_processed!(example.file_path)
16
18
 
17
19
  {
18
20
  test_file_path: relative_path(example.file_path),
@@ -21,6 +23,8 @@ module RSpec
21
23
  end
22
24
 
23
25
  def source_location(klass)
26
+ return unless klass.is_a?(Class)
27
+
24
28
  relative_path(klass.const_source_location(klass.name).first)
25
29
  end
26
30
 
@@ -33,6 +37,19 @@ module RSpec
33
37
  path
34
38
  end
35
39
  end
40
+
41
+ def already_processed!(test_file_path)
42
+ # Prevents the formatter from processing the same file multiple times
43
+ @already_processed ||= Set.new
44
+ return if @already_processed.include?(test_file_path)
45
+
46
+ @already_processed.add(test_file_path)
47
+ end
48
+
49
+ def already_processed?(test_file_path)
50
+ @already_processed ||= Set.new
51
+ @already_processed.include?(test_file_path)
52
+ end
36
53
  end
37
54
  end
38
55
  end
@@ -3,7 +3,7 @@
3
3
  module RSpec
4
4
  module Big
5
5
  module Infer
6
- VERSION = "0.7.0"
6
+ VERSION = "0.8.0"
7
7
  end
8
8
  end
9
9
  end
@@ -8,7 +8,7 @@ module RSpec
8
8
  module Big
9
9
  module Infer
10
10
  class Error < StandardError; end
11
- # Your code goes here...
11
+ # Provides helper tools for inferring which specs to run.
12
12
  end
13
13
  end
14
14
  end
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = ["rspec-big-infer"]
28
28
  spec.require_paths = ["lib"]
29
29
  spec.add_dependency "rspec-core", "~> 3"
30
+ spec.add_development_dependency "rspec", "~> 3"
30
31
 
31
32
  # For more information and examples about making a new gem, checkout our
32
33
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-big-infer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patryk Ptasinski
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 2025-05-22 00:00:00.000000000 Z
11
+ date: 2025-06-26 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: rspec-core
@@ -23,6 +24,21 @@ dependencies:
23
24
  - - "~>"
24
25
  - !ruby/object:Gem::Version
25
26
  version: '3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3'
41
+ description:
26
42
  email:
27
43
  - patryk@ipepe.pl
28
44
  executables:
@@ -34,11 +50,14 @@ files:
34
50
  - ".gitignore"
35
51
  - ".rubocop.yml"
36
52
  - Gemfile
53
+ - Gemfile.lock
37
54
  - LICENSE
38
55
  - README.md
39
56
  - Rakefile
40
57
  - bin/console
41
58
  - bin/setup
59
+ - docs/adr/0001-add-rspec-development-dependency.md
60
+ - docs/adr/0001-use-env-ruby-for-shebang.md
42
61
  - exe/rspec-big-infer
43
62
  - lib/rspec/big/infer.rb
44
63
  - lib/rspec/big/infer/formatter.rb
@@ -53,6 +72,7 @@ metadata:
53
72
  homepage_uri: https://github.com/ipepe-oss/rspec-big-infer
54
73
  source_code_uri: https://github.com/ipepe-oss/rspec-big-infer
55
74
  changelog_uri: https://github.com/ipepe-oss/rspec-big-infer
75
+ post_install_message:
56
76
  rdoc_options: []
57
77
  require_paths:
58
78
  - lib
@@ -67,7 +87,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
87
  - !ruby/object:Gem::Version
68
88
  version: '0'
69
89
  requirements: []
70
- rubygems_version: 3.6.2
90
+ rubygems_version: 3.3.26
91
+ signing_key:
71
92
  specification_version: 4
72
93
  summary: Infer which RSpec test files to run based on currently changed files
73
94
  test_files: []