Add a define_attr_method test
This commit is contained in:
parent
5232077517
commit
fda45f4fc4
@ -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')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user