rspec-turbo 0.1.0 → 0.1.1

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: 6e75805ec30e8c00d22ab5db21967fb3ddfdeb0ab8f6edabad1047f6b8d3d895
4
- data.tar.gz: 3081d8c6f070131b441e4d00c368396b3e19cd48a2d79ed13b60a427a30c0033
3
+ metadata.gz: 64eb6a3af09b14eb69de00d8e41a4d47ac536b31bb9d3ec4c20e6b27e9f6b7fc
4
+ data.tar.gz: 5d062a69b01ac90ed24144dfebb7fa295519d6d09c3ec33278801823e01a0871
5
5
  SHA512:
6
- metadata.gz: 6f29717c3d1da16330b2019c4ff0cd7043f846ac0bc803716ddd86bdc338b382c41037c58ed68b9182a9fcad66ac0406d1ca994f76c3c3e2402e2533bff767b0
7
- data.tar.gz: e66d30be4d8d35ba555cd4da8b5d950f19bf88fcdbd5df1c9feff10c14aab6956dbbd244d83cb82e3783264cfaedb58fd2ea80d05a7536f94691e684d808f78e
6
+ metadata.gz: 0e6909eb453c1488a4f98332667b52f941d609ffd67f415ec81c4bbdd2696258ea2ba10f92470735a9b35925d549229eb4f45f8c8bc5a926f3caa87719e3962b
7
+ data.tar.gz: 5e3ad70b33cb0008ae5478c5179f86c0b0ab17466dcba4b8154b0802afecdcdc4f2bc86c847b48145c7e0dccdb27a5e29052debb8a961dc79c9099a3f27600b6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.1] - 2026-06-12
4
+
5
+ ### Added
6
+ - Three entry points: the `rspec-turbo` binary plus a `spec:turbo` Rake task
7
+ (reachable as both `rake spec:turbo` and `rails spec:turbo`), registered in
8
+ Rails apps through a Railtie.
9
+ - `coverage:merge` Rake task that collates per-worker SimpleCov result files
10
+ with `SimpleCov.collate`, emitting JSON on CI (`JSONFormatter`) and HTML
11
+ locally (`HTMLFormatter`); glob overridable via `RSPEC_TURBO_COVERAGE_GLOB`.
12
+
13
+ ### Fixed
14
+ - Workers and the dry-run now force `RAILS_ENV=test`, so they always target the
15
+ `*_test` databases `DbSetup` created — instead of relying on the project's
16
+ `rails_helper` to set it (which broke when launched via `rake`/`rails`, where
17
+ the parent process boots in development).
18
+
3
19
  ## [0.1.0] - 2026-06-12
4
20
 
5
21
  Initial extraction from the single-file `turbo.rb` runner into a gem.
@@ -13,12 +29,6 @@ Initial extraction from the single-file `turbo.rb` runner into a gem.
13
29
  enabled by default (disable with `RSPEC_TURBO_NO_PROFILE=1`) and safe outside
14
30
  Rails (times examples without counting SQL when ActiveSupport is absent).
15
31
  - JUnit XML output (`JUNIT_DIR`) and SimpleCov coverage merging (`COVERAGE=1`).
16
- - Three entry points: the `rspec-turbo` binary plus a `spec:turbo` Rake task
17
- (reachable as both `rake spec:turbo` and `rails spec:turbo`), registered in
18
- Rails apps through a Railtie.
19
- - `coverage:merge` Rake task that collates per-worker SimpleCov result files
20
- with `SimpleCov.collate`, emitting JSON on CI (`JSONFormatter`) and HTML
21
- locally (`HTMLFormatter`); glob overridable via `RSPEC_TURBO_COVERAGE_GLOB`.
22
32
 
23
33
  ### Fixed (versus the original script)
24
34
  - `DbSetup#show_log` referenced an undefined `w` variable on failure.
data/README.md CHANGED
@@ -14,7 +14,7 @@ dashboard, and a report that tells you exactly which folders are slowing you
14
14
  down.
15
15
 
16
16
  ```sh
17
- bundle add rspec-turbo --group test
17
+ bundle add rspec-turbo --group "development, test"
18
18
  bundle exec rspec-turbo
19
19
  ```
20
20
 
@@ -96,10 +96,10 @@ does one thing and tunes hard for it:
96
96
 
97
97
  ## Install
98
98
 
99
- Add it to the `:test` group of your Gemfile:
99
+ Add it to the `:development, :test` group of your Gemfile:
100
100
 
101
101
  ```ruby
102
- group :test do
102
+ group :development, :test do
103
103
  gem "rspec-turbo"
104
104
  end
105
105
  ```
@@ -108,6 +108,14 @@ end
108
108
  bundle install
