Sha256: ab3f672b36c8da1c7ce871313c1d8426dc92af24f5b5d579d5388581a553150b

Contents?: true

Size: 649 Bytes

Versions: 2

Compression:

Stored size: 649 Bytes

Contents

require 'minitest_helper'

describe Rasti::Types::Float do

  it 'nil -> nil' do
    Rasti::Types::Float.cast(nil).must_equal nil
  end

  [100, '200', Time.now,2.0,"12.5"].each do |value|
    it "#{value.inspect} -> #{value.to_i}" do
      Rasti::Types::Float.cast(value).must_equal value.to_f
    end
  end

  ['text', :symbol, '999'.to_sym, [1,2], {a: 1, b: 2}, Object.new, "1.", ".2","."].each do |value|
    it "#{value.inspect} -> CastError" do
      error = proc { Rasti::Types::Float.cast(value) }.must_raise Rasti::Types::CastError
      error.message.must_equal "Invalid cast: #{as_string(value)} -> Rasti::Types::Float"
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rasti-types-2.0.1 spec/float_spec.rb
rasti-types-2.0.0 spec/float_spec.rb