diff options
author | Dmitry Plashchynski <plashchynski@gmail.com> | 2012-03-30 15:35:35 +0300 |
---|---|---|
committer | Dmitry Plashchynski <plashchynski@gmail.com> | 2012-03-30 15:45:46 +0300 |
commit | 96b951ce24651aa1527b16f4ec293c716757e8b0 (patch) | |
tree | f4f4ec4aae3fe22d2a459b51ba18aeefe6ad1bd0 /activesupport/test/core_ext/class | |
parent | 84338aab908f87cc830c15259dc31798d3ae150d (diff) | |
download | rails-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/class')
-rw-r--r-- | activesupport/test/core_ext/class/attribute_accessor_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/class/attribute_accessor_test.rb b/activesupport/test/core_ext/class/attribute_accessor_test.rb index 3822e7af66..8d827f054e 100644 --- a/activesupport/test/core_ext/class/attribute_accessor_test.rb +++ b/activesupport/test/core_ext/class/attribute_accessor_test.rb @@ -42,4 +42,18 @@ class ClassAttributeAccessorTest < 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 + cattr_reader "invalid attribute name" + end + end + + assert_raises NameError do + Class.new do + cattr_writer "invalid attribute name" + end + end + end end |