109
109
  ```
110
110
 
111
+ > **Why `:development` too?** `rake` and `rails` commands run in the
112
+ > **development** environment by default, and Bundler only loads gems from the
113
+ > groups for the current environment. The `spec:turbo` / `coverage:merge` tasks
114
+ > are registered by a Railtie, so the gem must be loaded in `development` for
115
+ > `rake spec:turbo` / `rails spec:turbo` to exist. (The `bundle exec rspec-turbo`
116
+ > binary works from any group.) If you must keep it in `:test` only, run the
117
+ > tasks with `RAILS_ENV=test rails spec:turbo`.
118
+
111
119
  ## Usage
112
120
 
113
121
  ```sh
@@ -165,6 +173,32 @@ parse argv → DbSetup → FileDiscovery → BatchPlanner → Executor (pool)
165
173
  - **`simplecov` + `simplecov_json_formatter`** — only when `COVERAGE=1`
166
174
  (see [Coverage](#coverage-optional) below).
167
175
 
176
+ ### Parallel test databases (required)
177
+
178
+ Each worker runs with its own `TEST_ENV_NUMBER` (`1`, `2`, … up to the worker
179
+ count), so **every worker needs its own database** — otherwise they trample each
180
+ other. Make the test database name include `TEST_ENV_NUMBER` in
181
+ `config/database.yml`:
182
+
183
+ ```yaml
184
+ default: &default
185
+ adapter: postgresql
186
+ username: postgres
187
+ password: postgres
188
+
189
+ test:
190
+ <<: *default
191
+ database: myapp_test<%= ENV["TEST_ENV_NUMBER"] %>
192
+ ```
193
+
194
+ That resolves to `myapp_test1`, `myapp_test2`, … — one per worker. (Plain
195
+ `rails` commands, with no `TEST_ENV_NUMBER`, still use `myapp_test`.)
196
+
197
+ On the first run — or after a schema change — `rspec-turbo` creates and loads
198
+ all of them for you (`db:drop db:create db:schema:load db:seed`, one process per
199
+ slot, each with its own `TEST_ENV_NUMBER`). Later runs reuse them via the
200
+ schema-fingerprint cache; force a rebuild with `RSPEC_TURBO_FORCE_SETUP=1`.
201
+
168
202
  ## Environment variables
169
203
 
170
204
  | Variable | Default | Purpose |
@@ -274,6 +308,18 @@ speak RuboCop pick up the same rules; the canonical runner is `standardrb`.
274
308
  VS Code is pre-wired (`.vscode/settings.json`) to format on save with Standard
275
309
  via the Ruby LSP extension.
276
310
 
311
+ ## Troubleshooting
312
+
313
+ **`Unrecognized command "spec:turbo"` (`Rails::Command::UnrecognizedCommandError`)**
314
+ — the gem isn't loaded in the environment your command runs in. `rake`/`rails`
315
+ default to `development`, so move the gem to `group :development, :test` (see
316
+ [Install](#install)), or run `RAILS_ENV=test rails spec:turbo`. The
317
+ `bundle exec rspec-turbo` binary works regardless.
318
+
319
+ **Workers fail with "database … already exists" / connection clashes** — your
320
+ `config/database.yml` test database name isn't keyed by `TEST_ENV_NUMBER`. See
321
+ [Parallel test databases](#parallel-test-databases-required).
322
+
277
323
  ## Contributing
278
324
 
279
325
  Issues and pull requests are welcome. Run `bundle exec rake` before opening a
@@ -59,7 +59,7 @@ module RSpecTurbo
59
59
  File.open(Config.dry_run_log, "w") do |err_file|
60
60
  IO.popen(
61
61
  # COVERAGE=0 keeps SimpleCov from contaminating the JSON on stdout.
62
- [{"COVERAGE" => "0", "TEST_ENV_NUMBER" => "1"},
62
+ [{"RAILS_ENV" => "test", "COVERAGE" => "0", "TEST_ENV_NUMBER" => "1"},
63
63
  "bundle", "exec", "rspec", "--dry-run", "--format", "json",
64
64
  *@rspec_options, *@files.map { |f| "spec/#{f}" }],
65
65
  err: err_file, &:read
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSpecTurbo
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
@@ -40,6 +40,10 @@ module RSpecTurbo
40
40
 
41
41
  def self.env(slot, progress_file)
42
42
  {
43
+ # Force the test env so each worker connects to the *_test database
44
+ # DbSetup created, regardless of how the run was launched (a Rake/Rails
45
+ # task boots in development) or whether rails_helper sets it.
46
+ "RAILS_ENV" => "test",
43
47
  "TEST_ENV_NUMBER" => slot.to_s,
44
48
  "RSPEC_TURBO_PROGRESS_FILE" => progress_file,
45
49
  "COVERAGE" => ENV.fetch("COVERAGE", "0")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-turbo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - thadeu