Sha256: bebd9b1a555b3d3282876824575066e6ae95ecd973a41e80ddd13296266c4d91

Contents?: true

Size: 544 Bytes

Versions: 8

Compression:

Stored size: 544 Bytes

Contents

# encoding: UTF-8

require File.expand_path("./helper", File.dirname(__FILE__))

class Post < Ohm::Model
  include Ohm::Timestamping
  include Ohm::Typecast

  typecast :created_at, Time
  typecast :updated_at, Time
end

test "created_at and updated_at are typecasted" do
  post = Post.create

  assert post.created_at.respond_to?(:strftime)
  assert post.updated_at.respond_to?(:strftime)

  assert NOW.strftime("%Y-%m-%d") == post.created_at.strftime("%Y-%m-%d")
  assert NOW.strftime("%Y-%m-%d") == post.updated_at.strftime("%Y-%m-%d")
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ohm-contrib-0.1.2 test/typecast_existing_attribute_test.rb
ohm-contrib-0.1.1 test/typecast_existing_attribute_test.rb
ohm-contrib-0.1.0 test/typecast_existing_attribute_test.rb
ohm-contrib-0.0.42 test/typecast_existing_attribute_test.rb
ohm-contrib-0.0.41 test/typecast_existing_attribute_test.rb
ohm-contrib-0.0.40 test/typecast_existing_attribute_test.rb
ohm-contrib-0.0.39 test/typecast_existing_attribute_test.rb
ohm-contrib-0.0.38 test/typecast_existing_attribute_test.rb