class ActiveModel::Type::FloatTest
Public Instance Methods
test_changing_float()
click to toggle source
# File activemodel/test/cases/type/float_test.rb, line 22 def test_changing_float type = Type::Float.new assert type.changed?(5.0, 5.0, "5wibble") assert_not type.changed?(5.0, 5.0, "5") assert_not type.changed?(5.0, 5.0, "5.0") assert_not type.changed?(nil, nil, nil) end
test_type_cast_float()
click to toggle source
# File activemodel/test/cases/type/float_test.rb, line 9 def test_type_cast_float type = Type::Float.new assert_equal 1.0, type.cast("1") end
test_type_cast_float_from_invalid_string()
click to toggle source
# File activemodel/test/cases/type/float_test.rb, line 14 def test_type_cast_float_from_invalid_string type = Type::Float.new assert_nil type.cast("") assert_equal 1.0, type.cast("1ignore") assert_equal 0.0, type.cast("bad1") assert_equal 0.0, type.cast("bad") end