Sha256: b93e02d7388d94b5b5c062bac46680cb0502d8c57d4135924404e273202b3287
Contents?: true
Size: 1.88 KB
Versions: 3
Compression:
Stored size: 1.88 KB
Contents
require File.expand_path(File.join(*%w[ .. helper ]), File.dirname(__FILE__)) class OptionClass extend Pigeon::OptionAccessor option_accessor :single_option option_accessor :multi1, :multi2 option_accessor :option_with_default, default: :example_default option_accessor :boolean_option, boolean: true self.single_option = :single_option_default end class OptionSubclass < OptionClass end class PigeonOptionAccessorTest < Minitest::Test def test_class_and_instance_chaining assert_equal :single_option_default, OptionClass.single_option instance = OptionClass.new assert_equal :single_option_default, instance.single_option OptionClass.single_option = :new_default assert_equal :new_default, instance.single_option instance.single_option = :override assert_equal :override, instance.single_option assert_equal :new_default, OptionClass.single_option # Reset to defaults for next test OptionClass.single_option = :single_option_default end def test_subclass_inheritance assert_equal :single_option_default, OptionSubclass.single_option OptionSubclass.single_option = :subclass_default assert_equal :subclass_default, OptionSubclass.single_option assert_equal :single_option_default, OptionClass.single_option class_instance = OptionClass.new subclass_instance = OptionSubclass.new assert_equal :subclass_default, subclass_instance.single_option assert_equal :single_option_default, class_instance.single_option # Reset to defaults for next test OptionSubclass.single_option = nil end def test_boolean_option assert_equal nil, OptionClass.multi1 instance = OptionClass.new instance.multi1 = false assert_equal false, instance.multi1 assert_equal nil, OptionClass.multi1 assert_equal nil, instance.multi2 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pigeon-1.0.2 | test/unit/pigeon_option_accessor_test.rb |
pigeon-1.0.1 | test/unit/pigeon_option_accessor_test.rb |
pigeon-1.0.0 | test/unit/pigeon_option_accessor_test.rb |