Sha256: c0aa8e6b033d859204a877513b4f03e0f68556b475aa935d57ccef9bbe7231cf

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

# encoding: UTF-8
require 'spec_helper'

feature 'Error pages' do
  shared_examples_for "an action that renders 500 page if the template is missing" do
    scenario 'Unprocessable entity due to ActionController:InvalidAuthenticityToken but without its template' do
      visit '/users/new'

      page.status_code.should == 422
      page.body.should have_content "Error page"
      page.body.should have_content "Something went wrong."
    end
  end

  context 'with the default exceptions app', if: !ENV["CUSTOM_EXCEPTIONS_APP"] do
    it_behaves_like "an action that renders 500 page if the template is missing"

    scenario 'Internal server error due to RuntimeError' do
      visit '/users/1'

      page.status_code.should == 500
      page.body.should have_content "Error page"
      page.body.should have_content "Something went wrong."
    end

    scenario 'Not found due to CustomException' do
      visit '/users'

      page.status_code.should == 404
      page.body.should have_content "Error page"
      page.body.should have_content "Page not found."
    end

    scenario 'Not found due to ActinoController::RoutingError' do
      visit '/doesnt_exist'

      page.status_code.should == 404
      page.body.should have_content "Error page"
      page.body.should have_content "Page not found."
    end
  end

  context "With a custom exception app", if: ENV["CUSTOM_EXCEPTIONS_APP"] do
    it_behaves_like "an action that renders 500 page if the template is missing"

    scenario 'Internal server error due to RuntimeError' do
      visit '/users/1'

      page.status_code.should == 500
      page.body.should have_content "Custom error page"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rambulance-0.1.1 spec/requests/error_page_spec.rb