-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Global before :all hooks with specified :type are not run with 2.14.0 #825
Comments
Trying to debug this, what happens if you put type: :request into your describe e.g.: describe "always failing", type: :request do
it "should fail" do
end
end |
Forgot to mention, that when nesting with context, then it seems to work as expected: # spec/requests/working_spec.rb
describe "working" do
context "yup, working" do
it "will fail, as expected because before all hook will raise" do
end
end
end Also, when removing # spec_helper.rb
before :all do
p self.class.metadata[:type]
end |
Yeah but there could be an ordering issue between |
It might be that the problem is in fact in one of the |
In case anyone else gets time to work on this before I do, the problem here seems to be that the metadata is not being set on the top level |
- In #970 we added `infer_spec_type_from_file_location!` but forgot to remove the code in `lib/rspec/rails/configuration.rb` that made it always infer - so the opt-in API was there but it was always enabled. Here I've made it truly opt-in. - The logic of `infer_spec_type_from_file_location!` also setup the helper module inclusion via explicit `:type` metadata but was only intended to setup the implicit mapping of spec file location to type. Here I've made the module inclusion via `:type` always work w/o an explicit config option needed to enable it. - We used to mutate the `:type` metadata on inclusion of the helper module, but this caused bugs such as #825. The problem is that rspec-core uses a raw hash for the metadata and doesn't re-apply filtering/inclusion logic when the metadata hash is mutated. Instead, we use a new explicit `define_derived_metadata` API. Fixes #825 and closes #829.
- In #970 we added `infer_spec_type_from_file_location!` but forgot to remove the code in `lib/rspec/rails/configuration.rb` that made it always infer - so the opt-in API was there but it was always enabled. Here I've made it truly opt-in. - The logic of `infer_spec_type_from_file_location!` also setup the helper module inclusion via explicit `:type` metadata but was only intended to setup the implicit mapping of spec file location to type. Here I've made the module inclusion via `:type` always work w/o an explicit config option needed to enable it. - We used to mutate the `:type` metadata on inclusion of the helper module, but this caused bugs such as #825. The problem is that rspec-core uses a raw hash for the metadata and doesn't re-apply filtering/inclusion logic when the metadata hash is mutated. Instead, we use a new explicit `define_derived_metadata` API. Fixes #825 and closes #829.
There's no need to anymore, and it created some surprising bugs (such as #825: `before(:all)` hooks would not properly be applied because they were registered before the modules were included).
Specifying global
before :all
hooks for specified:type
does not work withrspec-rails
version2.14.0
.Here's how to reproduce it:
before
hook with specific type intospec_helper
:request
spec:before :all
got not executed. The same happens when using differenttype
-controller
for example forspec/controllers/*_spec.rb
.It will work as inspected if using
before :each
instead or if downgrading to2.13.2
The text was updated successfully, but these errors were encountered: