After upgrade to ruby 3 and rails 6.1 my tests break on the line
subject.avatar.attach(fixture_file_upload(Rails.root.join('spec', 'fixtures', 'images', 'avatar.jpg')))
with:
NoMethodError:
undefined method `file_fixture_path' for RSpec::Rails::FixtureFileUploadSupport::RailsFixtureFileWrapper:Class
Did you mean? fixture_path
the error stack points to
webmock-3.11.0/lib/webmock/rspec.rb:37
Any suggestions how to debug it?
Ran into the same error, but had to solve it differently as the post in a request spec doesn't accept the object returned by file_fixture.
Including include ActionDispatch::TestProcess::FixtureFile
in my request solved it for me.
RSpec.describe "Attachments", type: :request do
include Rack::Test::Methods
include ActionDispatch::TestProcess::FixtureFile
#...
expect {
file = fixture_file_upload("image.jpg", "image/jpeg", :binary)
post collection_work_attachments_path(collection, work), {attachment: {file: file, name: image_name, visibility: [:admin]}}
}.to change(Attachment, :count).by(1)
#...
end