diff options
author | Agis- <corestudiosinc@gmail.com> | 2013-04-06 10:57:13 +0300 |
---|---|---|
committer | Agis- <corestudiosinc@gmail.com> | 2013-04-06 20:34:13 +0300 |
commit | 941986c7db3f4abaed6f859a4d7b93e6445039c4 (patch) | |
tree | 55ef11bf862c4615877a68c37998c7c40d00e8bd /activesupport/test/core_ext/class | |
parent | ec8f59ca530316a14672686611c629abc4112950 (diff) | |
download | rails-941986c7db3f4abaed6f859a4d7b93e6445039c4.tar.gz rails-941986c7db3f4abaed6f859a4d7b93e6445039c4.tar.bz2 rails-941986c7db3f4abaed6f859a4d7b93e6445039c4.zip |
Add option to Class#class_attribute for skipping the query method
Diffstat (limited to 'activesupport/test/core_ext/class')
-rw-r--r-- | activesupport/test/core_ext/class/attribute_test.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/activesupport/test/core_ext/class/attribute_test.rb b/activesupport/test/core_ext/class/attribute_test.rb index 1c3ba8a7a0..e7a1334db3 100644 --- a/activesupport/test/core_ext/class/attribute_test.rb +++ b/activesupport/test/core_ext/class/attribute_test.rb @@ -27,7 +27,7 @@ class ClassAttributeTest < ActiveSupport::TestCase assert_equal 1, Class.new(@sub).setting end - test 'query method' do + test 'predicate method' do assert_equal false, @klass.setting? @klass.setting = 1 assert_equal true, @klass.setting? @@ -48,7 +48,7 @@ class ClassAttributeTest < ActiveSupport::TestCase assert_equal 1, object.setting end - test 'instance query' do + test 'instance predicate' do object = @klass.new assert_equal false, object.setting? object.setting = 1 @@ -73,6 +73,11 @@ class ClassAttributeTest < ActiveSupport::TestCase assert_raise(NoMethodError) { object.setting = 'boom' } end + test 'disabling instance predicate' do + object = Class.new { class_attribute :setting, instance_predicate: false }.new + assert_raise(NoMethodError) { object.setting? } + end + test 'works well with singleton classes' do object = @klass.new object.singleton_class.setting = 'foo' |