Sha256: aee91ba4d03a119fa73c58ebe92ed0369b38b40eb38a0546e8a5806ee3dc1ed9
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
require 'spec_helper' module OrElse describe Just do subject(:just) { Just.new(val) } context 'when wrapping 1' do specify { expect(Just(1)).to be_a Just } end describe '#value' do context 'when initialized with 1' do let(:val) { 1 } specify { expect(just.value).to eq 1 } end context 'when initialized with "foo"' do let(:val) { 'foo' } specify { expect(just.value).to eq 'foo' } end end describe '#map' do context 'when initialized with 1' do let(:val) { 1 } specify { expect { |b| just.map(&b) }.to yield_with_args(Just) } it 'yields a Just with the value 1' do just.map { |j| expect(j.value).to eq 1 } end end context 'when initialized with "foo"' do let(:val) { 'foo' } specify { expect { |b| just.map(&b) }.to yield_with_args(Just) } it 'yields a Just with the value "foo"' do just.map { |j| expect(j.value).to eq 'foo' } end end end describe '#flat_map' do context 'when initialized with 1' do let(:val) { 1 } specify { expect { |b| just.flat_map(&b) }.to yield_with_args(1) } end context 'when initialized with "foo"' do let(:val) { 'foo' } specify { expect { |b| just.flat_map(&b) }.to yield_with_args('foo') } end end describe '#empty?' do let(:val) { 1 } specify { expect(just.empty?).to be_false } end describe '#exists?' do let(:val) { 1 } specify { expect(just.exists?).to be_true } end describe '#or_else' do let(:val) { 1 } specify { expect(just.or_else).to eq just } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
or_else-0.0.1 | spec/or_else/just_spec.rb |