Sha256: 9c7dfdb3dd77d1a932d2bdcf9377b92fe51701da024b6481d45fd923fbbb04cd

Contents?: true

Size: 966 Bytes

Versions: 4

Compression:

Stored size: 966 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 >= 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

4 entries across 4 versions & 1 rubygems

Version Path
grape-0.16.2 spec/grape/integration/rack_spec.rb
grape-0.16.1 spec/grape/integration/rack_spec.rb
grape-0.15.0 spec/grape/integration/rack_spec.rb
grape-0.14.0 spec/grape/integration/rack_spec.rb