diff options
Diffstat (limited to 'activemodel/test/cases/attribute_methods_test.rb')
-rw-r--r-- | activemodel/test/cases/attribute_methods_test.rb | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/activemodel/test/cases/attribute_methods_test.rb b/activemodel/test/cases/attribute_methods_test.rb index 67471ed497..9406328d3e 100644 --- a/activemodel/test/cases/attribute_methods_test.rb +++ b/activemodel/test/cases/attribute_methods_test.rb @@ -76,7 +76,15 @@ private end end +class ModelWithoutAttributesMethod + include ActiveModel::AttributeMethods +end + class AttributeMethodsTest < ActiveModel::TestCase + test 'method missing works correctly even if attributes method is not defined' do + assert_raises(NoMethodError) { ModelWithoutAttributesMethod.new.foo } + end + test 'unrelated classes should not share attribute method matchers' do assert_not_equal ModelWithAttributes.send(:attribute_method_matchers), ModelWithAttributes2.send(:attribute_method_matchers) @@ -133,24 +141,6 @@ 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 "original bar", ModelWithAttributes.original_bar - assert_equal "bar", ModelWithAttributes.bar - ModelWithAttributes.define_attr_method(:bar) - assert !ModelWithAttributes.bar - end - - test '#define_attr_method generates attribute method with invalid identifier characters' do - 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 - test '#alias_attribute works with attributes with spaces in their names' do ModelWithAttributesWithSpaces.define_attribute_methods([:'foo bar']) ModelWithAttributesWithSpaces.alias_attribute(:'foo_bar', :'foo bar') |