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
[x] You follow the architecture outlined below for RSpec in Queue Mode, which is a work in progress (feel free to propose changes):
Pure: lib/knapsack_pro/pure/queue/rspec_pure.rb contains pure functions that are unit tested.
Extension: lib/knapsack_pro/extensions/rspec_extension.rb encapsulates calls to RSpec internals and is integration and e2e tested.
Runner: lib/knapsack_pro/runners/queue/rspec_runner.rb invokes the pure code and the extension to produce side effects, which are integration and e2e tested.
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 somebefore(: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 executingbefore(:suite)
hooks.Changes
This PR conditionally adds
--require rails_helper
to cli arguments ofKnapsackPro::Runners::Queue::RSpecRunner
so that the Rails app (and its gems) can be loaded before executingbefore(:suite)
hooks. That way all thebefore(:suite)
hooks are registered properly and can be executed.Checklist reminder
lib/knapsack_pro/pure/queue/rspec_pure.rb
contains pure functions that are unit tested.lib/knapsack_pro/extensions/rspec_extension.rb
encapsulates calls to RSpec internals and is integration and e2e tested.lib/knapsack_pro/runners/queue/rspec_runner.rb
invokes the pure code and the extension to produce side effects, which are integration and e2e tested.