aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-12-29 19:43:07 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-12-29 19:43:07 +0000
commit20d29b379767713c64397a28105d1b74f0f36f5f (patch)
tree4f15147e5e0198d48981fb0835e33f583a92f3c5 /activesupport
parent1bb208d7e5c7147ed12e1e2fd0cd24b5054eceac (diff)
downloadrails-20d29b379767713c64397a28105d1b74f0f36f5f.tar.gz
rails-20d29b379767713c64397a28105d1b74f0f36f5f.tar.bz2
rails-20d29b379767713c64397a28105d1b74f0f36f5f.zip
Ruby 1.9 compat: introduce ActiveSupport::FrozenObjectError normalize TypeError vs RuntimeError handling. Closes #10645 [Frederick Cheung]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8510 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/exception.rb8
-rw-r--r--activesupport/test/core_ext/exception_test.rb4
2 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/exception.rb b/activesupport/lib/active_support/core_ext/exception.rb
index 14cd577066..57c8568334 100644
--- a/activesupport/lib/active_support/core_ext/exception.rb
+++ b/activesupport/lib/active_support/core_ext/exception.rb
@@ -1,3 +1,11 @@
+module ActiveSupport
+ if RUBY_VERSION >= '1.9'
+ FrozenObjectError = RuntimeError
+ else
+ FrozenObjectError = TypeError
+ end
+end
+
class Exception # :nodoc:
def clean_message
Pathname.clean_within message
diff --git a/activesupport/test/core_ext/exception_test.rb b/activesupport/test/core_ext/exception_test.rb
index b1ea564a0c..6a60c91380 100644
--- a/activesupport/test/core_ext/exception_test.rb
+++ b/activesupport/test/core_ext/exception_test.rb
@@ -61,4 +61,8 @@ class ExceptionExtTests < Test::Unit::TestCase
assert_kind_of Exception, e
assert_equal [], e.application_backtrace
end
+
+ def test_frozen_error
+ assert_raise(ActiveSupport::FrozenObjectError) { "foo".freeze.gsub!(/oo/,'aa') }
+ end
end