Sha256: 7cbe55472583394e7b5e516a71f82fcffcc1a135c00f4342b3de2f431ace0681

Contents?: true

Size: 594 Bytes

Versions: 6

Compression:

Stored size: 594 Bytes

Contents

require "dry-types"

describe "Dry type constraint" do
  before do
    module Test::Types
      include Dry::Types.module
    end

    class Test::Foo
      extend Dry::Initializer::Mixin
      param :foo, type: Test::Types::Strict::String
    end
  end

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

    it "raises TypeError" do
      expect { subject }.to raise_error TypeError, /1/
    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
end

Version data entries

6 entries across 6 versions & 1 rubygems

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