Sha256: b29cf3c001b662feb91a877114f354eeeaa83cb8ce20915cbdd81a5998c4191f

Contents?: true

Size: 930 Bytes

Versions: 2

Compression:

Stored size: 930 Bytes

Contents

require 'spec_helper'

module Structural
  module Model
    module TypeCasts
      describe Integer do
        subject { Integer.cast("2") }

        it 'casts strings to integers' do
          expect(subject).to eql(2)
        end
      end

      describe Float do
        subject { Float.cast("2.0") }

        it 'casts strings to floats' do
          expect(subject).to eql(2.0)
        end
      end

      describe Date do
        it 'casts strings to dates' do
          Date.cast("06-06-1983").should eq ::Date.new(1983, 6, 6)
        end
      end

      describe Time do
        it 'casts strings to Times' do
          Time.cast("06-06-1983").should eq ::Time.parse("06-06-1983")
        end
      end

      describe Money do
        it 'ints or strings to Money' do
          Money.cast("500").should eq ::Money.new(5_00)
          Money.cast(500).should eq ::Money.new(5_00)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
structural-0.2.0 spec/lib/structural/model/type_casts_spec.rb
structural-0.1.0 spec/lib/structural/model/type_casts_spec.rb