Skip to content

Commit c11312a

Browse files
authored
Merge pull request rails#53659 from zzak/railties-missing-assertions
Fix "Test is missing assertions" is caught by Strict Warnings
2 parents 3bdee53 + 71223ba commit c11312a

File tree

6 files changed

+16
-6
lines changed

6 files changed

+16
-6
lines changed

activesupport/lib/active_support/testing/tests_without_assertions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def after_teardown
1111

1212
if assertions.zero? && !skipped? && !error?
1313
file, line = method(name).source_location
14-
warn "Test is missing assertions: `#{name}` #{file}:#{line}"
14+
warn "Test is missing assertions: `#{name}` #{File.expand_path(file)}:#{line}"
1515
end
1616
end
1717
end

railties/test/application/generators_test.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ def check_expected
188188
end
189189

190190
quietly do
191-
Rails::Command.invoke(:generate, ["check_argv", "expected"]) # should not raise
191+
assert_nothing_raised do
192+
Rails::Command.invoke(:generate, ["check_argv", "expected"]) # should not raise
193+
end
192194
end
193195
end
194196

railties/test/application/initializers/frameworks_test.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ def show
220220
rails %w(generate model post title:string)
221221

222222
with_unhealthy_database do
223-
app("development")
223+
assert_nothing_raised do
224+
app("development")
225+
end
224226
end
225227
end
226228

railties/test/application/loading_test.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ class User < ActiveRecord::Base
8989
require "#{rails_root}/config/environment"
9090
setup_ar!
9191

92-
User
92+
assert_nothing_raised do
93+
User
94+
end
9395
end
9496

9597
test "load config/environments/environment before Bootstrap initializers" do

railties/test/application/rake/tmp_test.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def teardown
4040

4141
test "tmp:clear should work if folder missing" do
4242
FileUtils.remove_dir("#{app_path}/tmp")
43-
rails "tmp:clear"
43+
assert_nothing_raised do
44+
rails "tmp:clear"
45+
end
4446
end
4547
end
4648
end

railties/test/application/rake_test.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ def test_loading_only_yml_fixtures
205205
app_file "test/fixtures/products.csv", ""
206206

207207
require "#{rails_root}/config/environment"
208-
rails "db:fixtures:load"
208+
assert_nothing_raised do
209+
rails "db:fixtures:load"
210+
end
209211
end
210212

211213
def test_scaffold_tests_pass_by_default

0 commit comments

Comments
 (0)