Sha256: 15cde34904adb43df0772013f2c50d19a3660f0e8f8506db98e7691b7074f930
Contents?: true
Size: 927 Bytes
Versions: 4
Compression:
Stored size: 927 Bytes
Contents
# frozen_string_literal: true RSpec.describe Fear::PartialFunction::EMPTY do describe "#defined?" do subject { described_class.defined_at?(42) } it { is_expected.to be(false) } end describe "#call" do subject { -> { described_class.(42) } } it { is_expected.to raise_error(Fear::MatchError, "partial function not defined at: 42") } end describe "#call_or_else" do subject { described_class.call_or_else(42, &default) } let(:default) { ->(x) { "default: #{x}" } } it { is_expected.to eq("default: 42") } end describe "#and_then" do subject { described_class.and_then { |_x| "then" } } it { is_expected.to eq(described_class) } end describe "#or_else" do subject { described_class.or_else(other) } let(:other) { Fear.case(proc { true }) { "other" } } it { is_expected.to eq(other) } end it { is_expected.to be_kind_of(Fear::PartialFunction) } end
Version data entries
4 entries across 4 versions & 1 rubygems