|
2 | 2 |
|
3 | 3 | RSpec.describe "Errors", type: :request do |
4 | 4 | include Rambulance::TestHelper |
| 5 | + include ErrorsHelper |
5 | 6 |
|
6 | 7 | before do |
7 | 8 | # テスト用のルーティングを直接定義 |
8 | 9 | Rails.application.routes.draw do |
9 | | - get '/trigger_403', to: ->(env) { raise ActionController::Forbidden } |
| 10 | + get '/trigger_400', to: ->(env) { raise ActionController::BadRequest } |
10 | 11 | get '/trigger_422', to: ->(env) { raise ActionController::InvalidAuthenticityToken } |
11 | 12 | get '/trigger_500', to: ->(env) { raise "This is a test 500 error" } |
12 | 13 | end |
|
30 | 31 | get '/does_not_exist' |
31 | 32 | end |
32 | 33 | expect(response.status).to eq(404) |
33 | | - expect(response.body).to include("子どものためのプログラミング道場") |
| 34 | + expect(response.body).to include(error_title(404)) |
| 35 | + expect(response.body).to include(error_desc(404)) |
34 | 36 | end |
35 | 37 |
|
36 | 38 | it 'renders the 422 error page' do |
37 | 39 | with_exceptions_app do |
38 | 40 | get '/trigger_422' |
39 | 41 | end |
40 | 42 | expect(response.status).to eq(422) |
41 | | - expect(response.body).to include("子どものためのプログラミング道場") |
| 43 | + expect(response.body).to include(error_title(422)) |
| 44 | + expect(response.body).to include(error_desc(422)) |
42 | 45 | end |
43 | 46 |
|
44 | 47 | it 'renders the 500 error page' do |
45 | 48 | with_exceptions_app do |
46 | 49 | get '/trigger_500' |
47 | 50 | end |
48 | 51 | expect(response.status).to eq(500) |
49 | | - expect(response.body).to include("子どものためのプログラミング道場") |
| 52 | + expect(response.body).to include(error_title(500)) |
| 53 | + expect(response.body).to include(error_desc(500)) |
| 54 | + end |
| 55 | + it 'renders the 400 error page' do |
| 56 | + with_exceptions_app do |
| 57 | + get '/trigger_400' |
| 58 | + end |
| 59 | + expect(response.status).to eq(400) |
| 60 | + expect(response.body).to include(error_title(400)) |
| 61 | + expect(response.body).to include(error_desc(400)) |
50 | 62 | end |
51 | | - |
52 | 63 | end |
53 | 64 | end |
0 commit comments