aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Ravasio <ravasio.federico@gmail.com>2013-10-07 10:20:05 +0200
committerFederico Ravasio <ravasio.federico@gmail.com>2013-10-08 00:15:07 +0200
commitd8537ef1ec1ba51eb08087b4c929474f267bdf10 (patch)
tree8ed5ad62061e3324b8e3f8276b1fa9e5b4cf0c63
parentafd0a8ab5f690b9bcc5f49371abd82d41a364f58 (diff)
downloadrails-d8537ef1ec1ba51eb08087b4c929474f267bdf10.tar.gz
rails-d8537ef1ec1ba51eb08087b4c929474f267bdf10.tar.bz2
rails-d8537ef1ec1ba51eb08087b4c929474f267bdf10.zip
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".
-rw-r--r--activerecord/test/cases/transactions_test.rb4
1 files changed, 3 insertions, 1 deletions
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'