Sha256: 9b862602ac75dd5bf48dc5c813b50d8546a6e0134dd3ea5f01617e5fb0a79f6d

Contents?: true

Size: 583 Bytes

Versions: 1

Compression:

Stored size: 583 Bytes

Contents

require 'spec_helper'

describe Left do

  subject { Left[:foo] }

  it { should be_left }
  it { should_not be_right }

  it 'has a value on the left hand side' do
    expect(subject.left.value).to eq :foo
  end

  it 'does not have a value on the right hand side' do
    expect { subject.right.value }.to raise_error Option::ValueOfNoneError
  end

  it 'can be pattern matched against' do
    expect(
      subject.match do |m|
        m.left  { |v| "It is a left: #{v}"     }
        m.right { |v| "It is not a left: #{v}"  }
      end
    ).to eq "It is a left: foo"
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
either-0.0.2 spec/lib/left_spec.rb