diff --git a/CHANGELOG.md b/CHANGELOG.md index 55925dab..45e84774 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ only add here if you are working on a PR ### Added +- Rake tasks will prioritize the `PARALLEL_RAILS_ENV` value over the default `test` environment + ### Fixed ## 5.3.1 - 2025-07-23 diff --git a/Readme.md b/Readme.md index 0d529edc..e43f62b2 100644 --- a/Readme.md +++ b/Readme.md @@ -360,6 +360,7 @@ TIPS - Debug errors that only happen with multiple files using `--verbose` and [cleanser](https://github.com/grosser/cleanser) - `export PARALLEL_TEST_PROCESSORS=13` to override default processor count - `export PARALLEL_TEST_MULTIPLY_PROCESSES=.5` to override default processor multiplier + - `export PARALLEL_RAILS_ENV=environment_name` to override the default `test` environment - Shell alias: `alias prspec='parallel_rspec -m 2 --'` - [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. - `--first-is-1` will make the first environment be `1`, so you can test while running your full suite.
diff --git a/lib/parallel_tests/tasks.rb b/lib/parallel_tests/tasks.rb index 17f3044a..63af70cc 100644 --- a/lib/parallel_tests/tasks.rb +++ b/lib/parallel_tests/tasks.rb @@ -6,7 +6,7 @@ module ParallelTests module Tasks class << self def rails_env - 'test' + ENV['PARALLEL_RAILS_ENV'] || 'test' end def load_lib diff --git a/spec/parallel_tests/tasks_spec.rb b/spec/parallel_tests/tasks_spec.rb index ff2fa046..a2dd3721 100644 --- a/spec/parallel_tests/tasks_spec.rb +++ b/spec/parallel_tests/tasks_spec.rb @@ -42,13 +42,13 @@ end describe ".rails_env" do - it "should be test" do + it "should be test when nothing was set" do expect(ParallelTests::Tasks.rails_env).to eq("test") end - it "should disregard whatever was set" do - ENV["RAILS_ENV"] = "foo" - expect(ParallelTests::Tasks.rails_env).to eq("test") + it "should prioritize the PARALLEL_RAILS_ENV value over the standard" do + ENV["PARALLEL_RAILS_ENV"] = "bar" + expect(ParallelTests::Tasks.rails_env).to eq("bar") end end