Sha256: 6a7c08f304a3ab11be5930ca86e3d3b87f5030f850e31aa827b842bd44288445

Contents?: true

Size: 982 Bytes

Versions: 15

Compression:

Stored size: 982 Bytes

Contents

require 'spec_helper'

describe Rack do
  it 'correctly populates params from a Tempfile' do
    input = Tempfile.new 'rubbish'
    begin
      app = Class.new(Grape::API) do
        format :json
        post do
          { params_keys: params.keys }
        end
      end
      input.write({ test: '123' * 10_000 }.to_json)
      input.rewind
      options = {
        input: input,
        method: 'POST',
        'CONTENT_TYPE' => 'application/json'
      }
      env = Rack::MockRequest.env_for('/', options)

      unless RUBY_PLATFORM == 'java'
        major, minor, patch = Rack.release.split('.').map(&:to_i)
        patch ||= 0 # rack <= 1.5.2 does not specify patch version
        pending 'Rack 1.5.3 or 1.6.1 required' unless major >= 2 || (major >= 1 && ((minor == 5 && patch >= 3) || (minor >= 6)))
      end

      expect(JSON.parse(app.call(env)[2].body.first)['params_keys']).to match_array('test')
    ensure
      input.close
      input.unlink
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
grape-1.2.4 spec/grape/integration/rack_spec.rb
grape-1.2.3 spec/grape/integration/rack_spec.rb
grape-1.2.2 spec/grape/integration/rack_spec.rb
grape-1.2.1 spec/grape/integration/rack_spec.rb
grape-1.2.0 spec/grape/integration/rack_spec.rb
grape-1.1.0 spec/grape/integration/rack_spec.rb
grape-1.0.3 spec/grape/integration/rack_spec.rb
grape-1.0.2 spec/grape/integration/rack_spec.rb
grape-1.0.1 spec/grape/integration/rack_spec.rb
grape-1.0.0 spec/grape/integration/rack_spec.rb
grape-0.19.2 spec/grape/integration/rack_spec.rb
grape-0.19.1 spec/grape/integration/rack_spec.rb
grape-0.19.0 spec/grape/integration/rack_spec.rb
grape-0.18.0 spec/grape/integration/rack_spec.rb
grape-0.17.0 spec/grape/integration/rack_spec.rb