blob: 7b25a1ef7414cff9f7e8c398606b6257b5728e78 (
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
|
require "cases/helper"
require "active_model/type"
module ActiveModel
class StringTypeTest < ActiveModel::TestCase
test "type casting" do
type = Type::String.new
assert_equal "t", type.cast(true)
assert_equal "f", type.cast(false)
assert_equal "123", type.cast(123)
end
test "immutable strings are not duped coming out" do
s = "foo"
type = Type::ImmutableString.new
assert_same s, type.cast(s)
assert_same s, type.deserialize(s)
end
test "values are duped coming out" do
s = "foo"
type = Type::String.new
assert_not_same s, type.cast(s)
assert_not_same s, type.deserialize(s)
end
end
end
|