-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Require rails_helper before configuring RSpec #243
Conversation
23f00af
to
a965543
Compare
d2bebcc
to
616cc4a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good direction. I added some comments.
We will need integration tests in spec/integration/runners/queue/rspec_runner_spec.rb
. We want to cover case when the rails_helper.rb
file exists and it has RSpec before(:suite), after(:suite) hooks defined and only a spec file in 2nd batch of tests requires rails_helper
.
616cc4a
to
6d507bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work!
ec8e0e8
to
ede4590
Compare
ede4590
to
10de75b
Compare
Co-Authored-By: Artur Trzop <arturtrzop@gmail.com>
10de75b
to
80e389d
Compare
Story
https://trello.com/c/iyN1GKYS/320-bug-rspec-knapsackpro-700-fails-with-the-dotenv-gem
Related
#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.