Sha256: c6e973b24fb96750a63f261ab55d6cf5003871b9600850522c3a1620d005f53c

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

module RSpec
  module Rails
    # @private
    module FixtureFileUploadSupport
      delegate :fixture_file_upload, to: :rails_fixture_file_wrapper

    private

      # In Rails 7.0 fixture file path needs to be relative to `file_fixture_path` instead, this change
      # was brought in with a deprecation warning on 6.1. In Rails 7.0 expect to rework this to remove
      # the old accessor.
      def rails_fixture_file_wrapper
        RailsFixtureFileWrapper.file_fixture_path = nil
        resolved_fixture_path =
          if respond_to?(:file_fixture_path) && !file_fixture_path.nil?
            file_fixture_path.to_s
          else
            (RSpec.configuration.fixture_path || '').to_s
          end
        RailsFixtureFileWrapper.file_fixture_path = File.join(resolved_fixture_path, '') unless resolved_fixture_path.strip.empty?
        RailsFixtureFileWrapper.instance
      end

      class RailsFixtureFileWrapper
        include ActionDispatch::TestProcess if defined?(ActionDispatch::TestProcess)
        include ActiveSupport::Testing::FileFixtures

        class << self
          attr_accessor :fixture_path

          # Get instance of wrapper
          def instance
            @instance ||= new
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/rspec-rails-6.0.4/lib/rspec/rails/fixture_file_upload_support.rb
rspec-rails-6.0.4 lib/rspec/rails/fixture_file_upload_support.rb
rspec-rails-6.0.3 lib/rspec/rails/fixture_file_upload_support.rb
rspec-rails-6.0.2 lib/rspec/rails/fixture_file_upload_support.rb
rspec-rails-6.0.1 lib/rspec/rails/fixture_file_upload_support.rb
rspec-rails-6.0.0 lib/rspec/rails/fixture_file_upload_support.rb