Sha256: 230dec1c077dfcbde0169096949f9b0db02132c578ab341caad538014fa7db39

Contents?: true

Size: 570 Bytes

Versions: 3

Compression:

Stored size: 570 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Fear::Either do
  describe "#matcher" do
    subject(:result) { matcher.(value) }

    let(:matcher) do
      described_class.matcher do |m|
        m.right { |x| "right of #{x}" }
        m.left { |x| "left of #{x}" }
      end
    end

    context "when matches the right branch" do
      let(:value) { Fear.right(42) }

      it { is_expected.to eq("right of 42") }
    end

    context "when matches the left branch" do
      let(:value) { Fear.left(42) }

      it { is_expected.to eq("left of 42") }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fear-3.0.0 spec/fear/either_spec.rb
fear-2.0.1 spec/fear/either_spec.rb
fear-2.0.0 spec/fear/either_spec.rb