Sha256: 78a53f51926a737fd1e193590e101a26cb609751558862ad62092e83bf899e2d

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 Bytes

Contents

RSpec.describe Fear::OptionPatternMatch do
  include Fear::Option::Mixin

  context 'Some' do
    let(:matcher) do
      described_class.new do |m|
        m.some(:even?) { |x| "#{x} is even" }
        m.some(:odd?) { |x| "#{x} is odd" }
      end
    end

    it do
      expect(matcher.call(Some(4))).to eq('4 is even')
      expect(matcher.call(Some(3))).to eq('3 is odd')
      expect do
        matcher.call(None())
      end.to raise_error(Fear::MatchError)
    end
  end

  context 'None' do
    let(:matcher) do
      described_class.new do |m|
        m.none { 'nil' }
      end
    end

    it do
      expect(matcher.call(None())).to eq('nil')
      expect do
        matcher.call(Some(3))
      end.to raise_error(Fear::MatchError)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fear-0.11.0 spec/fear/option_pattern_match_spec.rb