Sha256: 6bb3ddab23f1c284f894dae3b476ac1b9976966a3cdf636263b12fb0a814fbda
Contents?: true
Size: 1.99 KB
Versions: 3
Compression:
Stored size: 1.99 KB
Contents
require File.dirname(__FILE__) + '/../spec_helper' include FastCache describe Maybe, '.nothing' do it 'should return an object with nothing' do Maybe.nothing.should be_nothing end end describe Maybe, '.just' do it 'should return an object with the passed value' do Maybe.just(42).value.should == 42 end end describe Maybe, '#anything?' do it 'should return true if there is a value' do Maybe.just(42).should be_anything Maybe.just(nil).should be_anything end it 'should return false if there is no value' do Maybe.nothing.should_not be_anything end end describe Maybe, '#nothing?' do it 'should return false if there is a value' do Maybe.just(42).should_not be_nothing Maybe.just(nil).should_not be_nothing end it 'should return true if there is no value' do Maybe.nothing.should be_nothing end end describe Maybe, 'getting and setting wrapped values' do it 'should allow setting a value on nothing' do [:hello, nil, false, true].each do |val| what = Maybe.nothing what.value = val what.should be_anything end end it 'should should replace existing values' do [:hello, nil, false, true].each do |val| what = Maybe.just(42) what.value = val what.value.should == val end end end describe Maybe, '#join' do it 'should keep nothing if nothing' do Maybe.nothing.join(Maybe.nothing).should be_nothing Maybe.nothing.join(Maybe.just(42)).should be_nothing end it 'should keep the new anything if anything' do what = Maybe.just(42).join(Maybe.just(43)) what.should be_anything what.value.should == 43 end it 'should become nothing if anything is passed nothing' do Maybe.just(42).join(Maybe.nothing).should be_nothing end end describe Maybe, '#void' do it 'should make an object with anything into one with nothing' do Maybe.just(42).void.should be_nothing end it 'should not let nothing remain nothing' do Maybe.nothing.void.should be_nothing end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
binary42-fastcache-0.1 | spec/util/maybe_spec.rb |
binary42-fastcache-0.2 | spec/util/maybe_spec.rb |
binary42-fastcache-0.3 | spec/util/maybe_spec.rb |