Skip to content

Commit 325c04c

Browse files
authored
Merge pull request rails#51693 from fatkodima/assertionless-tests
Enable raising for assertionless tests for internal framework tests
2 parents b7d1ff7 + 7026382 commit 325c04c

File tree

58 files changed

+235
-121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+235
-121
lines changed

actionpack/test/controller/action_pack_assertions_test.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,11 @@ def test_get_post_request_switch
177177
end
178178

179179
def test_string_constraint
180-
with_routing do |set|
181-
set.draw do
182-
get "photos", to: "action_pack_assertions#nothing", constraints: { subdomain: "admin" }
180+
assert_nothing_raised do
181+
with_routing do |set|
182+
set.draw do
183+
get "photos", to: "action_pack_assertions#nothing", constraints: { subdomain: "admin" }
184+
end
183185
end
184186
end
185187
end

actionpack/test/controller/flash_test.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,19 @@ def test_setting_flash_does_not_raise_in_following_requests
310310
with_test_route_set do
311311
env = { "action_dispatch.request.flash_hash" => ActionDispatch::Flash::FlashHash.new }
312312
get "/set_flash", env: env
313-
get "/set_flash", env: env
313+
assert_nothing_raised do
314+
get "/set_flash", env: env
315+
end
314316
end
315317
end
316318

317319
def test_setting_flash_now_does_not_raise_in_following_requests
318320
with_test_route_set do
319321
env = { "action_dispatch.request.flash_hash" => ActionDispatch::Flash::FlashHash.new }
320322
get "/set_flash_now", env: env
321-
get "/set_flash_now", env: env
323+
assert_nothing_raised do
324+
get "/set_flash_now", env: env
325+
end
322326
end
323327
end
324328

actionpack/test/controller/live_stream_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ def test_delayed_autoload_after_write_within_interlock_hook
430430
res = get :write_sleep_autoload
431431
res.each { }
432432
ActiveSupport::Dependencies.interlock.done_running
433+
pass
433434
end
434435

435436
def test_async_stream

actionpack/test/controller/render_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,7 @@ def test_live_head_ok
10001000

10011001
@response.stream.on_error { flunk "action should not raise any errors" }
10021002
sleep 0.2
1003+
pass
10031004
end
10041005
end
10051006

actionpack/test/controller/routing_test.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,11 @@ def setup_for_named_route(options = {})
508508
end
509509

510510
def test_named_route_without_hash
511-
rs.draw do
512-
ActionDispatch.deprecator.silence do
513-
get ":controller/:action/:id", as: "normal"
511+
assert_nothing_raised do
512+
rs.draw do
513+
ActionDispatch.deprecator.silence do
514+
get ":controller/:action/:id", as: "normal"
515+
end
514516
end
515517
end
516518
end

actionpack/test/dispatch/mapper_test.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ def asts
3636
end
3737

3838
def test_initialize
39-
Mapper.new FakeSet.new
39+
assert_nothing_raised do
40+
Mapper.new FakeSet.new
41+
end
4042
end
4143

4244
def test_scope_raises_on_anchor

actionpack/test/dispatch/request/multipart_params_parsing_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def teardown
159159
fixture = FIXTURE_PATH + "/ruby_on_rails.jpg"
160160
params = { uploaded_data: fixture_file_upload(fixture, "image/jpeg") }
161161
post "/read", params: params
162+
assert_equal Encoding::ASCII_8BIT, response.body.encoding
162163
end
163164
end
164165

actionpack/test/dispatch/request_test.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,9 @@ class RequestParameters < BaseRequestTest
11521152
request = stub_request("QUERY_STRING" => "foo=%81E")
11531153

11541154
ActionDispatch::Request::Utils.stub(:set_binary_encoding, { "foo" => "\x81E".b }) do
1155-
request.parameters
1155+
assert_nothing_raised do
1156+
request.parameters
1157+
end
11561158
end
11571159
end
11581160

@@ -1166,7 +1168,9 @@ class RequestParameters < BaseRequestTest
11661168
)
11671169

11681170
ActionDispatch::Request::Utils.stub(:set_binary_encoding, { "foo" => "\x81E".b }) do
1169-
request.parameters
1171+
assert_nothing_raised do
1172+
request.parameters
1173+
end
11701174
end
11711175
end
11721176

actionpack/test/dispatch/system_testing/driver_test.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ class DriverTest < ActiveSupport::TestCase
3030

3131
test "initializing the driver with a headless chrome and custom path" do
3232
original_driver_path = ::Selenium::WebDriver::Chrome::Service.driver_path
33-
::Selenium::WebDriver::Chrome::Service.driver_path = "bin/test"
34-
ActionDispatch::SystemTesting::Driver.new(:selenium, using: :headless_chrome, screen_size: [1400, 1400])
33+
assert_nothing_raised do
34+
::Selenium::WebDriver::Chrome::Service.driver_path = "bin/test"
35+
ActionDispatch::SystemTesting::Driver.new(:selenium, using: :headless_chrome, screen_size: [1400, 1400])
36+
end
3537
ensure
3638
::Selenium::WebDriver::Chrome::Service.driver_path = original_driver_path
3739
end
@@ -47,8 +49,10 @@ class DriverTest < ActiveSupport::TestCase
4749

4850
test "initializing the driver with a headless firefox and custom path" do
4951
original_driver_path = ::Selenium::WebDriver::Firefox::Service.driver_path
50-
::Selenium::WebDriver::Firefox::Service.driver_path = "bin/test"
51-
ActionDispatch::SystemTesting::Driver.new(:selenium, using: :headless_firefox, screen_size: [1400, 1400])
52+
assert_nothing_raised do
53+
::Selenium::WebDriver::Firefox::Service.driver_path = "bin/test"
54+
ActionDispatch::SystemTesting::Driver.new(:selenium, using: :headless_firefox, screen_size: [1400, 1400])
55+
end
5256
ensure
5357
::Selenium::WebDriver::Firefox::Service.driver_path = original_driver_path
5458
end

actiontext/test/unit/strict_loading_test.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@ class MessageWithFooter < MessageWithStrictLoading
2828

2929
records = MessageWithStrictLoading.with_rich_text_strict_loading_content.all
3030

31-
records.map(&:strict_loading_content)
31+
assert_nothing_raised do
32+
records.map(&:strict_loading_content)
33+
end
3234
end
3335

3436
test "has_rich_text accepts strict_loading: overrides" do
3537
MessageWithFooter.create! footer: "ignored"
3638

3739
records = MessageWithFooter.all
3840

39-
records.map(&:footer)
41+
assert_nothing_raised do
42+
records.map(&:footer)
43+
end
4044
end
4145
end

0 commit comments

Comments
 (0)