KnapsackPro / knapsack_pro-ruby

Knapsack Pro gem splits tests across parallel CI nodes and makes sure that tests run in optimal time
https://knapsackpro.com
MIT License
132 stars 27 forks source link

Require rails_helper before configuring RSpec #243

Closed Pacyfik closed 7 months ago

Pacyfik commented 8 months ago

Story

https://trello.com/c/iyN1GKYS/320-bug-rspec-knapsackpro-700-fails-with-the-dotenv-gem

Related

https://github.com/KnapsackPro/knapsack_pro-ruby/issues/242

Description

Version 7.0.0 introduced some fundamental changes, namely fetching, loading and running batches of specs after executing suite hooks, so that such hooks are only ran once, not before every batch. As a result, if rails_helper is only required in spec files, which is the RSpec default, instead of e.g. in .rspec, then some before(:suite) hooks, e.g. defined by gems, are registered after suite hooks had already been executed by the test suite. In comparison, RSpec loads all the spec files before executing before(:suite) hooks.

Changes

This PR conditionally adds --require rails_helper to cli arguments of KnapsackPro::Runners::Queue::RSpecRunner so that the Rails app (and its gems) can be loaded before executing before(:suite) hooks. That way all the before(:suite) hooks are registered properly and can be executed.

Checklist reminder