Sha256: 057d8299eec9e9eefc8380ca97cc38321bc09205387472343fcb5ea1a4b33697

Contents?: true

Size: 832 Bytes

Versions: 1

Compression:

Stored size: 832 Bytes

Contents

require 'rspec'
require_relative '../lib/totally_lazy'

describe 'Type Check' do

  it 'should raise UnsupportedTypeException exception if value is not of specified type' do
    expect(Type.check(1, Fixnum)).to eq(1)
    expect { Type.check('1', Fixnum) }.to raise_error(UnsupportedTypeException)
  end

  it 'should raise UnsupportedTypeException exception if value does not respond to specified method' do
     expect(Type.responds(1, :even?)).to eq(1)
     expect { Type.responds('1', :even?) }.to raise_error(UnsupportedTypeException)
  end

  it 'should raise UnsupportedTypeException exception if values do not respond to specified method' do
     expect(Type.responds_all(sequence(1,2,3), :to_s)).to eq([1,2,3])
     expect { Type.responds_all(sequence(1,2,3), :is_cool) }.to raise_error(UnsupportedTypeException)
   end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
totally_lazy-0.0.4 spec/type_check_spec.rb