[Nitro] Og fixtures for Time class

Emmanuel Piperakis epiperak at softlab.ece.ntua.gr
Mon Dec 19 20:55:08 EST 2005


Hi!,
I had the same error some time ago, but not on an assert. I am not 100% 
sure how I resolved it, but first thing I would suggest is do not use 
Time.utc but Time.new, secondly create and save an object before testing 
it with assert (I can not see that in your code), try
def test_all
   sc = SomeClass.create
   sc.some_time = tt = Time.now
   sc.save

   ss = SomeClass[1] # load it from the db
   assert_equal tt, ss.some_time
end

That would work (I guess)

Emmanouil

> Hi everyone! I'm having a little problem with the fixtures..
>
> model.rb
> class SomeClass
>   property :some_time, Time
> end
>
> some_class.yml
> something:
>  some_time: 2005-12-19 09:00:00 # rails's fixture like
>
>
> tc_model.rb
> class TestModel < Test::Unit::TestCase
>
>  def setup
>    @og = Og.setup(
>      :destroy => true,
>      :store => :mysql,
>      :name => 'test_db',
>      :user => 'web_user',
>      :password => '*******'
>    )
>    og_fixture SomeClass
>  end
>
>  def test_all
>    assert_equal Time.utc(2005,12,19,9,0,0) , @something.some_time
>  end
> end
>
> When i run this test it saids that can't insert an string.. Glue
> doesn't parse the time an convert it to a Time object? How can i solve
> this?
>
> This is the output of the test:
>
> Loaded suite test/tc_model
> Started
> Database "test_db" dropped
> I, [2005-12-19T21:01:00.278501 #31274]  INFO -- : Database 'test_db' not found!
> I, [2005-12-19T21:01:00.342666 #31274]  INFO -- : Created table 'ogsomeclass'.
> E
> Finished in 0.211703 seconds.
>
>  1) Error:
> test_all(TestModel):
> NoMethodError: undefined method `strftime' for "2005-12-19 09:00:00":String
>    /usr/lib/ruby/gems/1.8/gems/og-0.25.0/lib/og/store/sql.rb:24:in `timestamp'
>    (eval):5:in `og_insert'
>    /usr/lib/ruby/gems/1.8/gems/og-0.25.0/lib/og/store.rb:100:in `save'
>    /usr/lib/ruby/gems/1.8/gems/og-0.25.0/lib/og/entity.rb:14:in `save'
>    /usr/lib/ruby/gems/1.8/gems/og-0.25.0/lib/og/test/testcase.rb:46:in
> `og_fixture'
>    /usr/lib/ruby/gems/1.8/gems/og-0.25.0/lib/og/test/testcase.rb:45:in
> `og_fixture'
>    /usr/lib/ruby/gems/1.8/gems/og-0.25.0/lib/og/test/testcase.rb:42:in
> `og_fixture'
>    test/tc_model.rb:18:in `setup'
>
> 1 tests, 0 assertions, 0 failures, 1 errors
>
> Please help me :D
>
> Thanks in advance
>
> Humber
>
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general
>

Emmanouil Piperakis (epiperak at cs.ntua.gr)
{To explore is Human, to Create is Devine,
  To teach is Primal, to Rule is Sin}



More information about the Nitro-general mailing list