-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix support for namespaced fixtures with rspec-rails 6.1.0 and rails 7.1 #2716
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
Conversation
7fa6d14
to
54a1e50
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.
Thank you!
I kindly appreciate if you find a way to prevent regression with some spec that won’t add a new doc example.
@@ -104,3 +104,23 @@ Feature: Transactional examples | |||
""" | |||
When I run `rspec spec/models/thing_spec.rb` | |||
Then the examples should all pass | |||
|
|||
Scenario: Run in transactions with namespaced fixture |
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.
Even though this may be a good measure against regressions, this also serves as public-facing documentation. And this scenario doesn’t bring value as such. Do you think it would be possible to cover this differently?
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.
Specs aren’t probably an option. Might be the example_app_generator or snippets (eg https://github.com/rspec/rspec-rails/blob/main/snippets/use_active_record_false.rb)?
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.
@pirj I removed the changes to the feature file for now. I'll see if I can come up with a way to test this otherwise, but I'm not familiar with the project setup so any help would be appreciated 🙂
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.
I'm happy to merge this but it needs a regression check of some sorts, it probably needs a generated spec in the example app...
I added the required regression check and have merged this in, thank you for your work. |
@JonRowe Thanks for figuring out the regression tests! I'm pretty sure I wouldn't have been able to figure out the solution you landed on 👍 |
Released in 6.1.1 |
This pull request fixes an issue with namespaced fixtures in Rails 7.1 and RSpec Rails 6.1 as described in #2715
The problem is related to this change in
fixture_support.rb
.The
fixtures
method is only looking at the keys of fixture sets, but I think it also needs to look at the values. The keys seem to represent the method name, and the values represent the fixture names.It works fine for not namespaced fixtures, but the values are different for namespaced ones:
Calling
access_fixture
with the method name raises the error described above, because the fixture cache is based on the fixture name (with/
in the values).This pull request changes the implementation to use both
method_name
andfixture_name
.