Skip to content

Commit 4e3c8ce

Browse files
purinklelaicuRoot
andcommitted
Make the gem enable missing translation errors
Before, the gem generated the default configuration for the test environment. We wanted to raise errors when we missed a translation. We enabled this configuration in the gem for the test environment. [GitHub](#1259) Co-authored-by: Jose Blanco <jose.blanco@thoughtbot.com>
1 parent 71a76db commit 4e3c8ce

4 files changed

Lines changed: 242 additions & 21 deletions

File tree

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ gem "rake", "~> 13.0"
1111
gem "rspec", "~> 3.0"
1212

1313
gem "standard", "~> 1.3"
14+
15+
gem "rails"
16+
gem "rubocop-rails-omakase"

Gemfile.lock

Lines changed: 197 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,95 @@ PATH
66
GEM
77
remote: https://rubygems.org/
88
specs:
9+
action_text-trix (2.1.15)
10+
railties
11+
actioncable (8.1.1)
12+
actionpack (= 8.1.1)
13+
activesupport (= 8.1.1)
14+
nio4r (~> 2.0)
15+
websocket-driver (>= 0.6.1)
16+
zeitwerk (~> 2.6)
17+
actionmailbox (8.1.1)
18+
actionpack (= 8.1.1)
19+
activejob (= 8.1.1)
20+
activerecord (= 8.1.1)
21+
activestorage (= 8.1.1)
22+
activesupport (= 8.1.1)
23+
mail (>= 2.8.0)
24+
actionmailer (8.1.1)
25+
actionpack (= 8.1.1)
26+
actionview (= 8.1.1)
27+
activejob (= 8.1.1)
28+
activesupport (= 8.1.1)
29+
mail (>= 2.8.0)
30+
rails-dom-testing (~> 2.2)
31+
actionpack (8.1.1)
32+
actionview (= 8.1.1)
33+
activesupport (= 8.1.1)
34+
nokogiri (>= 1.8.5)
35+
rack (>= 2.2.4)
36+
rack-session (>= 1.0.1)
37+
rack-test (>= 0.6.3)
38+
rails-dom-testing (~> 2.2)
39+
rails-html-sanitizer (~> 1.6)
40+
useragent (~> 0.16)
41+
actiontext (8.1.1)
42+
action_text-trix (~> 2.1.15)
43+
actionpack (= 8.1.1)
44+
activerecord (= 8.1.1)
45+
activestorage (= 8.1.1)
46+
activesupport (= 8.1.1)
47+
globalid (>= 0.6.0)
48+
nokogiri (>= 1.8.5)
49+
actionview (8.1.1)
50+
activesupport (= 8.1.1)
51+
builder (~> 3.1)
52+
erubi (~> 1.11)
53+
rails-dom-testing (~> 2.2)
54+
rails-html-sanitizer (~> 1.6)
55+
activejob (8.1.1)
56+
activesupport (= 8.1.1)
57+
globalid (>= 0.3.6)
58+
activemodel (8.1.1)
59+
activesupport (= 8.1.1)
60+
activerecord (8.1.1)
61+
activemodel (= 8.1.1)
62+
activesupport (= 8.1.1)
63+
timeout (>= 0.4.0)
64+
activestorage (8.1.1)
65+
actionpack (= 8.1.1)
66+
activejob (= 8.1.1)
67+
activerecord (= 8.1.1)
68+
activesupport (= 8.1.1)
69+
marcel (~> 1.0)
70+
activesupport (8.1.1)
71+
base64
72+
bigdecimal
73+
concurrent-ruby (~> 1.0, >= 1.3.1)
74+
connection_pool (>= 2.2.5)
75+
drb
76+
i18n (>= 1.6, < 2)
77+
json
78+
logger (>= 1.4.2)
79+
minitest (>= 5.1)
80+
securerandom (>= 0.3)
81+
tzinfo (~> 2.0, >= 2.0.5)
82+
uri (>= 0.13.1)
983
ast (2.4.2)
1084
base64 (0.1.2)
85+
bigdecimal (3.3.1)
86+
builder (3.3.0)
87+
concurrent-ruby (1.3.5)
88+
connection_pool (3.0.2)
89+
crass (1.0.6)
1190
date (3.4.1)
1291
diff-lcs (1.6.2)
92+
drb (2.2.3)
93+
erubi (1.13.1)
94+
globalid (1.3.0)
95+
activesupport (>= 6.1)
96+
i18n (1.14.7)
97+
concurrent-ruby (~> 1.0)
1398
io-console (0.8.0)
1499
irb (1.15.1)
15100
pp (>= 0.6.0)
@@ -18,25 +103,90 @@ GEM
18103
json (2.6.3)
19104
language_server-protocol (3.17.0.3)
20105
lint_roller (1.1.0)
106+
logger (1.7.0)
107+
loofah (2.24.1)
108+
crass (~> 1.0.2)
109+
nokogiri (>= 1.12.0)
110+
mail (2.9.0)
111+
logger
112+
mini_mime (>= 0.1.1)
113+
net-imap
114+
net-pop
115+
net-smtp
116+
marcel (1.1.0)
117+
mini_mime (1.1.5)
118+
minitest (5.26.2)
119+
net-imap (0.5.12)
120+
date
121+
net-protocol
122+
net-pop (0.1.2)
123+
net-protocol
124+
net-protocol (0.2.2)
125+
timeout
126+
net-smtp (0.5.1)
127+
net-protocol
128+
nio4r (2.7.5)
129+
nokogiri (1.18.10-arm64-darwin)
130+
racc (~> 1.4)
131+
nokogiri (1.18.10-x86_64-linux-gnu)
132+
racc (~> 1.4)
21133
parallel (1.23.0)
22-
parser (3.2.2.4)
134+
parser (3.3.10.0)
23135
ast (~> 2.4.1)
24136
racc
25137
pp (0.6.2)
26138
prettyprint
27139
prettyprint (0.2.0)
140+
prism (1.6.0)
28141
psych (5.2.3)
29142
date
30143
stringio
31144
racc (1.8.1)
145+
rack (3.2.4)
146+
rack-session (2.1.1)
147+
base64 (>= 0.1.0)
148+
rack (>= 3.0.0)
149+
rack-test (2.2.0)
150+
rack (>= 1.3)
151+
rackup (2.3.1)
152+
rack (>= 3)
153+
rails (8.1.1)
154+
actioncable (= 8.1.1)
155+
actionmailbox (= 8.1.1)
156+
actionmailer (= 8.1.1)
157+
actionpack (= 8.1.1)
158+
actiontext (= 8.1.1)
159+
actionview (= 8.1.1)
160+
activejob (= 8.1.1)
161+
activemodel (= 8.1.1)
162+
activerecord (= 8.1.1)
163+
activestorage (= 8.1.1)
164+
activesupport (= 8.1.1)
165+
bundler (>= 1.15.0)
166+
railties (= 8.1.1)
167+
rails-dom-testing (2.3.0)
168+
activesupport (>= 5.0.0)
169+
minitest
170+
nokogiri (>= 1.6)
171+
rails-html-sanitizer (1.6.2)
172+
loofah (~> 2.21)
173+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
174+
railties (8.1.1)
175+
actionpack (= 8.1.1)
176+
activesupport (= 8.1.1)
177+
irb (~> 1.13)
178+
rackup (>= 1.0.0)
179+
rake (>= 12.2)
180+
thor (~> 1.0, >= 1.2.2)
181+
tsort (>= 0.2)
182+
zeitwerk (~> 2.6)
32183
rainbow (3.1.1)
33184
rake (13.2.1)
34185
rdoc (6.12.0)
35186
psych (>= 4.0.0)
36-
regexp_parser (2.8.2)
187+
regexp_parser (2.11.3)
37188
reline (0.6.0)
38189
io-console (~> 0.5)
39-
rexml (3.2.6)
40190
rspec (3.13.2)
41191
rspec-core (~> 3.13.0)
42192
rspec-expectations (~> 3.13.0)
@@ -50,38 +200,62 @@ GEM
50200
diff-lcs (>= 1.2.0, < 2.0)
51201
rspec-support (~> 3.13.0)
52202
rspec-support (3.13.6)
53-
rubocop (1.56.4)
54-
base64 (~> 0.1.1)
203+
rubocop (1.75.6)
55204
json (~> 2.3)
56-
language_server-protocol (>= 3.17.0)
205+
language_server-protocol (~> 3.17.0.2)
206+
lint_roller (~> 1.1.0)
57207
parallel (~> 1.10)
58-
parser (>= 3.2.2.3)
208+
parser (>= 3.3.0.2)
59209
rainbow (>= 2.2.2, < 4.0)
60-
regexp_parser (>= 1.8, < 3.0)
61-
rexml (>= 3.2.5, < 4.0)
62-
rubocop-ast (>= 1.28.1, < 2.0)
210+
regexp_parser (>= 2.9.3, < 3.0)
211+
rubocop-ast (>= 1.44.0, < 2.0)
63212
ruby-progressbar (~> 1.7)
64-
unicode-display_width (>= 2.4.0, < 3.0)
65-
rubocop-ast (1.29.0)
66-
parser (>= 3.2.1.0)
67-
rubocop-performance (1.19.1)
68-
rubocop (>= 1.7.0, < 2.0)
69-
rubocop-ast (>= 0.4.0)
213+
unicode-display_width (>= 2.4.0, < 4.0)
214+
rubocop-ast (1.48.0)
215+
parser (>= 3.3.7.2)
216+
prism (~> 1.4)
217+
rubocop-performance (1.25.0)
218+
lint_roller (~> 1.1)
219+
rubocop (>= 1.75.0, < 2.0)
220+
rubocop-ast (>= 1.38.0, < 2.0)
221+
rubocop-rails (2.34.2)
222+
activesupport (>= 4.2.0)
223+
lint_roller (~> 1.1)
224+
rack (>= 1.1)
225+
rubocop (>= 1.75.0, < 2.0)
226+
rubocop-ast (>= 1.44.0, < 2.0)
227+
rubocop-rails-omakase (1.1.0)
228+
rubocop (>= 1.72)
229+
rubocop-performance (>= 1.24)
230+
rubocop-rails (>= 2.30)
70231
ruby-progressbar (1.13.0)
71-
standard (1.31.2)
232+
securerandom (0.4.1)
233+
standard (1.50.0)
72234
language_server-protocol (~> 3.17.0.2)
73235
lint_roller (~> 1.0)
74-
rubocop (~> 1.56.4)
236+
rubocop (~> 1.75.5)
75237
standard-custom (~> 1.0.0)
76-
standard-performance (~> 1.2)
238+
standard-performance (~> 1.8)
77239
standard-custom (1.0.2)
78240
lint_roller (~> 1.0)
79241
rubocop (~> 1.50)
80-
standard-performance (1.2.1)
242+
standard-performance (1.8.0)
81243
lint_roller (~> 1.1)
82-
rubocop-performance (~> 1.19.1)
244+
rubocop-performance (~> 1.25.0)
83245
stringio (3.1.3)
246+
thor (1.4.0)
247+
timeout (0.5.0)
248+
tsort (0.2.0)
249+
tzinfo (2.0.6)
250+
concurrent-ruby (~> 1.0)
84251
unicode-display_width (2.5.0)
252+
uri (1.1.1)
253+
useragent (0.16.11)
254+
websocket-driver (0.8.0)
255+
base64
256+
websocket-extensions (>= 0.1.0)
257+
websocket-extensions (0.1.5)
258+
zeitwerk (2.7.3)
85259

86260
PLATFORMS
87261
arm64-darwin-21
@@ -91,8 +265,10 @@ PLATFORMS
91265

92266
DEPENDENCIES
93267
irb
268+
rails
94269
rake (~> 13.0)
95270
rspec (~> 3.0)
271+
rubocop-rails-omakase
96272
standard (~> 1.3)
97273
suspenders!
98274

lib/templates/web.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ def install_gems
1515
# Deployment
1616
add_procfiles
1717

18+
# Environments
19+
setup_test_environment
20+
1821
# Finalization
1922
run_migrations
2023
lint_codebase
@@ -34,6 +37,13 @@ def add_procfiles
3437
copy_file "Procfile"
3538
end
3639

40+
def setup_test_environment
41+
uncomment_lines(
42+
"config/environments/test.rb",
43+
/config\.i18n\.raise_on_missing_translations\s*=\s*true/
44+
)
45+
end
46+
3747
def run_migrations
3848
rails_command "db:create"
3949
rails_command "db:migrate"

spec/environments/test_spec.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require "tmpdir"
2+
require "spec_helper"
3+
4+
RSpec.describe "Test environment" do
5+
it "enables the raising of errors for missing translations" do
6+
with_temp_directory do |tmp_dir|
7+
generate tmp_dir, "test_app"
8+
configuration = File.read(
9+
File.join(
10+
tmp_dir,
11+
"test_app",
12+
"config/environments/test.rb"
13+
)
14+
)
15+
16+
expect(configuration)
17+
.to match /^\s*config\.i18n\.raise_on_missing_translations\s=\strue$/
18+
expect(configuration)
19+
.not_to match /^\s*#\sconfig\.i18n\.raise_on_missing_translations/
20+
end
21+
end
22+
23+
def with_temp_directory
24+
yield Dir.mktmpdir
25+
end
26+
27+
def generate(directory, app_name)
28+
Dir.chdir directory do
29+
Suspenders::CLI.run app_name
30+
end
31+
end
32+
end

0 commit comments

Comments
 (0)