diff options
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/configurable_test.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/activesupport/test/configurable_test.rb b/activesupport/test/configurable_test.rb index da7729d066..215a6e06b0 100644 --- a/activesupport/test/configurable_test.rb +++ b/activesupport/test/configurable_test.rb @@ -48,6 +48,18 @@ class ConfigurableActiveSupport < ActiveSupport::TestCase assert !instance.respond_to?(:baz=) end + test "configuration accessors can take a default value" do + parent = Class.new do + include ActiveSupport::Configurable + config_accessor :hair_colors, :tshirt_colors do + [:black, :blue, :white] + end + end + + assert_equal [:black, :blue, :white], parent.hair_colors + assert_equal [:black, :blue, :white], parent.tshirt_colors + end + test "configuration hash is available on instance" do instance = Parent.new assert_equal :bar, instance.config.foo @@ -78,7 +90,7 @@ class ConfigurableActiveSupport < ActiveSupport::TestCase test "should raise name error if attribute name is invalid" do assert_raises NameError do - Class.new do + Class.new do include ActiveSupport::Configurable config_accessor "invalid attribute name" end @@ -94,4 +106,4 @@ class ConfigurableActiveSupport < ActiveSupport::TestCase methods = object.public_methods.map(&:to_s) assert !methods.include?(method.to_s), "Expected #{methods.inspect} to not include #{method.to_s.inspect}" end -end
\ No newline at end of file +end |