2015-12-02 05:15:17 +08:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
2015-12-19 01:40:53 +08:00
|
|
|
describe 'headers' do
|
2015-12-18 05:12:00 +08:00
|
|
|
include_context "the api entities"
|
|
|
|
|
|
2015-12-02 05:15:17 +08:00
|
|
|
before :all do
|
|
|
|
|
module TheApi
|
|
|
|
|
class HeadersApi < Grape::API
|
|
|
|
|
format :json
|
|
|
|
|
|
|
|
|
|
desc 'This returns something',
|
2015-12-18 05:12:00 +08:00
|
|
|
failure: [{code: 400, model: Entities::ApiError}],
|
2015-12-02 05:15:17 +08:00
|
|
|
headers: {
|
2015-12-02 18:23:22 +08:00
|
|
|
"X-Rate-Limit-Limit" => {
|
|
|
|
|
"description" => "The number of allowed requests in the current period",
|
|
|
|
|
"type" => "integer"
|
2015-12-02 05:15:17 +08:00
|
|
|
}},
|
|
|
|
|
|
2015-12-18 05:12:00 +08:00
|
|
|
entity: Entities::UseResponse
|
2015-12-02 05:15:17 +08:00
|
|
|
get '/use_headers' do
|
|
|
|
|
{ "declared_params" => declared(params) }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
add_swagger_documentation
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def app
|
|
|
|
|
TheApi::HeadersApi
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
subject do
|
|
|
|
|
get '/swagger_doc'
|
|
|
|
|
JSON.parse(last_response.body)
|
|
|
|
|
end
|
|
|
|
|
|
2015-12-19 03:29:48 +08:00
|
|
|
specify do
|
|
|
|
|
expect(subject['paths']['/use_headers']['get']).to include('headers')
|
|
|
|
|
expect(subject['paths']['/use_headers']['get']['headers']).to eql({
|
|
|
|
|
"X-Rate-Limit-Limit"=>{"description"=>"The number of allowed requests in the current period", "type"=>"integer"}
|
|
|
|
|
})
|
2015-12-02 05:15:17 +08:00
|
|
|
end
|
|
|
|
|
end
|