spectracer 1.3.0 → 1.4.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: fbfa5429478965d82098a285c1c6319df7ec0354dc01f5797acb4c7618412bf0
4
- data.tar.gz: 35fdb890ce1c67257a0cb41cb09a4bfd4f5479c428cc2f477484ba2afb90f919
3
+ metadata.gz: c01031e82f15d06eeef77717e0d31ec34a5bb73940323deb023c6bf3ec13eb13
4
+ data.tar.gz: 77395beec7e9113f050495f1ea036e8f019814514da08fb2a90654d25f0a6a10
5
5
  SHA512:
6
- metadata.gz: 973f20fc2e7168cb2af8bb865ab5740a590b189dadb8f94635dfe9a4f3c68b033f42b983c15799fe97e84078da40c7d482926d26e9a2faf230e9f2991f4c1db7
7
- data.tar.gz: ff5a83f41d30a6038ef597b559585897c11c30fbeb2e396a077984fcef7e04f26b9aad4e8718e8fbc4c516e38034df27b18646937041adda63db9f50f5afa9ef
6
+ metadata.gz: 30dd806f8a0428ea5890a4f39b2c315ae198c740b27fa33c629f1be9b6279d28b71227afceb349994bf6dfea58e05e5b65fa574623d63131e5b338e51ba9a13e
7
+ data.tar.gz: 0741cbb623678895406c7a233124654c6b54f8a96743e3bb8ab05de3e4447cafc1b8fa4affc3ea0ded7466f0aa3a2b749048e9ff96a52982f09e7e8472969669
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.4.0] - 2026-02-04
4
+
5
+ ### Changed
6
+
7
+ - Remove `./` prefix from traced paths for bktec/zzglob compatibility
8
+ - zzglob's `path.Clean()` normalizes `./spec/` to `spec/`, causing pattern mismatches
9
+ - Paths are now stored without the `./` prefix (e.g., `spec/models/user_spec.rb`)
10
+ - Output is compatible with both `bktec --test-file-pattern` and `rspec --pattern`
11
+
3
12
  ## [1.3.0] - 2026-02-02
4
13
 
5
14
  ### Added
@@ -34,8 +34,8 @@ module Spectracer
34
34
  end
35
35
 
36
36
  def normalize(file_path, repo_root:)
