From d8537ef1ec1ba51eb08087b4c929474f267bdf10 Mon Sep 17 00:00:00 2001 From: Federico Ravasio Date: Mon, 7 Oct 2013 10:20:05 +0200 Subject: Assert presence of "frozen" in error message, not the full MRI message. Related to all the other issues regarding message independent assertions to make Rails compatible with other Ruby implementations other than MRI. The best way here would be to have a specific error raised when modifying frozen objects, like FrozenObjectError or something. But since Ruby doesn't provide such a thing, we must limit the assertion to the lowest common denominator, which is word "frozen". --- activerecord/test/cases/transactions_test.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/activerecord/test/cases/transactions_test.rb b/activerecord/test/cases/transactions_test.rb index 17206ffe99..980981903a 100644 --- a/activerecord/test/cases/transactions_test.rb +++ b/activerecord/test/cases/transactions_test.rb @@ -421,7 +421,9 @@ class TransactionTest < ActiveRecord::TestCase topic = Topic.new(:title => 'test') topic.freeze e = assert_raise(RuntimeError) { topic.save } - assert_equal "can't modify frozen Hash", e.message + assert_match(/frozen/i, e.message) # Not good enough, but we can't do much + # about it since there is no specific error + # for frozen objects. assert !topic.persisted?, 'not persisted' assert_nil topic.id assert topic.frozen?, 'not frozen' -- cgit v1.2.3