From f4f6e57e8c2a446a4a600576f0caf0fb8921ba13 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 15 Jul 2008 21:24:00 -0500 Subject: Added Object#metaclass --- activesupport/test/core_ext/object_and_class_ext_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activesupport/test') 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 16f4ab888e..b0a746fdc7 100644 --- a/activesupport/test/core_ext/object_and_class_ext_test.rb +++ b/activesupport/test/core_ext/object_and_class_ext_test.rb @@ -173,6 +173,14 @@ class ObjectTests < Test::Unit::TestCase assert duck.acts_like?(:time) assert !duck.acts_like?(:date) end + + def test_metaclass + string = "Hello" + string.metaclass.instance_eval do + define_method(:foo) { "bar" } + end + assert_equal "bar", string.foo + end end class ObjectInstanceVariableTest < Test::Unit::TestCase -- cgit v1.2.3