Sha256: e3ab8fdecded3b3cb7d5d30afc6e7236393fcadba39d6b6bb6f20a70185e04a2

Contents?: true

Size: 697 Bytes

Versions: 13

Compression:

Stored size: 697 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Grape::API::Helpers do
  subject do
    shared_params = Module.new do
      extend Grape::API::Helpers

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

    Class.new(Grape::API) do
      helpers shared_params
      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

13 entries across 13 versions & 2 rubygems

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