aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/module/attribute_accessor_test.rb
diff options
context:
space:
mode:
authorDmitry Plashchynski <plashchynski@gmail.com>2012-03-30 15:35:35 +0300
committerDmitry Plashchynski <plashchynski@gmail.com>2012-03-30 15:45:46 +0300
commit96b951ce24651aa1527b16f4ec293c716757e8b0 (patch)
treef4f4ec4aae3fe22d2a459b51ba18aeefe6ad1bd0 /activesupport/test/core_ext/module/attribute_accessor_test.rb
parent84338aab908f87cc830c15259dc31798d3ae150d (diff)
downloadrails-96b951ce24651aa1527b16f4ec293c716757e8b0.tar.gz
rails-96b951ce24651aa1527b16f4ec293c716757e8b0.tar.bz2
rails-96b951ce24651aa1527b16f4ec293c716757e8b0.zip
validate attribute names in class and module attribute accessors
Diffstat (limited to 'activesupport/test/core_ext/module/attribute_accessor_test.rb')
-rw-r--r--activesupport/test/core_ext/module/attribute_accessor_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module/attribute_accessor_test.rb b/activesupport/test/core_ext/module/attribute_accessor_test.rb
index 6a2ad2f241..a577f90bdd 100644
--- a/activesupport/test/core_ext/module/attribute_accessor_test.rb
+++ b/activesupport/test/core_ext/module/attribute_accessor_test.rb
@@ -44,4 +44,18 @@ class ModuleAttributeAccessorTest < ActiveSupport::TestCase
assert !@object.respond_to?(:camp)
assert !@object.respond_to?(:camp=)
end
+
+ def test_should_raise_name_error_if_attribute_name_is_invalid
+ assert_raises NameError do
+ Class.new do
+ mattr_reader "invalid attribute name"
+ end
+ end
+
+ assert_raises NameError do
+ Class.new do
+ mattr_writer "invalid attribute name"
+ end
+ end
+ end
end