diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index ff7ec0f2c..fad78128f 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -5,8 +5,8 @@ class UsersControllerTest < ActionDispatch::IntegrationTest sign_in_as :kevin get users_path - assert_match /#{users(:david).name}/, @response.body - assert_match /#{users(:kevin).name}/, @response.body + assert_in_body users(:david).name + assert_in_body users(:kevin).name end test "new" do @@ -32,7 +32,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest sign_in_as :kevin get user_path(users(:david)) - assert_match /#{users(:david).name}/, @response.body + assert_in_body users(:david).name end test "update oneself" do diff --git a/test/test_helper.rb b/test/test_helper.rb index 1447430b1..dd27bd4ca 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -11,5 +11,15 @@ module ActiveSupport fixtures :all include CardTestHelper, ChangeTestHelper, SessionTestHelper + + # FIXME: Remove when upstream in Rails has landed (https://github.com/rails/rails/pull/54938) + def assert_in_body(text) + assert_match /#{text}/, @response.body + end + + # FIXME: Remove when upstream in Rails has landed (https://github.com/rails/rails/pull/54938) + def assert_not_in_body(text) + assert_no_match /#{text}/, @response.body + end end end