test/yao/resources/test_base.rb in yao-0.20.0 vs test/yao/resources/test_base.rb in yao-0.21.0
- old
+ new
@@ -21,9 +21,19 @@
base = Yao::Resources::Base.new({"empty" => ""})
base.class.map_attribute_to_resource empty: NilClass
assert_equal(nil, base.empty)
end
+ def test_map_attributes_to_time
+ base = Yao::Resources::Base.new("updated_at" => "2015-01-01T00:00:00Z")
+ base.class.map_attributes_to_time :updated_at
+ assert_equal(Time.parse("2015-01-01T00:00:00Z"), base.updated_at)
+
+ base = Yao::Resources::Base.new("updated_at" => nil)
+ base.class.map_attributes_to_time :updated_at
+ assert(base.updated_at.nil?)
+ end
+
def test_update
stub(Yao::Resources::Base).update('foo', {name: 'BAR'}) { Yao::Resources::Base.new('id' => 'foo', 'name' => 'BAR')}
base = Yao::Resources::Base.new({'id' => 'foo', 'name' => 'bar'})
got = base.update(name: 'BAR')
assert_equal(got.name, 'BAR')