Skip to content

file_fixture_path fails with Rails 6.1 RC1 #2402

@ball-hayden

Description

@ball-hayden

What Ruby, Rails and RSpec versions are you using?

Ruby version: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
Rails version: Rails 6.1.0.rc1
RSpec version:

RSpec 3.10
  - rspec-core 3.10.0
  - rspec-expectations 3.10.0
  - rspec-mocks 3.10.0
  - rspec-rails 4.0.1
  - rspec-support 3.10.0

Observed behaviour

Use of fixture_file_upload results in the following error:

undefined method `file_fixture_path' for RSpec::Rails::FixtureFileUploadSupport::RailsFixtureFileWrapper:Class

Expected behaviour

When rspec-rails is used with previous Rails version, fixture_file_upload behaves as documented

Can you provide an example app?

Create a new Rails app for Rails 6.1.0.rc1 with RSpec:

gem install rails --pre
rails new rspecdemo
echo 'gem "rspec-rails", group: [:development, :test]' >> Gemfile
bundle install
rails generate rspec:install

Add the following test:

commit 65d60a8139f9856759818d95a32dcb9332589a11 (HEAD -> master)
Author: Hayden Ball <[email protected]>
Date:   Sat Nov 14 20:11:39 2020 +0000

    Add failing spec

diff --git a/spec/test_spec.rb b/spec/test_spec.rb
new file mode 100644
index 0000000..f922374
--- /dev/null
+++ b/spec/test_spec.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+RSpec.describe "test" do
+  it "fails" do
+    fixture_file_upload("test_file")
+  end
+end

Observe failure:

$ bundle exec rspec spec/test_spec.rb
F

Failures:

  1) test fails
     Failure/Error: fixture_file_upload("test_file")

     NoMethodError:
       undefined method `file_fixture_path' for RSpec::Rails::FixtureFileUploadSupport::RailsFixtureFileWrapper:Class
       Did you mean?  fixture_path
     # ./spec/test_spec.rb:7:in `block (2 levels) in <top (required)>'

Finished in 0.02347 seconds (files took 1.31 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/test_spec.rb:6 # test fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions