Sha256: 7d226667673eab993fcd1d007c7b9f04e143e20e03b78737d4bad753c26ca054

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

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

    private

      def rails_fixture_file_wrapper
        resolved_fixture_path = (fixture_path || RSpec.configuration.fixture_path || '')
        RailsFixtureFileWrapper.fixture_path = File.join(resolved_fixture_path, '')
        RailsFixtureFileWrapper.instance
      end

      class RailsFixtureFileWrapper
        include ActionDispatch::TestProcess if defined?(ActionDispatch::TestProcess)

        class << self
          attr_reader :fixture_path

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

          # Override fixture_path set
          # to support Rails 3.0->3.1 using ActionController::TestCase class to resolve fixture_path
          # see https://apidock.com/rails/v3.0.0/ActionDispatch/TestProcess/fixture_file_upload
          def fixture_path=(value)
            if ActionController::TestCase.respond_to?(:fixture_path)
              ActionController::TestCase.fixture_path = value
            end
            @fixture_path = value
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-rails-3.7.2 lib/rspec/rails/fixture_file_upload_support.rb