Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'rubygems'
require 'sequel'
if defined? JRUBY_VERSION
DB = Sequel.connect( 'jdbc:sqlite::memory:' )
else
DB = Sequel.sqlite
end
DB.create_table :things do
primary_key :id
Time :created_at
end
class Thing < Sequel::Model
plugin :timestamps
plugin :typecast_on_load, :created_at
end
require 'test/unit'
class ThingTest < Test::Unit::TestCase
def test_created_at_should_be_Time_instance
thing = Thing.create
assert_kind_of Time, thing.created_at
end
end
# Output:
#$ multiruby test_timestamp.rb
#
#VERSION = jruby-1.4.0
#CMD = ~/.multiruby/install/jruby-1.4.0/bin/ruby test_timestamp.rb
#
#Loaded suite test_timestamp
#Started
#F
#Finished in 0.07 seconds.
#
# 1) Failure:
#test_created_at_should_be_Time_instance(ThingTest) [test_timestamp.rb:24]:
#<"2010-03-06 16:30:09.970000-0800">
#expected to be kind_of?
#<Time> but was
#<String>.
#
#1 tests, 1 assertions, 1 failures, 0 errors
#
#RESULT = 256
#
#VERSION = 1.8.7-p72
#CMD = ~/.multiruby/install/1.8.7-p72/bin/ruby test_timestamp.rb
#
#Loaded suite test_timestamp
#Started
#.
#Finished in 0.002524 seconds.
#
#1 tests, 1 assertions, 0 failures, 0 errors
#
#RESULT = 0
#
#VERSION = 1.9.1-p378
#CMD = ~/.multiruby/install/1.9.1-p378/bin/ruby test_timestamp.rb
#
#Loaded suite test_timestamp
#Started
#.
#Finished in 0.002922 seconds.
#
#1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
#
#RESULT = 0
#
#TOTAL RESULT = 1 failures out of 3
#
#Passed: 1.8.7-p72, 1.9.1-p378
#Failed: jruby-1.4.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.