2025-05-05 09:29:55 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2021-07-19 11:29:44 +02:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
2023-05-31 12:15:15 +02:00
|
|
|
RSpec.describe "Errors handling" do
|
2021-07-19 11:29:44 +02:00
|
|
|
it "renders the internal error page in case of exceptions" do
|
|
|
|
|
# We unfortunately cannot test raising exceptions as the test environment
|
|
|
|
|
# marks all requests as local and thus shows exception details instead (like in dev mode)
|
|
|
|
|
visit "/500"
|
|
|
|
|
expect(page).to have_current_path "/500"
|
|
|
|
|
expect(page).to have_text "An error occurred on the page you were trying to access."
|
2024-01-04 17:01:17 +01:00
|
|
|
expect(page).to have_no_text "Oh no, this is an internal error!"
|
2021-07-19 11:29:44 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "renders the not found page" do
|
|
|
|
|
# We unfortunately cannot test raising exceptions as the test environment
|
|
|
|
|
# marks all requests as local and thus shows exception details instead (like in dev mode)
|
|
|
|
|
visit "/404"
|
|
|
|
|
expect(page).to have_current_path "/404"
|
|
|
|
|
expect(page).to have_text "[Error 404] The page you were trying to access doesn't exist or has been removed."
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "renders the unacceptable response" do
|
|
|
|
|
# This file exists in public and is recommended to be rendered, but I'm not aware
|
|
|
|
|
# of any path that would trigger this
|
|
|
|
|
visit "/422"
|
|
|
|
|
expect(page).to have_current_path "/422"
|
|
|
|
|
expect(page).to have_text "The change you wanted was rejected."
|
|
|
|
|
end
|
|
|
|
|
end
|