From d3715f65734a10eac228359b9073bbc5aa3ecdbb Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Tue, 22 May 2012 14:13:39 -0700 Subject: Fixes the build break caused by 9ee8528 in #6445. Ruby 1.8 raises a TypeError when trying to modify a frozen Hash, while Ruby 1.9 raises a RuntimeError instead. Also, Ruby < 1.9.3 uses a lowercase 'hash' in the exception message while Ruby >= 1.9.3 uses an uppercase 'Hash' instead. This commit normalizes those issues in the test case. --- activerecord/test/cases/transactions_test.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activerecord') diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb index a9ccd00fac..3efaaef7de 100644 --- a/activerecord/test/cases/transactions_test.rb +++ b/activerecord/test/cases/transactions_test.rb @@ -363,10 +363,12 @@ class TransactionTest < ActiveRecord::TestCase end def test_rollback_when_saving_a_frozen_record + expected_raise = (RUBY_VERSION < '1.9') ? TypeError : RuntimeError + topic = Topic.new(:title => 'test') topic.freeze - e = assert_raise(RuntimeError) { topic.save } - assert_equal "can't modify frozen Hash", e.message + e = assert_raise(expected_raise) { topic.save } + assert_equal "can't modify frozen hash", e.message.downcase assert !topic.persisted?, 'not persisted' assert_nil topic.id assert topic.frozen?, 'not frozen' -- cgit v1.2.3