Sha256: bc6dc67cd57bb4b54117ed9155a86994b432d2ffd36f498ed06e7e4514af25d1

Contents?: true

Size: 1.81 KB

Versions: 1

Compression:

Stored size: 1.81 KB

Contents

require 'spec_helper'

describe 'ErrMerchant' do
  it 'shows a 500 when an exception is raised' do
    visit '/failures/wild_error'

    page.should have_content("We're sorry, but something went wrong.")
    page.status_code.should == 500
  end

  it 'shows a 404 when record not found' do
    visit '/failures/where_is_it'

    page.should have_content("The page you were looking for doesn't exist.")
    page.status_code.should == 404
  end

  it 'shows a 422 when an unprocessable entity is encountered' do
    visit '/failures/dont_process_this'

    page.should have_content("The change you wanted was rejected.")
    page.status_code.should == 422
  end

  it 'shows the error in the application layout' do
    visit '/failures/wild_error'

    page.should have_content("ErrMerchant Test Application")
  end

  it 'does not kick in if there are no errors' do
    visit '/failures/usual_action'

    page.should have_content("This is a usual action.")
    page.status_code.should == 200
  end

  it 'shows translated error messages if available' do
    I18n.locale = :de
    visit '/failures/where_is_it'

    page.should have_content("Seite nicht gefunden")
  end

  it 'shows english error message when no translation available' do
    I18n.locale = :fr
    visit '/failures/wild_error'

    page.should have_content("We're sorry, but something went wrong.")
  end

  it 'falls back to standard error pages if everything goes wrong' do
    ErrMerchant.layout = "erroneous"

    visit '/failures/wild_error'
    page.should have_content("We're sorry, but something went wrong.")
    page.status_code.should == 500
    page.should_not have_css('div.err_merchant')
    page.should have_css('div.dialog h1')
  end

  it 'should deliver airbrake notifications' do
    Airbrake.should_receive(:notify_or_ignore)
    visit '/failures/wild_error'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
err_merchant-0.2.0 spec/err_merchant_spec.rb