Skip to content

Commit a9df40a

Browse files
authored
Prioritize PARALLEL_RAILS_ENV over the standard (#1019)
* Prioritize PARALLEL_RAILS_ENV over RAILS_ENV * RSpec tests * Update CHANGELOG.md * Add doc in Readme.md * Add a reference to #776 in the changelog * Adapt the code based on @grosser's suggestion #1019 (review)
1 parent c9f15e8 commit a9df40a

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ only add here if you are working on a PR
88

99
### Added
1010

11+
- Rake tasks will prioritize the `PARALLEL_RAILS_ENV` value over the default `test` environment
12+
1113
### Fixed
1214

1315
## 5.3.1 - 2025-07-23

Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ TIPS
360360
- Debug errors that only happen with multiple files using `--verbose` and [cleanser](https://github.com/grosser/cleanser)
361361
- `export PARALLEL_TEST_PROCESSORS=13` to override default processor count
362362
- `export PARALLEL_TEST_MULTIPLY_PROCESSES=.5` to override default processor multiplier
363+
- `export PARALLEL_RAILS_ENV=environment_name` to override the default `test` environment
363364
- Shell alias: `alias prspec='parallel_rspec -m 2 --'`
364365
- [Spring] Add the [spring-commands-parallel-tests](https://github.com/DocSpring/spring-commands-parallel-tests) gem to your `Gemfile` to get `parallel_tests` working with Spring.
365366
- `--first-is-1` will make the first environment be `1`, so you can test while running your full suite.<br/>

lib/parallel_tests/tasks.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module ParallelTests
66
module Tasks
77
class << self
88
def rails_env
9-
'test'
9+
ENV['PARALLEL_RAILS_ENV'] || 'test'
1010
end
1111

1212
def load_lib

spec/parallel_tests/tasks_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
end
4343

4444
describe ".rails_env" do
45-
it "should be test" do
45+
it "should be test when nothing was set" do
4646
expect(ParallelTests::Tasks.rails_env).to eq("test")
4747
end
4848

49-
it "should disregard whatever was set" do
50-
ENV["RAILS_ENV"] = "foo"
51-
expect(ParallelTests::Tasks.rails_env).to eq("test")
49+
it "should prioritize the PARALLEL_RAILS_ENV value over the standard" do
50+
ENV["PARALLEL_RAILS_ENV"] = "bar"
51+
expect(ParallelTests::Tasks.rails_env).to eq("bar")
5252
end
5353
end
5454

0 commit comments

Comments
 (0)