Sha256: 0ac7ebc9d040de229cb8909d9580a209a27e8c0ef840daab206c9ca0cfd48692

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 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, release = Rack.release.split('.').map(&:to_i)
        pending 'Rack 1.5.3 or 1.6.1 required' unless major >= 1 && ((minor == 5 && release >= 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

2 entries across 2 versions & 1 rubygems

Version Path
grape-0.13.0 spec/grape/integration/rack_spec.rb
grape-0.12.0 spec/grape/integration/rack_spec.rb