Ruby version: 2.7.2
Rails version: 6.1.0
RSpec version: 3.10.1 (rspec-core) and 4.0.2 (rspec-rails)
Hello! I am trying to upgrade my app to Rails 6.1 from 6.0.3.4, and I'm encountering an error when using the fixture_file_upload
method. When I call this method, the following exception is raised:
NoMethodError:
undefined method `file_fixture_path' for RSpec::Rails::FixtureFileUploadSupport::RailsFixtureFileWrapper:Class
Did you mean? fixture_path
It seems that ActionPack
has changed the implementation of the fixture_file_upload
and expects there to be a file_fixture_path
method on the RailsFixtureFileWrapper
class.
I expect this method to upload the file without raising any exceptions.
You can see my example app with a failing test here: https://github.com/egiurleo/fixture-file-upload-test/blob/main/spec/fixture_file_upload_spec.rb
For the test, I have a pdf file in the spec/fixtures
folder. I am trying to call the fixture_file_upload
method with the name of that file, and the test raises the exception I described earlier.
file_fixture_path
in this context so any guidance would be appreciated.ActionPack
(lib/action_dispatch/testing/test_process.rb
).Thanks for reporting. We're actively working on rspec-rails
4.1, you can access it by pointing to a branch:
# Gemfile
gem 'rspec-rails', github: 'rspec/rspec-rails', branch: 'rails-6-1-dev'
The fix is included there.
Sorry for the inconvenience.
Please feel free to report back if it still doesn't work for you.
Thank you so much for letting me know!
As a temporary workaround for this, rather than fiddling with my Gemfile and making sure I had all the dependencies, I just defined my own fixture_file_upload
method after looking at the source code for that method:
def fixture_file_upload(path, mime_type)
Rack::Test::UploadedFile.new(Pathname.new(file_fixture_path).join(path), mime_type, false)
end
Most helpful comment
Thanks for reporting. We're actively working on
rspec-rails
4.1, you can access it by pointing to a branch:The fix is included there.
Sorry for the inconvenience.
Please feel free to report back if it still doesn't work for you.