37
- relative = file_path.sub(/\A#{Regexp.escape(repo_root)}/, ".")
38
- relative.start_with?("./") ? relative : "./#{relative}"
37
+ relative = file_path.sub(%r{\A#{Regexp.escape(repo_root)}/?}, "")
38
+ relative.sub(%r{\A\./}, "")
39
39
  end
40
40
 
41
41
  def strip_dot_prefix(path)
@@ -16,12 +16,12 @@ module Spectracer
16
16
  changed_files.each do |file|
17
17
  matched_specs = []
18
18
 
19
- if file.end_with?("_spec.rb")
19
+ if file.end_with?("_spec.rb", "_test.rb")
20
20
  spec_set.add(file)
21
21
  matched_specs << file
22
22
  end
23
23
 
24
- file_key = file.start_with?("./") ? file : "./#{file}"
24
+ file_key = file.sub(%r{\A\./}, "")
25
25
  if (specs = inverse_deps[file_key])
26
26
  spec_set.merge(specs)
27
27
  matched_specs.concat(specs)
@@ -6,7 +6,8 @@ module Spectracer
6
6
  module IO
7
7
  class ConfigLoader
8
8
  FILE_PATH = ".spectracer.yml"
9
- DEFAULT_FILE_PATH = File.expand_path("../../spectracer.default.yml", __dir__)
9
+ DEFAULT_RSPEC_FILE_PATH = File.expand_path("../../spectracer.default.yml", __dir__)
10
+ DEFAULT_MINITEST_FILE_PATH = File.expand_path("../../spectracer.default.minitest.yml", __dir__)
10
11
 
11
12
  def initialize(logger: nil)
12
13
  @logger = logger
@@ -29,7 +30,17 @@ module Spectracer
29
30
  YAML.safe_load_file(FILE_PATH)
30
31
  else
31
32
  @logger&.debug("No configuration file found at #{FILE_PATH.inspect}. Using defaults.")
32
- YAML.safe_load_file(DEFAULT_FILE_PATH)
33
+ YAML.safe_load_file(default_file_path)
34
+ end
35
+ end
36
+
37
+ def default_file_path
38
+ if defined?(RSpec)
39
+ DEFAULT_RSPEC_FILE_PATH
40
+ elsif defined?(Minitest)
41
+ DEFAULT_MINITEST_FILE_PATH
42
+ else
43
+ DEFAULT_RSPEC_FILE_PATH
33
44
  end
34
45
  end
35
46
 
@@ -10,12 +10,39 @@ namespace :spectracer do
10
10
  exit 0
11
11
  end
12
12
 
13
+ framework = detect_test_framework
14
+ default_file_path = case framework
15
+ when :minitest
16
+ Spectracer::IO::ConfigLoader::DEFAULT_MINITEST_FILE_PATH
17
+ else
18
+ Spectracer::IO::ConfigLoader::DEFAULT_RSPEC_FILE_PATH
19
+ end
20
+
21
+ warn "Detected test framework: #{framework}"
13
22
  warn "Creating '#{config_path}' file."
14
23
 
15
- default_content = File.read(Spectracer::IO::ConfigLoader::DEFAULT_FILE_PATH)
24
+ default_content = File.read(default_file_path)
16
25
  File.write(config_path, default_content)
17
26
  end
18
27
 
28
+ def detect_test_framework
29
+ gemfile_path = File.join(Dir.pwd, "Gemfile")
30
+ return :rspec unless File.exist?(gemfile_path)
31
+
32
+ gemfile_content = File.read(gemfile_path)
33
+
34
+ has_rspec = gemfile_content.match?(/['"]rspec['"]|['"]rspec-rails['"]/)
35
+ has_minitest = gemfile_content.match?(/['"]minitest['"]/) || Dir.exist?("test")
36
+
37
+ if has_rspec
38
+ :rspec
39
+ elsif has_minitest
40
+ :minitest
41
+ else
42
+ :rspec
43
+ end
44
+ end
45
+
19
46
  desc "Collect spec dependencies from tracing artifacts"
20
47
  task :collect_dependencies do
21
48
  logger = Spectracer::Logger.new(
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spectracer
4
- VERSION = "1.3.0"
4
+ VERSION = "1.4.0"
5
5
  end
@@ -0,0 +1,16 @@
1
+ # This file was generated by the 'spectracer:install' Rake task.
2
+ # You can modify this file to customize the behavior of Spectracer.
3
+ # Test framework: Minitest
4
+ defaults:
5
+ all_specs_glob: "test/**/*_test.rb"
6
+ no_specs_glob: "{}"
7
+
8
+ # When no spec files are detected to run, Spectracer will run the specs defined in the 'on_empty_spec_set' key.
9
+ on_empty_spec_set: "{{no_specs_glob}}"
10
+
11
+ # If a file changes and it matches the glob, the corresponding pattern will be added to the list of spec files to run.
12
+ # These will take precedence over the 'on_empty_spec_set' key.
13
+ globs_matcher:
14
+ "Gemfile": "{{all_specs_glob}}"
15
+ "Gemfile.lock": "{{all_specs_glob}}"
16
+ "config/**": "{{all_specs_glob}}"
@@ -1,5 +1,6 @@
1
1
  # This file was generated by the 'spectracer:install' Rake task.
2
2
  # You can modify this file to customize the behavior of Spectracer.
3
+ # Test framework: RSpec
3
4
  defaults:
4
5
  all_specs_glob: "spec/**/*_spec.rb"
5
6
  no_specs_glob: "{}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spectracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitch Smith
@@ -36,6 +36,7 @@ files:
36
36
  - CHANGELOG.md
37
37
  - LICENSE.txt
38
38
  - README.md
39
+ - lib/spectracer.default.minitest.yml
39
40
  - lib/spectracer.default.yml
40
41
  - lib/spectracer.rb
41
42
  - lib/spectracer/core/glob_factorizer.rb