Sha256: eadc794202a11dfd7d1396600aea01ee9df7fb5d030fe0cd17b79d4f82656737

Contents?: true

Size: 516 Bytes

Versions: 1

Compression:

Stored size: 516 Bytes

Contents

describe "proc type" do
  before do
    class Test::Foo
      extend Dry::Initializer

      param :foo, type: proc { |val| fail(TypeError) unless String === val }
    end
  end

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

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

1 entries across 1 versions & 1 rubygems

Version Path
dry-initializer-0.0.1 spec/dry/proc_type_spec.rb