aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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')