aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2010-02-25 09:32:29 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2010-02-25 09:32:29 -0800
commitf7b0a857e97304a5daeb47313759b9bf0d7e2fc9 (patch)
tree81bda0d86cc1d22e3e8c50e5e852d200aec7be57 /activesupport/test/core_ext
parent6b12d74026808a3014f1dff34481006a96e0f18f (diff)
downloadrails-f7b0a857e97304a5daeb47313759b9bf0d7e2fc9.tar.gz
rails-f7b0a857e97304a5daeb47313759b9bf0d7e2fc9.tar.bz2
rails-f7b0a857e97304a5daeb47313759b9bf0d7e2fc9.zip
Use Object#singleton_class instead of #metaclass. Prefer Ruby's choice.
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/object_and_class_ext_test.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/activesupport/test/core_ext/object_and_class_ext_test.rb b/activesupport/test/core_ext/object_and_class_ext_test.rb
index f31e7774e9..00c59d84b8 100644
--- a/activesupport/test/core_ext/object_and_class_ext_test.rb
+++ b/activesupport/test/core_ext/object_and_class_ext_test.rb
@@ -89,7 +89,7 @@ class ClassExtTest < Test::Unit::TestCase
end
end
-class ObjectTests < Test::Unit::TestCase
+class ObjectTests < ActiveSupport::TestCase
class DuckTime
def acts_like_time?
true
@@ -119,12 +119,16 @@ class ObjectTests < Test::Unit::TestCase
assert !duck.acts_like?(:date)
end
- def test_metaclass
- string = "Hello"
- string.metaclass.instance_eval do
- define_method(:foo) { "bar" }
+ def test_singleton_class
+ o = Object.new
+ assert_equal class << o; self end, o.singleton_class
+ end
+
+ def test_metaclass_deprecated
+ o = Object.new
+ assert_deprecated /use singleton_class instead/ do
+ assert_equal o.singleton_class, o.metaclass
end
- assert_equal "bar", string.foo
end
end