Sha256: 588517f7ef659d616bb5f81f895eb0472ff69ae2959abf1413779589a83bdbbd
Contents?: true
Size: 1.18 KB
Versions: 17
Compression:
Stored size: 1.18 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/helper') require 'property_sets/casting' class TestCasting < ActiveSupport::TestCase context "Casting#read" do should "return nil when given value nil regardless of type" do assert_equal nil, PropertySets::Casting.read(:string, nil) assert_equal nil, PropertySets::Casting.read(:hello, nil) end should "leave serialized data alone" do assert_equal [1,2,3], PropertySets::Casting.read(:serialized, [1, 2, 3]) end end context "Casting#write" do should "return nil when given value nil regardless of type" do assert_equal nil, PropertySets::Casting.write(:string, nil) assert_equal nil, PropertySets::Casting.write(:hello, nil) end should "convert time instances to UTC" do time = Time.now.in_time_zone("CET") assert PropertySets::Casting.write(:datetime, time) =~ /UTC$/ end should "convert integers to strings" do assert_equal "123", PropertySets::Casting.write(:integer, 123) end should "leave serialized data alone for the record to deal with" do a = [123] assert_equal a, PropertySets::Casting.write(:serialized, a) end end end
Version data entries
17 entries across 17 versions & 1 rubygems