aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/attribute_methods_test.rb
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2011-03-16 21:08:02 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2011-03-16 21:08:02 -0300
commitfda45f4fc493f5596375199fefe854df24b1ffbf (patch)
treee62bd5f49f42d4f9d3ee537c591ec464e3dce300 /activemodel/test/cases/attribute_methods_test.rb
parent52320775175275379b1b215274dc26bed7f43634 (diff)
downloadrails-fda45f4fc493f5596375199fefe854df24b1ffbf.tar.gz
rails-fda45f4fc493f5596375199fefe854df24b1ffbf.tar.bz2
rails-fda45f4fc493f5596375199fefe854df24b1ffbf.zip
Add a define_attr_method test
Diffstat (limited to 'activemodel/test/cases/attribute_methods_test.rb')
-rw-r--r--activemodel/test/cases/attribute_methods_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activemodel/test/cases/attribute_methods_test.rb b/activemodel/test/cases/attribute_methods_test.rb
index 3df76295cf..13f29a8fd9 100644
--- a/activemodel/test/cases/attribute_methods_test.rb
+++ b/activemodel/test/cases/attribute_methods_test.rb
@@ -5,6 +5,12 @@ class ModelWithAttributes
attribute_method_suffix ''
+ class << self
+ define_method(:bar) do
+ 'bar'
+ end
+ end
+
def attributes
{ :foo => 'value of foo' }
end
@@ -92,6 +98,13 @@ class AttributeMethodsTest < ActiveModel::TestCase
assert_equal "value of foo bar", ModelWithAttributesWithSpaces.new.send(:'foo bar')
end
+ test '#define_attr_method generates attribute method' do
+ ModelWithAttributes.define_attr_method(:bar, 'bar')
+
+ assert_respond_to ModelWithAttributes, :bar
+ assert_equal "bar", ModelWithAttributes.bar
+ end
+
test '#define_attr_method generates attribute method with invalid identifier characters' do
ModelWithWeirdNamesAttributes.define_attr_method(:'c?d', 'c?d')