Sha256: b00975f23086713b626e5358be51d246a1cbe98cac01926871d6c478697299a4

Contents?: true

Size: 596 Bytes

Versions: 14

Compression:

Stored size: 596 Bytes

Contents

require 'minitest_helper'

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

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

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rasti-form-3.1.2 spec/types/integer_spec.rb
rasti-form-3.1.1 spec/types/integer_spec.rb
rasti-form-3.1.0 spec/types/integer_spec.rb
rasti-form-3.0.0 spec/types/integer_spec.rb
rasti-form-2.2.0 spec/types/integer_spec.rb
rasti-form-2.1.0 spec/types/integer_spec.rb
rasti-form-2.0.0 spec/types/integer_spec.rb
rasti-form-1.1.1 spec/types/integer_spec.rb
rasti-form-1.1.0 spec/types/integer_spec.rb
rasti-form-1.0.3 spec/types/integer_spec.rb
rasti-form-1.0.2 spec/types/integer_spec.rb
rasti-form-1.0.1 spec/types/integer_spec.rb
rasti-form-1.0.0 spec/types/integer_spec.rb
rasti-form-0.1.0 spec/types/integer_spec.rb