Sha256: 139da2681518061f4783fac93a9d5c0f0cbcdc9f20806770381ab346c202201c

Contents?: true

Size: 484 Bytes

Versions: 10

Compression:

Stored size: 484 Bytes

Contents

describe "custom initializer" do
  before do
    class Test::Foo
      extend Dry::Initializer::Mixin

      param :bar

      def initialize(*args)
        super
        @bar *= 3
      end
    end

    class Test::Baz < Test::Foo
      param :qux

      def initialize(*args)
        super
        @qux += 1
      end
    end
  end

  it "reloads the initializer" do
    baz = Test::Baz.new(5, 5)

    expect(baz.bar).to eq 15 # 5 * 3
    expect(baz.qux).to eq 6  # 5 + 1
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dry-initializer-1.4.1 spec/custom_initializer_spec.rb
dry-initializer-1.4.0 spec/custom_initializer_spec.rb
dry-initializer-1.3.0 spec/custom_initializer_spec.rb
dry-initializer-1.2.0 spec/custom_initializer_spec.rb
dry-initializer-1.1.3 spec/custom_initializer_spec.rb
dry-initializer-1.1.2 spec/custom_initializer_spec.rb
dry-initializer-1.1.1 spec/custom_initializer_spec.rb
dry-initializer-1.1.0 spec/custom_initializer_spec.rb
dry-initializer-1.0.0 spec/custom_initializer_spec.rb
dry-initializer-0.11.0 spec/custom_initializer_spec.rb