Sha256: c04e83c1104fb5654b01f1aab192c9bd658b2527ceab7663f12293049c3fb6be

Contents?: true

Size: 670 Bytes

Versions: 1

Compression:

Stored size: 670 Bytes

Contents

RSpec.describe Dry::Matcher::Case do
  describe "#matches?" do
    it "calls the match proc with the value" do
      kase = described_class.new(match: -> value { value.even? })
      expect(kase.matches?(2)).to be true
      expect(kase.matches?(1)).to be false
    end
  end

  describe "#resolve" do
    it "calls the resolve proc with the value" do
      kase = described_class.new(match: -> * { true }, resolve: resolve = -> value { value.to_s })

      expect(kase.resolve(123)).to eq "123"
    end

    it "defaults to passing through the value" do
      kase = described_class.new(match: -> * { true })
      expect(kase.resolve(123)).to eq 123
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-matcher-0.6.0 spec/unit/case_spec.rb