Skip to content

Commit 5cc74fd

Browse files
committed
統計ページの英語版に対するテストを追加
- 日本語版と英語版の表示内容を確認 - 言語切り替えリンクの動作を確認 - 都道府県名の英語表記を確認 - グラフタイトルの英語表記を確認 - 言語パラメータの設定を確認
1 parent 73d8d7a commit 5cc74fd

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

spec/requests/stats_spec.rb

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
require 'rails_helper'
2+
3+
RSpec.describe "Stats", type: :request do
4+
describe "GET /stats" do
5+
it "日本語版の統計ページが表示される" do
6+
get "/stats"
7+
expect(response).to have_http_status(200)
8+
expect(response.body).to include("統計情報")
9+
expect(response.body).to include("推移グラフ")
10+
expect(response.body).to include("最新データ")
11+
expect(response.body).to include("View in English")
12+
end
13+
end
14+
15+
describe "GET /english/stats" do
16+
it "英語版の統計ページが表示される" do
17+
get "/english/stats"
18+
expect(response).to have_http_status(200)
19+
expect(response.body).to include("Statistics")
20+
expect(response.body).to include("Transition Charts")
21+
expect(response.body).to include("Latest Data")
22+
expect(response.body).to include("Switch to Japanese")
23+
end
24+
25+
it "都道府県名が英語で表示される" do
26+
# テストデータベースに都道府県を作成
27+
Prefecture.find_or_create_by!(name: "東京", region: "関東")
28+
Prefecture.find_or_create_by!(name: "大阪", region: "近畿")
29+
Prefecture.find_or_create_by!(name: "北海道", region: "北海道")
30+
31+
get "/english/stats"
32+
expect(response.body).to include("Tokyo")
33+
expect(response.body).to include("Osaka")
34+
expect(response.body).to include("Hokkaido")
35+
end
36+
37+
it "グラフのタイトルが英語で表示される" do
38+
get "/english/stats"
39+
expect(response.body).to include("Number of Dojos")
40+
expect(response.body).to include("Number of Events")
41+
expect(response.body).to include("Number of Participants")
42+
end
43+
end
44+
45+
describe "言語パラメータ" do
46+
it "言語パラメータがデフォルトで'ja'に設定される" do
47+
get "/stats"
48+
controller = @controller
49+
expect(controller.instance_variable_get(:@lang)).to eq('ja')
50+
end
51+
52+
it "/english/stats で言語パラメータが'en'に設定される" do
53+
get "/english/stats"
54+
controller = @controller
55+
expect(controller.instance_variable_get(:@lang)).to eq('en')
56+
end
57+
end
58+
end

0 commit comments

Comments
 (0)