Sha256: b2615b02a7cdf17865409778dc6acbbce7eaf4e2bdfca0dd1bf805504d435d3f
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
require 'spec_helper' require 'rack/test' describe ServiceTemplate::GrapeExtenders do include Rack::Test::Methods before do allow(ServiceTemplate::Logger.logger).to receive(:debug) end subject do Class.new(Grape::API) do format :json extend ServiceTemplate::GrapeExtenders end end def app subject end describe 'ActiveRecord extensions' do it 'rescues ActiveRecord::RecordNotFound and returns a 404' do subject.get do raise ActiveRecord::RecordNotFound end get '/' expect(response_code).to be 404 expect(parsed_response.error.code).to eq 'record_not_found' end end describe 'AASM extensions' do it 'rescues AASM::InvalidTransition and returns a 422' do module AASM class InvalidTransition < StandardError end end subject.get do raise AASM::InvalidTransition end get '/' expect(response_code).to be 422 expect(parsed_response.error.code).to eq 'unprocessable_entity' end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
service_template-0.5.2 | spec/grape_extenders_spec.rb |
service_template-0.5.1 | spec/grape_extenders_spec.rb |
service_template-0.5.0 | spec/grape_extenders_spec.rb |