Sha256: f2890ff32b5ceaccc8c39da714e89a81a31d6137861a8284f02e06c3dcbd6158
Contents?: true
Size: 927 Bytes
Versions: 2
Compression:
Stored size: 927 Bytes
Contents
require 'spec_helper' describe Grape::Middleware::Error do class ErrApp class << self attr_accessor :error attr_accessor :format def call(env) throw :error, error end end end def app Rack::Builder.app do use Grape::Middleware::Error, default_message: 'Aww, hamburgers.' run ErrApp end end it 'sets the status code appropriately' do ErrApp.error = { status: 410 } get '/' expect(last_response.status).to eq(410) end it 'sets the error message appropriately' do ErrApp.error = { message: 'Awesome stuff.' } get '/' expect(last_response.body).to eq('Awesome stuff.') end it 'defaults to a 500 status' do ErrApp.error = {} get '/' expect(last_response.status).to eq(500) end it 'has a default message' do ErrApp.error = {} get '/' expect(last_response.body).to eq('Aww, hamburgers.') end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
grape-security-0.8.0 | spec/grape/middleware/error_spec.rb |
grape-0.8.0 | spec/grape/middleware/error_spec.rb |