rspec-turbo 0.1.3 → 0.1.5

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: 455e548802384d8f96139d09af290e9d76dcd5f7d3739669a77dfcb2ad55d2bd
4
- data.tar.gz: 916b2fade601b8cae5f6b46248b91ce6d4820ebe330f9dec7523657db52b0a99
3
+ metadata.gz: 117edefa9bc6a59aacec81c4dd980e163491245fad030d8468062a40dd23625b
4
+ data.tar.gz: c7aa89a42fb179f1ff476deaa54512c162c647272ca84f82e982846821ebde85
5
5
  SHA512:
6
- metadata.gz: 1459826357e5e9ac091511916c1c1c71af7d9af6687c660001e4e28f3ca18dbf7d259b943f9423be5a95e096c9be4395f2caaa04125b431c03a2fb141ae5595f
7
- data.tar.gz: 05be1a74d923db34f516992994a8388c9311c55b2e0bc6897bbe57325a502fcfb8fd8e2b2f775031c1040809ca1d8bb25641c7b55cba8ad97c40521f5fe58cc5
6
+ metadata.gz: cd78bea6709d2cd4b8f3270834ba60571372d822614326bd4525d4be5c5556e0c27cca8306dd5668731c3fecffc4c5045e547aa9b5ae172961004a1847008e06
7
+ data.tar.gz: e9c097f3d8d33ec7b0c9c36abb5bd7902c0c09a2c12bb718c71359c98e55d9dcfc7d2b5790325cf8afc2d8314f6b4b8d80721e2eae0bd16653078bbf08da6580
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.5] - 2026-09-29
4
+
5
+ ### Fixed
6
+ - Examples defined in `shared_examples` are now counted for the spec file that
7
+ includes them. The dry-run keyed examples by `file_path`, which RSpec sets to
8
+ the shared file, so those examples were missing from the file weights and
9
+ from the report total. The file now comes from the example id.
10
+
11
+ ## [0.1.4] - 2026-09-29
12
+
13
+ ### Fixed
14
+ - Dry-run no longer falls back to equal-weight distribution when the app prints
15
+ to stdout during the run (e.g. SimpleCov's "Coverage report generated…"
16
+ summary, emitted even with `COVERAGE=0` by apps that start it
17
+ unconditionally). The JSON formatter now writes to its own file
18
+ (`--out tmp/rspec-turbo/dry_run.json`), so stdout noise can't corrupt it.
19
+
3
20
  ## [0.1.3] - 2026-06-12
4
21
 
5
22
  ### Fixed
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "fileutils"
3
4
  require "json"
4
5
 
5
6
  module RSpecTurbo
@@ -41,13 +42,10 @@ module RSpecTurbo
41
42
  return empty_result if @files.empty?
42
43
 
43
44
  t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
44
- raw = capture_dry_run
45
+ capture_dry_run
45
46
  @dry_run_elapsed = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t0).round
46
47
 
47
- json_start = raw.index("{")
48
- raise "No JSON in dry-run output" unless json_start
49
-
50
- parse_examples(JSON.parse(raw[json_start..]))
48
+ parse_examples(read_dry_run_json)
51
49
  rescue => e
52
50
  warn " ⚠ dry-run failed (#{e.message}) — using equal-weight distribution"
53
51
  log_dry_run_error
@@ -55,24 +53,38 @@ module RSpecTurbo
55
53
  empty_result
56
54
  end
57
55
 
56
+ # The JSON goes to its own file (`--out`), never stdout: apps that start
57
+ # SimpleCov unconditionally print their coverage summary to stdout right
58
+ # after the formatter, which would make the JSON unparseable.
58
59
  def capture_dry_run
60
+ FileUtils.mkdir_p(Config.log_dir)
61
+ FileUtils.rm_f(Config.dry_run_json)
62
+
59
63
  File.open(Config.dry_run_log, "w") do |err_file|
60
64
  IO.popen(
61
- # COVERAGE=0 keeps SimpleCov from contaminating the JSON on stdout.
62
65
  [{"RAILS_ENV" => "test", "COVERAGE" => "0", "TEST_ENV_NUMBER" => "1"},
63
- "bundle", "exec", "rspec", "--dry-run", "--format", "json",
66
+ "bundle", "exec", "rspec", "--dry-run", "--format", "json", "--out", Config.dry_run_json,
64
67
  *@rspec_options, *@files.map { |f| "spec/#{f}" }],
65
68
  err: err_file, &:read
66
69
  )
67
70
  end
68
71
  end
69
72
 
73
+ def read_dry_run_json
74
+ raw = File.exist?(Config.dry_run_json) ? File.read(Config.dry_run_json) : ""
75
+ raise "No JSON in dry-run output" if raw.strip.empty?
76
+
77
+ JSON.parse(raw)
78
+ end
79
+
70
80
  def parse_examples(parsed)
71
81
  counts = Hash.new(0)
72
82
  ids = Hash.new { |hash, key| hash[key] = [] }
73
83
 
84
+ # Key by the file in the example id, not `file_path`: examples from
85
+ # shared_examples report the shared file as their `file_path`.
74
86
  parsed["examples"].each do |example|
75
- file = example["file_path"].delete_prefix("./spec/")
87
+ file = example["id"].sub(/\[[\d:]+\]\z/, "").delete_prefix("./spec/")
76
88
  counts[file] += 1
77
89
  ids[file] << example["id"]
78
90
  end
@@ -58,6 +58,8 @@ module RSpecTurbo
58
58
 
59
59
  def dry_run_log = File.join(log_dir, "dry_run_stderr.log")
60
60
 
61
+ def dry_run_json = File.join(log_dir, "dry_run.json")
62
+
61
63
  def coverage_merge_log = File.join(log_dir, "coverage_merge.log")
62
64
  end
63
65
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSpecTurbo
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-turbo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - thadeu
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-06-12 00:00:00.000000000 Z
10
+ date: 2026-09-30 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rspec-core