From c834a751d2acbd55b580cbba2e96dd29c5d9a452 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 16 Mar 2011 21:19:35 -0300 Subject: define_attr_method correctly defines methods with invalid identifiers --- activemodel/test/cases/attribute_methods_test.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activemodel/test') diff --git a/activemodel/test/cases/attribute_methods_test.rb b/activemodel/test/cases/attribute_methods_test.rb index 13f29a8fd9..5cf905bc1f 100644 --- a/activemodel/test/cases/attribute_methods_test.rb +++ b/activemodel/test/cases/attribute_methods_test.rb @@ -7,7 +7,7 @@ class ModelWithAttributes class << self define_method(:bar) do - 'bar' + 'original bar' end end @@ -49,7 +49,7 @@ class ModelWithWeirdNamesAttributes class << self define_method(:'c?d') do - 'c?d' + 'original c?d' end end @@ -102,6 +102,7 @@ class AttributeMethodsTest < ActiveModel::TestCase ModelWithAttributes.define_attr_method(:bar, 'bar') assert_respond_to ModelWithAttributes, :bar + assert_equal "original bar", ModelWithAttributes.original_bar assert_equal "bar", ModelWithAttributes.bar end @@ -109,6 +110,7 @@ class AttributeMethodsTest < ActiveModel::TestCase ModelWithWeirdNamesAttributes.define_attr_method(:'c?d', 'c?d') assert_respond_to ModelWithWeirdNamesAttributes, :'c?d' + assert_equal "original c?d", ModelWithWeirdNamesAttributes.send('original_c?d') assert_equal "c?d", ModelWithWeirdNamesAttributes.send('c?d') end -- cgit v1.2.3