From c42bd31977d601a743a154cf5a614459b51a3cb3 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Wed, 25 Jan 2017 09:46:29 +0900 Subject: correctly check error message `assert_raise` does not check error message. However, in some tests, it seems like expecting error message checking with `assert_raise`. Instead of specifying an error message in `assert_raise`, modify to use another assert to check the error message. --- activesupport/test/dependencies_test.rb | 3 ++- activesupport/test/time_travel_test.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index e772d15d53..95d05df82f 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -271,7 +271,8 @@ class DependenciesTest < ActiveSupport::TestCase def test_raising_discards_autoloaded_constants with_autoloading_fixtures do - assert_raises(Exception, "arbitray exception message") { RaisesArbitraryException } + e = assert_raises(Exception) { RaisesArbitraryException } + assert_equal("arbitray exception message", e.message) assert_not defined?(A) assert_not defined?(RaisesArbitraryException) end diff --git a/activesupport/test/time_travel_test.rb b/activesupport/test/time_travel_test.rb index cfc6447360..e0d3fb0cf5 100644 --- a/activesupport/test/time_travel_test.rb +++ b/activesupport/test/time_travel_test.rb @@ -94,11 +94,12 @@ class TimeTravelTest < ActiveSupport::TestCase outer_expected_time = Time.new(2004, 11, 24, 01, 04, 44) inner_expected_time = Time.new(2004, 10, 24, 01, 04, 44) travel_to outer_expected_time do - assert_raises(RuntimeError, /Calling `travel_to` with a block, when we have previously already made a call to `travel_to`, can lead to confusing time stubbing./) do + e = assert_raises(RuntimeError) do travel_to(inner_expected_time) do #noop end end + assert_match(/Calling `travel_to` with a block, when we have previously already made a call to `travel_to`, can lead to confusing time stubbing./, e.message) end end end -- cgit v1.2.3