Sha256: a89e8824e68b5f7396b71463c64a3a96808e6e52342621638560e43a600e47cf

Contents?: true

Size: 523 Bytes

Versions: 2

Compression:

Stored size: 523 Bytes

Contents

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

      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

2 entries across 2 versions & 1 rubygems

Version Path
dry-initializer-0.1.1 spec/dry/proc_type_spec.rb
dry-initializer-0.1.0 spec/dry/proc_type_spec.rb