Sha256: b151bc3329a4033bfb0015ff2515e87e8ab73afc4e9c640380ae29c858f03c40

Contents?: true

Size: 660 Bytes

Versions: 1

Compression:

Stored size: 660 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: -> 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.7.0 spec/unit/case_spec.rb