Sha256: 9506896698c151aaf911280d2d0f365d0de5e2cf9a6aba1d7e51319e487d869c

Contents?: true

Size: 607 Bytes

Versions: 4

Compression:

Stored size: 607 Bytes

Contents

require 'spec_helper'
module Alf
  describe "Support#coerce" do

    it 'coerces integers without trouble' do
      Support.coerce("12", Integer).should eql(12)
    end

    it 'coerces Time without trouble' do
      Support.coerce("2012-05-11 12:00:00.000000+0200", Time).should be_a(Time)
    end

    it 'coerces DateTime without trouble' do
      Support.coerce("2012-05-11 12:00:00.000000+0200", DateTime).should be_a(DateTime)
    end

    it 'should raise a TypeError in case of error' do
      lambda{ 
        Support.coerce("abc", Integer)
      }.should raise_error(TypeError)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-support/test_coerce.rb
alf-core-0.14.0 spec/unit/alf-support/test_coerce.rb
alf-core-0.13.1 spec/unit/alf-support/test_coerce.rb
alf-core-0.13.0 spec/unit/alf-support/test_coerce.rb