aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/type/float_test.rb
blob: 2e34f57f7ead4eaae62102ecebe0e885284aa12b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require "cases/helper"
require "active_model/type"

module ActiveModel
  module Type
    class FloatTest < ActiveModel::TestCase
      def test_type_cast_float
        type = Type::Float.new
        assert_equal 1.0, type.cast("1")
      end

      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
    end
  end
end