Sha256: 510327ef2137288cb9c91131215acc0b512111c90bd58fd4b59e1171544cd0f2

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

# encoding: UTF-8
require 'spec_helper'

feature 'Error json responses', if: !ENV["CUSTOM_EXCEPTIONS_APP"] 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 'Unprocessable entity due to ActionController:InvalidAuthenticityToken but without its template' do
    get '/users/new'

    response.status.should == 422
    json_response['message'].should == "Something went wrong"
  end

  scenario 'Internal server error due to RuntimeError' do
    get '/users/1.json'

    response.status.should == 500
    json_response['message'].should == "Something went wrong"
  end

  scenario 'Not found due to CustomException' do
    get '/users.json'

    response.status.should == 404
    json_response['message'].should == "Page not found"
  end

  scenario 'Not found due to ActinoController::RoutingError' do
    get '/doesnt_exist.json'

    response.status.should == 404
    json_response['message'].should == "Page not found"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rambulance-0.1.2 spec/requests/error_json_spec.rb
rambulance-0.1.1 spec/requests/error_json_spec.rb