Sha256: dc743be8db9f731f6f2011426d9967fb25ecbce61411ca1a4f037cfb15c36b33

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe Sinatra::Errorcodes do
  it 'has a version number' do
    expect(Sinatra::Errorcodes::VERSION).not_to be nil
  end

  it 'provides status 500' do
    expect(HTTPError::InternalServerError::CODE).to be 500
    expect(HTTPError::InternalServerError::MESSAGE).to eq 'Internal Server Error'
  end

  it 'provides status 400' do
    expect(HTTPError::BadRequest::CODE).to be 400
    expect(HTTPError::BadRequest::MESSAGE).to eq 'Bad Request'
  end

  it 'returns status 500 ' do
    get '/error'
    expect(last_response.status).to be 500
    expect(last_response.body).to eq 'Internal Server Error'
  end

  it 'returns status 400' do
    get '/badrequest'
    expect(last_response.status).to be 400
    expect(last_response.body).to eq 'Bad Request'
  end

  it 'returns status 500 with a custom error message' do
    get '/custom'
    expect(last_response.status).to be 500
    expect(last_response.body).to eq 'Custom error message'
  end

  it 'returns status 500 without a message of HTTPError::InternalServerError' do
    get '/general_error'
    expect(last_response.status).to be 500
    expect(last_response.body).not_to eq 'Internal Server Error'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sinatra-errorcodes-0.1.2 spec/sinatra/errorcodes_spec.rb