blob: 92e5aebfb7b9f137644193f4f476275673023aa2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
require "cases/helper"
require "active_model/type"
module ActiveModel
module Type
class BooleanTest < ActiveModel::TestCase
def test_type_cast_boolean
type = Type::Boolean.new
assert type.cast("").nil?
assert type.cast(nil).nil?
assert type.cast(true)
assert type.cast(1)
assert type.cast("1")
assert type.cast("t")
assert type.cast("T")
assert type.cast("true")
assert type.cast("TRUE")
assert type.cast("on")
assert type.cast("ON")
assert type.cast(" ")
assert type.cast("\u3000\r\n")
assert type.cast("\u0000")
assert type.cast("SOMETHING RANDOM")
# explicitly check for false vs nil
assert_equal false, type.cast(false)
assert_equal false, type.cast(0)
assert_equal false, type.cast("0")
assert_equal false, type.cast("f")
assert_equal false, type.cast("F")
assert_equal false, type.cast("false")
assert_equal false, type.cast("FALSE")
assert_equal false, type.cast("off")
assert_equal false, type.cast("OFF")
end
end
end
end
|