Sha256: 62849de5c48162a012147c727a222e8db5da67b14be6d241c8fc5d2a0d95cebc

Contents?: true

Size: 693 Bytes

Versions: 6

Compression:

Stored size: 693 Bytes

Contents

describe "plain type constraint" do
  before do
    class Test::Foo
      extend Dry::Initializer::Mixin

      param :foo, type: String
    end
  end

  context "in case of mismatch" do
    subject { Test::Foo.new :foo }

    it "raises TypeError" do
      expect { subject }.to raise_error TypeError, /:foo/
    end
  end

  context "in case of match" do
    subject { Test::Foo.new "foo" }

    it "completes the initialization" do
      expect { subject }.not_to raise_error
    end
  end

  context "in case of soft match" do
    subject { Test::Foo.new Class.new(String).new "foo" }

    it "completes the initialization" do
      expect { subject }.not_to raise_error
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dry-initializer-0.3.3 spec/dry/plain_type_constraint_spec.rb
dry-initializer-0.3.2 spec/dry/plain_type_constraint_spec.rb
dry-initializer-0.3.1 spec/dry/plain_type_constraint_spec.rb
dry-initializer-0.3.0 spec/dry/plain_type_constraint_spec.rb
dry-initializer-0.2.1 spec/dry/plain_type_constraint_spec.rb
dry-initializer-0.2.0 spec/dry/plain_type_constraint_spec.rb