aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-01-25 09:46:29 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-01-25 09:58:15 +0900
commitc42bd31977d601a743a154cf5a614459b51a3cb3 (patch)
tree2d52a01d303e0ec2ca1cbb4d9eeb07e822bf2298 /activesupport
parentc6f9f8c28a720ad4ec7cf3613dddfa451d5968e2 (diff)
downloadrails-c42bd31977d601a743a154cf5a614459b51a3cb3.tar.gz
rails-c42bd31977d601a743a154cf5a614459b51a3cb3.tar.bz2
rails-c42bd31977d601a743a154cf5a614459b51a3cb3.zip
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.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/test/dependencies_test.rb3
-rw-r--r--activesupport/test/time_travel_test.rb3
2 files changed, 4 insertions, 2 deletions
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