- <%= @title %>
+ <%= title %>
- <%= @desc %>
+ <%= desc %>
From 29c6cac72e18af53f3bf35117511c95939a64a8e Mon Sep 17 00:00:00 2001
From: nacchan
Date: Wed, 18 Jun 2025 12:34:49 +0900
Subject: [PATCH 30/40] =?UTF-8?q?fix(config):=20Rambulance=E3=81=AE?=
=?UTF-8?q?=E4=BE=8B=E5=A4=96=E3=83=9E=E3=83=83=E3=83=94=E3=83=B3=E3=82=B0?=
=?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
422エラー(InvalidAuthenticityToken)が正しく処理されて
いなかった問題と、サーバー起動時にクラッシュする問題を修正。
- にを追加し、
422ページが表示されるようにマッピング。
- サーバー起動時のエラーを回避するため、
全ての例外クラスを定数から文字列に変更。
---
config/initializers/rambulance.rb | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/config/initializers/rambulance.rb b/config/initializers/rambulance.rb
index 47de0907..2b186e81 100644
--- a/config/initializers/rambulance.rb
+++ b/config/initializers/rambulance.rb
@@ -29,9 +29,10 @@
# If Rambulance receives an exception that is not listed here, it'll render
# the internal server error template and return 500 as http status.
config.rescue_responses = {
- ActionController::RoutingError => :not_found,
- AbstractController::ActionNotFound => :not_found,
- ActionController::BadRequest => :bad_request,
+ "ActionController::RoutingError" => :not_found,
+ "AbstractController::ActionNotFound" => :not_found,
+ "ActionController::BadRequest" => :bad_request,
+ "ActionController::InvalidAuthenticityToken" => :unprocessable_entity,
# "ActiveRecord::RecordNotUnique" => :unprocessable_entity,
# "CanCan::AccessDenied" => :forbidden,
From 48b231e2358431d8935506f0342053bae6818c62 Mon Sep 17 00:00:00 2001
From: nacchan
Date: Wed, 18 Jun 2025 14:54:30 +0900
Subject: [PATCH 31/40] =?UTF-8?q?fix(helper):=20=E4=BA=88=E6=9C=9F?=
=?UTF-8?q?=E3=81=9B=E3=81=AC=E3=82=A8=E3=83=A9=E3=83=BC=E7=99=BA=E7=94=9F?=
=?UTF-8?q?=E6=99=82=E3=81=AE=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8?=
=?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/helpers/errors_helper.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/helpers/errors_helper.rb b/app/helpers/errors_helper.rb
index 2bfb16ac..acb2edc7 100644
--- a/app/helpers/errors_helper.rb
+++ b/app/helpers/errors_helper.rb
@@ -13,7 +13,7 @@ def error_desc(code)
when 404 then "ページが削除された可能性があります 🤔💭"
when 422 then "入力内容に誤りがあるか、リクエストが正しく送信されなかった可能性があります。"
when 500 then "申し訳ありません。サーバーで問題が発生しています。"
- else "しばらく経ってから再度お試しください。"
+ else "ご迷惑をおかけして、大変申し訳ありません。"
end
end
end
From 8cd758dbc0ae9bfb187700f39e024a1ac8218e8f Mon Sep 17 00:00:00 2001
From: nacchan
Date: Wed, 18 Jun 2025 15:38:24 +0900
Subject: [PATCH 32/40] =?UTF-8?q?feat:=20=E9=96=8B=E7=99=BA=E7=94=A8?=
=?UTF-8?q?=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC=E3=83=9A=E3=83=BC=E3=82=B8?=
=?UTF-8?q?=E3=83=97=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC=E6=A9=9F=E8=83=BD?=
=?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
開発中に、設定ファイルを変更したり、意図的に例外を
発生させたりすることなく、エラーページのデザインを
簡単に確認できるようにするためのプレビュー機能を追加します。
- を作成
- 開発環境でのみ有効な のルートを追加
---
app/controllers/previews/errors_controller.rb | 21 +++++++++++++++++++
config/routes.rb | 9 ++++++++
2 files changed, 30 insertions(+)
create mode 100644 app/controllers/previews/errors_controller.rb
diff --git a/app/controllers/previews/errors_controller.rb b/app/controllers/previews/errors_controller.rb
new file mode 100644
index 00000000..67c09c56
--- /dev/null
+++ b/app/controllers/previews/errors_controller.rb
@@ -0,0 +1,21 @@
+class Previews::ErrorsController < ApplicationController
+ # このコントローラー全体で、application.html.erb のレイアウトを使用します
+ layout "application"
+
+ # 404ページをプレビューするためのアクション
+ def not_found
+ # app/views/errors/not_found.html.erb を、
+ # ステータスコード404で描画します
+ render template: "errors/not_found", status: :not_found
+ end
+
+ # 422ページをプレビューするためのアクション
+ def unprocessable_entity
+ render template: "errors/unprocessable_entity", status: :unprocessable_entity
+ end
+
+ # 500ページをプレビューするためのアクション
+ def internal_server_error
+ render template: "errors/internal_server_error", status: :internal_server_error
+ end
+end
diff --git a/config/routes.rb b/config/routes.rb
index a113fce3..62aa73dd 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -111,6 +111,15 @@
# Check development sent emails
mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
+ if Rails.env.development?
+ namespace :previews do
+ # /previews/errors/404 などのURLでアクセスできるようになります
+ get "errors/404" => "errors#not_found"
+ get "errors/422" => "errors#unprocessable_entity"
+ get "errors/500" => "errors#internal_server_error"
+ end
+ end
+
# Rambulance がキャッチする /404, /422, /500
match "/404", to: Rambulance::Engine, via: :all, defaults: { status_code: 404 }
match "/422", to: Rambulance::Engine, via: :all, defaults: { status_code: 422 }
From 52bc61daf2e646f2269bcbb326c335db65d6436f Mon Sep 17 00:00:00 2001
From: nacchan
Date: Thu, 19 Jun 2025 08:28:31 +0900
Subject: [PATCH 33/40] =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E7=94=BB?=
=?UTF-8?q?=E9=9D=A2=E3=81=AE=E6=A1=88=E5=86=85=E6=96=87=E3=82=92=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0=E3=81=97=E3=80=81=E5=A0=B1=E5=91=8A=E4=BE=9D=E9=A0=BC?=
=?UTF-8?q?=E3=81=AE=E6=96=87=E8=A8=80=E3=82=92=E8=BF=BD=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/helpers/errors_helper.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/helpers/errors_helper.rb b/app/helpers/errors_helper.rb
index acb2edc7..e9dd015d 100644
--- a/app/helpers/errors_helper.rb
+++ b/app/helpers/errors_helper.rb
@@ -13,7 +13,7 @@ def error_desc(code)
when 404 then "ページが削除された可能性があります 🤔💭"
when 422 then "入力内容に誤りがあるか、リクエストが正しく送信されなかった可能性があります。"
when 500 then "申し訳ありません。サーバーで問題が発生しています。"
- else "ご迷惑をおかけして、大変申し訳ありません。"
+ else "改善されない場合は、お手数ですがエラー報告をお願いいたします🙇♀️"
end
end
end
From 619801e5ad304cb14d4d58e0c42ad1515c9cc781 Mon Sep 17 00:00:00 2001
From: nacchan
Date: Thu, 19 Jun 2025 09:27:12 +0900
Subject: [PATCH 34/40] =?UTF-8?q?refactor:=20400=E3=83=BB403=E3=82=A8?=
=?UTF-8?q?=E3=83=A9=E3=83=BC=E3=83=93=E3=83=A5=E3=83=BC=E3=82=92=E5=85=B1?=
=?UTF-8?q?=E9=80=9A=E3=81=AE=E6=A7=8B=E6=88=90=E3=81=AB=E7=B5=B1=E4=B8=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
元から存在したとが、
他のエラーページと異なる独自の構造を持っていたため、
共通のパーシャルを呼び出す形に修正。
---
app/views/errors/bad_request.html.erb | 40 +--------------------------
app/views/errors/forbidden.html.erb | 39 +-------------------------
2 files changed, 2 insertions(+), 77 deletions(-)
diff --git a/app/views/errors/bad_request.html.erb b/app/views/errors/bad_request.html.erb
index 1c64ebeb..52a69226 100644
--- a/app/views/errors/bad_request.html.erb
+++ b/app/views/errors/bad_request.html.erb
@@ -1,39 +1 @@
-<% provide(:title, "ページが見つかりませんでした... 🥺💦") %>
-<% provide(:desc, "ページが削除された可能性があります 🤔💭") %>
-
-
-
-
CoderDojo Japan
-
子どものためのプログラミング道場
-
-
-
-
-
- ページが見つかりませんでした... 🥺💦
-
-
- ページが削除された可能性があります 🤔💭
-
-
-
- フィードバックなどあれば info@coderdojo.jp にメールしていただくか、
-
- もしくは
- GitHub Issue
- に書いていただけると嬉しいです (>人< )✨
-
-
-
-
-
+<%= render template: "errors/show", locals: { status_code: 400 } %>
diff --git a/app/views/errors/forbidden.html.erb b/app/views/errors/forbidden.html.erb
index c9854724..b48a4db1 100644
--- a/app/views/errors/forbidden.html.erb
+++ b/app/views/errors/forbidden.html.erb
@@ -1,38 +1 @@
-<% provide(:title, "403 Forbidden エラー 🚧 🏗") %>
-<% provide(:desc, "アクセス権限が無いか削除された可能性があります 🤔💭") %>
-
-
-
-
CoderDojo Japan
-
子どものためのプログラミング道場
-
-
-
-
-
- アクセスできないページのため表示できませんでした 🚧 🏗
-
-
- ログインし直すことで解決する可能性があります 🤔💭
-
-
-
- フィードバックなどあれば info@coderdojo.jp にメールしていただくか、
-
- もしくは
- GitHub Issue
- に書いていただけると嬉しいです (>人< )✨
-
-
-
-
\ No newline at end of file
+<%= render template: "errors/show", locals: { status_code: 403 } %>
From 4df3a8afee30b061bdde07f1137305546ce4b5f1 Mon Sep 17 00:00:00 2001
From: nacchan
Date: Thu, 19 Jun 2025 09:33:35 +0900
Subject: [PATCH 35/40] =?UTF-8?q?feat:=20=E3=82=A8=E3=83=A9=E3=83=BC?=
=?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AE=E3=83=97=E3=83=AC=E3=83=93?=
=?UTF-8?q?=E3=83=A5=E3=83=BC=E6=A9=9F=E8=83=BD=E3=82=92=E5=8B=95=E7=9A=84?=
=?UTF-8?q?=E3=81=AB=E6=94=B9=E5=96=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
エラーの種類ごとにアクションやルートを追加する必要があった
静的なプレビュー機能を、URLのステータスコードを元に
動的にページを出し分ける、よりDRYな構成にリファクタリング。
- に アクションを実装
- ルートを に一本化
- これにより、今後のメンテナンス性が大幅に向上します
---
app/controllers/previews/errors_controller.rb | 27 +++++++++----------
config/routes.rb | 5 +---
2 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/app/controllers/previews/errors_controller.rb b/app/controllers/previews/errors_controller.rb
index 67c09c56..362e6657 100644
--- a/app/controllers/previews/errors_controller.rb
+++ b/app/controllers/previews/errors_controller.rb
@@ -1,21 +1,20 @@
class Previews::ErrorsController < ApplicationController
- # このコントローラー全体で、application.html.erb のレイアウトを使用します
layout "application"
- # 404ページをプレビューするためのアクション
- def not_found
- # app/views/errors/not_found.html.erb を、
- # ステータスコード404で描画します
- render template: "errors/not_found", status: :not_found
- end
+ def show
+ status_code = params[:status_code].to_i
- # 422ページをプレビューするためのアクション
- def unprocessable_entity
- render template: "errors/unprocessable_entity", status: :unprocessable_entity
- end
+ if status_code == 422
+ # 422の時だけは、ファイル名を直接指定
+ # Rails標準のRack::Utilsは422を "Unprocessable Content" と解釈しますが、
+ # Rambulanceが期待するビュー名は `unprocessable_entity.html.erb` です。
+ # この食い違いを吸収するため、422の時だけファイル名を直接指定しています。
+ error_page_name = "unprocessable_entity"
+ else
+ error_page_name = Rack::Utils::HTTP_STATUS_CODES[status_code].downcase.gsub(" ", "_")
+ end
- # 500ページをプレビューするためのアクション
- def internal_server_error
- render template: "errors/internal_server_error", status: :internal_server_error
+ render template: "errors/#{error_page_name}", status: status_code
end
+
end
diff --git a/config/routes.rb b/config/routes.rb
index 62aa73dd..a1510685 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -113,10 +113,7 @@
if Rails.env.development?
namespace :previews do
- # /previews/errors/404 などのURLでアクセスできるようになります
- get "errors/404" => "errors#not_found"
- get "errors/422" => "errors#unprocessable_entity"
- get "errors/500" => "errors#internal_server_error"
+ get "errors/:status_code", to: "errors#show"
end
end
From cc5dad93778f1a46e345fe20bfa88a636cbfc5c3 Mon Sep 17 00:00:00 2001
From: nacchan
Date: Thu, 19 Jun 2025 12:08:40 +0900
Subject: [PATCH 36/40] =?UTF-8?q?test:=20=E3=82=A8=E3=83=A9=E3=83=BC?=
=?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AE=E3=83=AA=E3=82=AF=E3=82=A8?=
=?UTF-8?q?=E3=82=B9=E3=83=88=E3=82=B9=E3=83=9A=E3=83=83=E3=82=AF=E3=82=92?=
=?UTF-8?q?=E8=BF=BD=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Rambulanceで生成されるエラーページ(404, 422, 500)が正しく表示されることを確認するためのリクエストスペックを追加します。
各エラーを意図的に発生させるためのテスト用ルーティングを定義し、それぞれのリクエストで期待されるステータスコードが返却されることを検証します。
---
spec/requests/errors_spec.rb | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/spec/requests/errors_spec.rb b/spec/requests/errors_spec.rb
index 9b568327..6fe3cca2 100644
--- a/spec/requests/errors_spec.rb
+++ b/spec/requests/errors_spec.rb
@@ -3,9 +3,30 @@
RSpec.describe "Errors", type: :request do
include Rambulance::TestHelper
+ before do
+ # テスト用のルーティングを直接定義
+ Rails.application.routes.draw do
+ get '/trigger_403', to: ->(env) { raise ActionController::Forbidden }
+ get '/trigger_422', to: ->(env) { raise ActionController::InvalidAuthenticityToken }
+ get '/trigger_500', to: ->(env) { raise "This is a test 500 error" }
+ end
+
+ # ビューのレンダリングをスタブして、レイアウト起因のエラーを回避
+ allow_any_instance_of(Rambulance::ExceptionsApp).to receive(:render).and_wrap_original do |m, *args|
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ m.call(*args, **options.merge(layout: false))
+ end
+ end
+
+ after do
+ # テスト後に追加したルーティングを元に戻す
+ Rails.application.reload_routes!
+ end
+
describe "Error requests" do
it 'renders the 404 error page' do
with_exceptions_app do
+ # どのルーティングにもマッチしないパスをリクエスト
get '/does_not_exist'
end
expect(response.status).to eq(404)
@@ -27,5 +48,6 @@
expect(response.status).to eq(500)
expect(response.body).to include("子どものためのプログラミング道場")
end
+
end
end
From 561e69883059021b4cf2bc272d190dd8944b8636 Mon Sep 17 00:00:00 2001
From: nacchan
Date: Mon, 23 Jun 2025 13:27:04 +0900
Subject: [PATCH 37/40] =?UTF-8?q?fix:=20422=E3=82=A8=E3=83=A9=E3=83=BC?=
=?UTF-8?q?=E3=83=93=E3=83=A5=E3=83=BC=E3=81=AE=E3=83=95=E3=82=A1=E3=82=A4?=
=?UTF-8?q?=E3=83=AB=E5=90=8D=E3=82=92Rambulance=E3=81=AE=E4=BB=95?=
=?UTF-8?q?=E6=A7=98=E3=81=AB=E7=B5=B1=E4=B8=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Rambulanceのプレビュー機能での検証をきっかけに、422エラー発生時に500ページが表示される問題が判明しました。
原因は、Rambulanceが期待するテンプレート名 () と実際のファイル名 () が異なっていたためです。
ファイル名をRambulanceの仕様に合わせ、この問題を修正します。
---
...processable_entity.html.erb => unprocessable_content.html.erb} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename app/views/errors/{unprocessable_entity.html.erb => unprocessable_content.html.erb} (100%)
diff --git a/app/views/errors/unprocessable_entity.html.erb b/app/views/errors/unprocessable_content.html.erb
similarity index 100%
rename from app/views/errors/unprocessable_entity.html.erb
rename to app/views/errors/unprocessable_content.html.erb
From 37ed1c4802929ba8d0daeb8f797417d199285382 Mon Sep 17 00:00:00 2001
From: nacchan
Date: Mon, 23 Jun 2025 13:47:34 +0900
Subject: [PATCH 38/40] =?UTF-8?q?refactor:=20=E8=87=AA=E4=BD=9C=E3=83=97?=
=?UTF-8?q?=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC=E6=A9=9F=E8=83=BD=E3=82=92?=
=?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=97=E3=80=81Rambulance=E3=81=AE?=
=?UTF-8?q?=E3=83=AB=E3=83=BC=E3=83=88=E3=81=AB=E7=B5=B1=E4=B8=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
自作していたエラーページのプレビュー機能 ( と関連ルーティング) を削除しました。
先ほどのビューファイル名の修正により、Rambulanceが の末尾で定義しているプレビュー用ルート (, など) で正しく表示できるようになったため、このリファクタリングを実施します。
よりシンプルでメンテナンスしやすい構成になります。
---
app/controllers/previews/errors_controller.rb | 20 -------------------
config/routes.rb | 6 ------
2 files changed, 26 deletions(-)
delete mode 100644 app/controllers/previews/errors_controller.rb
diff --git a/app/controllers/previews/errors_controller.rb b/app/controllers/previews/errors_controller.rb
deleted file mode 100644
index 362e6657..00000000
--- a/app/controllers/previews/errors_controller.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-class Previews::ErrorsController < ApplicationController
- layout "application"
-
- def show
- status_code = params[:status_code].to_i
-
- if status_code == 422
- # 422の時だけは、ファイル名を直接指定
- # Rails標準のRack::Utilsは422を "Unprocessable Content" と解釈しますが、
- # Rambulanceが期待するビュー名は `unprocessable_entity.html.erb` です。
- # この食い違いを吸収するため、422の時だけファイル名を直接指定しています。
- error_page_name = "unprocessable_entity"
- else
- error_page_name = Rack::Utils::HTTP_STATUS_CODES[status_code].downcase.gsub(" ", "_")
- end
-
- render template: "errors/#{error_page_name}", status: status_code
- end
-
-end
diff --git a/config/routes.rb b/config/routes.rb
index a1510685..a113fce3 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -111,12 +111,6 @@
# Check development sent emails
mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
- if Rails.env.development?
- namespace :previews do
- get "errors/:status_code", to: "errors#show"
- end
- end
-
# Rambulance がキャッチする /404, /422, /500
match "/404", to: Rambulance::Engine, via: :all, defaults: { status_code: 404 }
match "/422", to: Rambulance::Engine, via: :all, defaults: { status_code: 422 }
From 9b25662dc5296df1ca23c098170a7de8f792b010 Mon Sep 17 00:00:00 2001
From: nacchan
Date: Mon, 23 Jun 2025 14:00:41 +0900
Subject: [PATCH 39/40] =?UTF-8?q?test:=20=E3=82=A8=E3=83=A9=E3=83=BC?=
=?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8(404,=20422,=20500,=20400)=E3=81=AE?=
=?UTF-8?q?=E3=83=AA=E3=82=AF=E3=82=A8=E3=82=B9=E3=83=88=E3=82=B9=E3=83=9A?=
=?UTF-8?q?=E3=83=83=E3=82=AF=E3=82=92=E8=BF=BD=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
エラーページが正しく表示されることを検証する、
リクエストスペックを追加・改善しました。
- ErrorsHelperを読み込み、具体的な文言ではなく
ヘルパーの実行結果を検証することで、将来の文言変更に
強いテストに変更。
- これまでテストできていなかった400エラー(else句)の
テストケースも追加完了。
---
spec/requests/errors_spec.rb | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/spec/requests/errors_spec.rb b/spec/requests/errors_spec.rb
index 6fe3cca2..606b8fd5 100644
--- a/spec/requests/errors_spec.rb
+++ b/spec/requests/errors_spec.rb
@@ -2,11 +2,12 @@
RSpec.describe "Errors", type: :request do
include Rambulance::TestHelper
+ include ErrorsHelper
before do
# テスト用のルーティングを直接定義
Rails.application.routes.draw do
- get '/trigger_403', to: ->(env) { raise ActionController::Forbidden }
+ get '/trigger_400', to: ->(env) { raise ActionController::BadRequest }
get '/trigger_422', to: ->(env) { raise ActionController::InvalidAuthenticityToken }
get '/trigger_500', to: ->(env) { raise "This is a test 500 error" }
end
@@ -30,7 +31,8 @@
get '/does_not_exist'
end
expect(response.status).to eq(404)
- expect(response.body).to include("子どものためのプログラミング道場")
+ expect(response.body).to include(error_title(404))
+ expect(response.body).to include(error_desc(404))
end
it 'renders the 422 error page' do
@@ -38,7 +40,8 @@
get '/trigger_422'
end
expect(response.status).to eq(422)
- expect(response.body).to include("子どものためのプログラミング道場")
+ expect(response.body).to include(error_title(422))
+ expect(response.body).to include(error_desc(422))
end
it 'renders the 500 error page' do
@@ -46,8 +49,16 @@
get '/trigger_500'
end
expect(response.status).to eq(500)
- expect(response.body).to include("子どものためのプログラミング道場")
+ expect(response.body).to include(error_title(500))
+ expect(response.body).to include(error_desc(500))
+ end
+ it 'renders the 400 error page' do
+ with_exceptions_app do
+ get '/trigger_400'
+ end
+ expect(response.status).to eq(400)
+ expect(response.body).to include(error_title(400))
+ expect(response.body).to include(error_desc(400))
end
-
end
end
From ac24ce13ca319f665187098e16d83fc02e166985 Mon Sep 17 00:00:00 2001
From: nacchan
Date: Mon, 23 Jun 2025 14:16:26 +0900
Subject: [PATCH 40/40] =?UTF-8?q?style:=20=E3=83=86=E3=82=B9=E3=83=88?=
=?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AE=E3=82=AF=E3=82=A9=E3=83=BC?=
=?UTF-8?q?=E3=83=88=E3=82=92=E3=82=B7=E3=83=B3=E3=82=B0=E3=83=AB=E3=82=AF?=
=?UTF-8?q?=E3=82=A9=E3=83=BC=E3=83=88=E3=81=AB=E7=B5=B1=E4=B8=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
レビューでの指摘を反映し、テストコード内で使用する
文字列のクォートを修正しました。
---
spec/requests/errors_spec.rb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/spec/requests/errors_spec.rb b/spec/requests/errors_spec.rb
index 606b8fd5..2c3bee77 100644
--- a/spec/requests/errors_spec.rb
+++ b/spec/requests/errors_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'
-RSpec.describe "Errors", type: :request do
+RSpec.describe 'Errors', type: :request do
include Rambulance::TestHelper
include ErrorsHelper
@@ -9,7 +9,7 @@
Rails.application.routes.draw do
get '/trigger_400', to: ->(env) { raise ActionController::BadRequest }
get '/trigger_422', to: ->(env) { raise ActionController::InvalidAuthenticityToken }
- get '/trigger_500', to: ->(env) { raise "This is a test 500 error" }
+ get '/trigger_500', to: ->(env) { raise 'This is a test 500 error' }
end
# ビューのレンダリングをスタブして、レイアウト起因のエラーを回避
@@ -24,7 +24,7 @@
Rails.application.reload_routes!
end
- describe "Error requests" do
+ describe 'Error requests' do
it 'renders the 404 error page' do
with_exceptions_app do
# どのルーティングにもマッチしないパスをリクエスト