Sha256: caa59427aa9c09e84bb06fe7fe033a6bc07f59a869967523f6b9d80ad00fa436
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'spec_helper' module Structural module Model module TypeCasts describe Cast do it 'requires a type' do expect { Cast.new(1).type }.to raise_error NotImplementedError end it 'requires a conversion' do expect { Cast.new(1).conversion }.to raise_error NotImplementedError end end describe Date do it 'casts strings to dates' do Date.new("06-06-1983").cast.should eq ::Date.new(1983, 6, 6) end end describe Time do it 'casts strings to Times' do Time.new("06-06-1983").cast.should eq ::Time.parse("06-06-1983") end it 'does nothing if the value is already of the correct type' do time = ::Time.now Time.new(time).cast.should eq time end end describe Money do it 'ints or strings to Money' do Money.new("500").cast.should eq ::Money.new(5_00) Money.new(500).cast.should eq ::Money.new(5_00) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
structural-0.0.1 | spec/lib/structural/model/type_casts_spec.rb |