diff options
author | Genadi Samokovarov <gsamokovarov@gmail.com> | 2013-06-30 16:45:32 +0300 |
---|---|---|
committer | Genadi Samokovarov <gsamokovarov@gmail.com> | 2013-12-02 23:57:20 +0200 |
commit | 7dfbd91b0780fbd6a1dd9bfbc176e10894871d2d (patch) | |
tree | 576c89e85c523b18fad887dcb3d329eaee97e2bf /activesupport/test/core_ext/class/attribute_accessor_test.rb | |
parent | 152edcc16b3f4da967fb7765d4abff5bc93c3626 (diff) | |
download | rails-7dfbd91b0780fbd6a1dd9bfbc176e10894871d2d.tar.gz rails-7dfbd91b0780fbd6a1dd9bfbc176e10894871d2d.tar.bz2 rails-7dfbd91b0780fbd6a1dd9bfbc176e10894871d2d.zip |
Unify cattr and mattr accessors declarations
Diffstat (limited to 'activesupport/test/core_ext/class/attribute_accessor_test.rb')
-rw-r--r-- | activesupport/test/core_ext/class/attribute_accessor_test.rb | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/activesupport/test/core_ext/class/attribute_accessor_test.rb b/activesupport/test/core_ext/class/attribute_accessor_test.rb deleted file mode 100644 index 3bc948f3a6..0000000000 --- a/activesupport/test/core_ext/class/attribute_accessor_test.rb +++ /dev/null @@ -1,70 +0,0 @@ -require 'abstract_unit' -require 'active_support/core_ext/class/attribute_accessors' - -class ClassAttributeAccessorTest < ActiveSupport::TestCase - def setup - @class = Class.new do - cattr_accessor :foo - cattr_accessor :bar, :instance_writer => false - cattr_reader :shaq, :instance_reader => false - cattr_accessor :camp, :instance_accessor => false - cattr_accessor(:defa) { 'default_accessor_value' } - cattr_reader(:defr) { 'default_reader_value' } - cattr_writer(:defw) { 'default_writer_value' } - end - @object = @class.new - end - - def test_should_use_mattr_default - assert_nil @class.foo - assert_nil @object.foo - end - - def test_should_set_mattr_value - @class.foo = :test - assert_equal :test, @object.foo - - @object.foo = :test2 - assert_equal :test2, @class.foo - end - - def test_should_not_create_instance_writer - assert_respond_to @class, :foo - assert_respond_to @class, :foo= - assert_respond_to @object, :bar - assert !@object.respond_to?(:bar=) - end - - def test_should_not_create_instance_reader - assert_respond_to @class, :shaq - assert !@object.respond_to?(:shaq) - end - - def test_should_not_create_instance_accessors - assert_respond_to @class, :camp - assert !@object.respond_to?(:camp) - assert !@object.respond_to?(:camp=) - end - - def test_should_raise_name_error_if_attribute_name_is_invalid - exception = assert_raises NameError do - Class.new do - cattr_reader "1nvalid" - end - end - assert_equal "invalid class attribute name: 1nvalid", exception.message - - exception = assert_raises NameError do - Class.new do - cattr_writer "1nvalid" - end - end - assert_equal "invalid class attribute name: 1nvalid", exception.message - end - - def test_should_use_default_value_if_block_passed - assert_equal 'default_accessor_value', @class.defa - assert_equal 'default_reader_value', @class.defr - assert_equal 'default_writer_value', @class.class_variable_get('@@defw') - end -end |