Browse files

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".
  • Loading branch information...
1 parent afd0a8a commit d8537ef1ec1ba51eb08087b4c929474f267bdf10 @razielgn razielgn committed Oct 7, 2013
Showing with 3 additions and 1 deletion.
  1. +3 −1 activerecord/test/cases/transactions_test.rb
@@ -421,7 +421,9 @@ def test_rollback_when_saving_a_frozen_record
topic = => 'test')
e = assert_raise(RuntimeError) { }
- 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 topic.frozen?, 'not frozen'

0 comments on commit d8537ef

Please sign in to comment.