-
-
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
ActiveStorage::FixtureSet.blob incompatible with rspec #2637
Comments
We have a default |
Can you provide a reproduction snippet? (Preferably not an entire app, see our snippets for examples (https://github.com/rspec/rspec-rails/tree/main/snippets) |
I ran into the same problem today. Here's what I've figured out. And sorry I couldn't get a snippet to work. I tried but ran into ActiveStorage initialization issues. TL;DR.Rails expects More informationCalling This is the line that is blowing up.
The line errors because How Rails and minitest do itRails and minitest set up the class attribute in
rspec-rails
Fix?If I change that line to the code below, the error goes away.
I don't know if that is a good fix, or if I'm 100% on the write track, maybe I'm missing something. I could send a pull request. |
As for But the suggested fix would break non-active storage specs, wouldn't it? |
If I set a breakpoint on the line you mentioned, when it runs,
Yes, you're right. Good catch. I just tested it. It breaks regular file fixtures with the same error I was getting with blobs. But, you don't have to replace the line. This makes more sense. included do
self.file_fixture_path = RSpec.configuration.file_fixture_path
if defined? ActiveStorage::FixtureSet
ActiveStorage::FixtureSet.file_fixture_path = RSpec.configuration.file_fixture_path
end
end I don't think Rails < 7.0 has the Oh and a quick note. If anyone comes across this and wants an easy solution, I'm currently setting the |
Nice! A PR is welcome, @jaywhy. |
What Ruby, Rails and RSpec versions are you using?
Ruby version: 3.1.1
Rails version: 7.0.4
RSpec version:
rspec-core (3.12.0)
rspec-rails (5.0.3)
rspec-support (3.12.0)
Observed behaviour
When setting up file fixtures, and calling e.g.
fixtures/active_storage/blobs.yml
This will call
ActiveSupport::Testing::FileFixtures.file_fixture_path
, which is nil. This then fails.The rspec config should be set up correctly.
Expected behaviour
Expect rspec to find file_fixture_path
The text was updated successfully, but these errors were encountered: