Sha256: 2ef7473770eaf68260368e49804e304d2f4b3017a45b0761c0e59ffc072b418d

Contents?: true

Size: 1.12 KB

Versions: 13

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

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)

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

  context 'when the app is mounted' do
    def app
      @main_app ||= Class.new(Grape::API) do
        get 'ping'
      end
    end

    let!(:base) do
      app_to_mount = app
      Class.new(Grape::API) do
        namespace 'namespace' do
          mount app_to_mount
        end
      end
    end

    it 'finds the app on the namespace' do
      get '/namespace/ping'
      expect(last_response.status).to eq 200
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
grape-1.6.2 spec/grape/integration/rack_spec.rb
grape-1.6.1 spec/grape/integration/rack_spec.rb
grape-1.6.0 spec/grape/integration/rack_spec.rb
grape-1.5.3 spec/grape/integration/rack_spec.rb
grape-1.5.2 spec/grape/integration/rack_spec.rb
grape-1.5.1 spec/grape/integration/rack_spec.rb
grape-1.5.0 spec/grape/integration/rack_spec.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.4.0/spec/grape/integration/rack_spec.rb
grape-1.4.0 spec/grape/integration/rack_spec.rb
grape-1.3.3 spec/grape/integration/rack_spec.rb
grape-1.3.2 spec/grape/integration/rack_spec.rb
grape-1.3.1 spec/grape/integration/rack_spec.rb
grape-1.3.0 spec/grape/integration/rack_spec.rb