Sha256: e0eb6cd471a020d43a7f4a5727b67155cf78d8a3a18381fd6aa1325fc7f4aa46

Contents?: true

Size: 641 Bytes

Versions: 6

Compression:

Stored size: 641 Bytes

Contents

require 'spec_helper'

describe Grape::API::Helpers do
  module SharedParams
    extend Grape::API::Helpers

    params :pagination do
      optional :page, type: Integer
      optional :size, type: Integer
    end
  end

  subject do
    Class.new(Grape::API) do
      helpers SharedParams
      format :json

      params do
        use :pagination
      end
      get do
        declared(params, include_missing: true)
      end
    end
  end

  def app
    subject
  end

  it 'defines parameters' do
    get '/'
    expect(last_response.status).to eq 200
    expect(last_response.body).to eq({ page: nil, size: nil }.to_json)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
grape-0.13.0 spec/grape/api/shared_helpers_spec.rb
grape-0.12.0 spec/grape/api/shared_helpers_spec.rb
grape-0.11.0 spec/grape/api/shared_helpers_spec.rb
grape-0.10.1 spec/grape/api/shared_helpers_spec.rb
grape-0.10.0 spec/grape/api/helpers_spec.rb
grape-0.9.0 spec/grape/api/helpers_spec.rb