I believe it depends on your Rails version, as Rails 5 has the file_fixture method.
Jon Rowe --------------------------- [email protected] jonrowe.co.uk On 24 April 2019 at 17:18, belgoros wrote: > I still can't figure out the right way to use fixture_file_upload method in a > request spec. > I looked through several issues: 1554 > (https://github.com/rspec/rspec-rails/issues/1554) and 1943 > (https://github.com/rspec/rspec-rails/pull/1943), but still no success. > > I put an image rails.jpeg in spec/fixtures folder. > Here is an example that fails: > > describe 'PATCH /shops/:shop_identifer' do > > let (:photo) {fixture_file_upload('files/rails.jpeg') } > > let (:valid_params) do > > ams_json ( > > Shop, > > category : shop.category, > > country : shop.country, > > identifier : shop.identifier, > > modified_by : shop.modified_by, > > name : 'new name', > > photo : photo, > > status : shop. > status > > ) > > end > > > > before { patch "/shops/#{shop.identifier}", params: valid_params, headers: > headers } > ... > > it 'creates a blob ' do > > expect (shop.photo.attached?).to be true > > end > > > It fails with: > RuntimeError: > > > files /rails.jpeg file does not exist > > What am I missing? > > RSpec version: 3.8.1 > Rails version: 5.2.0 > > > > > > > -- You received this message because you are subscribed to the Google Groups "rspec" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/dejalu-217-fc9682c2-791c-4ab6-a2c5-3b0ae64b6a52%40jonrowe.co.uk. For more options, visit https://groups.google.com/d/optout.
