Sha256: f005256a7634b056cb3e5e84fbeca5dbc64c9b522cdd8ce8b149c9df23149982

Contents?: true

Size: 945 Bytes

Versions: 4

Compression:

Stored size: 945 Bytes

Contents

module Tests
  module Shared
    module Defaults
      def self.included(base)
        base.setup_with :defaults do |c|
          c.p2 = 23

          c.p3.p4 = 'CONFIGURED P3P4'

          c.module = -> { 'MODULE' }
        end
      end

      def test_property
        assert_equal 23, @configuration.p2
      end

      def test_property_with_default
        assert_equal 'P1', @configuration.p1
      end

      def test_overwritten_property
        assert_equal 'MODULE', @configuration.module.call
      end

      def test_overwritten_nested_property
        assert_equal 'CONFIGURED P3P4', @configuration.p3.p4
      end

      def test_nested_property_with_default
        assert_equal({ hash: :hash }, @configuration.p3.p5.p7)
      end

      def test_keywords_defaults
        assert_equal :class, @configuration.class
      end

      def test_no_default_no_write
        assert_nil @configuration.puts
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
configurations-2.2.2 test/configurations/shared/defaults.rb
configurations-2.2.1 test/configurations/shared/defaults.rb
configurations-2.2.0 test/configurations/shared/defaults.rb
configurations-2.0.0 test/configurations/shared/defaults.rb