Sha256: b17de5c5a79b0ed065b31c2c1461d0e6110c9c27b92b69a9d9df0833de29d148
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
# -*- coding: utf-8 -*- require File.expand_path("../test_helper", __FILE__) class SerializedAttributesTypesTest < ActiveSupport::TestCase test "boolean type encodes nil properly" do type = SerializedAttributes::Boolean.new assert_equal nil, type.encode(nil) end test "boolean type encodes blank string properly" do type = SerializedAttributes::Boolean.new assert_equal nil, type.encode("") end test "boolean type handles strings that look like booleans" do type = SerializedAttributes::Boolean.new assert_equal 0, type.encode("false") assert_equal 1, type.encode("true") end test "boolean type encodes booleans properly" do type = SerializedAttributes::Boolean.new assert_equal 0, type.encode(false) assert_equal 1, type.encode(true) end test "boolean type parses properly" do type = SerializedAttributes::Boolean.new assert_equal false, type.parse(0) assert_equal true, type.parse(1) assert_equal false, type.parse("0") assert_equal true, type.parse("1") assert_equal nil, type.parse("") end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
serializable_attributes-1.1.0 | test/types_test.rb |
serializable_attributes-1.0.0 | test/types_test.rb |
serializable_attributes-0.9.0 | test/types_test.rb |