Sha256: 617255756e2a77d9804bcfdb015b4a072e04a8200c11efd1f64e604ce9923dea
Contents?: true
Size: 982 Bytes
Versions: 7
Compression:
Stored size: 982 Bytes
Contents
require 'spec_helper' describe Grape::Endpoint do subject { Class.new(Grape::API) } def app subject end before do subject.namespace do format :json content_type :json, 'application/json' params do requires :id, desc: 'Identifier.' end get ':id' do { id: params[:id], format: params[:format] } end end end context 'get' do it 'no format' do get '/foo' expect(last_response.status).to eq 200 expect(last_response.body).to eq(MultiJson.dump(id: 'foo', format: nil)) end it 'json format' do get '/foo.json' expect(last_response.status).to eq 200 expect(last_response.body).to eq(MultiJson.dump(id: 'foo', format: 'json')) end it 'invalid format' do get '/foo.invalid' expect(last_response.status).to eq 200 expect(last_response.body).to eq(MultiJson.dump(id: 'foo', format: 'invalid')) end end end
Version data entries
7 entries across 7 versions & 1 rubygems