Sha256: 869aba0a6101100f4e25608873dd30dfecc300f80415ea5190a6c65c7e4b29a8
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
# encoding: UTF-8 require 'spec_helper' feature 'Error json response', if: !ENV["CUSTOM_EXCEPTIONS_APP"], type: :request do def json_response JSON.parse(response.body) end def get(path) super(path, nil, "CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/json") end scenario 'returns 422 json due to ActionController:InvalidAuthenticityToken but without its template' do get '/users/new' expect(response.status).to eq(422) expect(json_response['message']).to eq("Something went wrong") end scenario 'returns 500 json due to RuntimeError' do get '/users/1.json' expect(response.status).to eq(500) expect(json_response['message']).to eq("Something went wrong") end scenario 'returns 404 json due to CustomException' do get '/users.json' expect(response.status).to eq(404) expect(json_response['message']).to eq("Page not found") end scenario 'returns 404 json due to ActinoController::RoutingError' do get '/doesnt_exist.json' expect(response.status).to eq(404) expect(json_response['message']).to eq("Page not found") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rambulance-0.3.0 | spec/requests/error_json_spec.rb |
rambulance-0.2.0 | spec/requests/error_json_spec.rb |