Functional tests run fine on their own but fail with rake

this is a weird one. i have 8 functional tests classes. when I run them
individually, they all pass. When i use rake or ‘rake test:functionals’
one
of them fails. I’ve traced the error back to a problemwith reading data
from
the session.

when running the tests individually, the data is there. when run using
rake,
it’s nil.

has anyone come across anything like this before? any suggestions?

thanks
alan

Alan B. wrote:

thanks
alan


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

This has usually something to do with fixtures and associations, I
think. There was a thread about this about 3 weeks ago, or so. If you
search for functional, fixtures rake, I think you’ll prob find
something.

HTH

Yes I’ve seen this and it is maddening. When I was on the brink of
something
terrible, I tried to calm myself and think of the differences in the 2
situations. One difference I came up with, like mentioned above by Chris
T,
is the handling of fixtures.

When you do “rake”, in some or all of the situations the schema is
recreated
by copying from the development schema.

This is not done if you simply invoke a test on its own. The result is
the
database state can be slightly different. Specifically, a test running
manually may find records in the database that would be deleted if the
schema were recreated.

In my case, close inspection revealed that one my tests referenced
records
that were not added by the test specified fixtures. When I added the
missing fixture my tests started operating the same in both
environments.

-Kelly

On Jul 18, 2006, at 3:12 PM, Kelly F. wrote:

Yes I’ve seen this and it is maddening. When I was on the brink of
something terrible, I tried to calm myself and think of the
differences in the 2 situations. One difference I came up with,
like mentioned above by Chris T, is the handling of fixtures.

When you do “rake”, in some or all of the situations the schema is
recreated by copying from the development schema.

Also, check your config/environment.rb file and verify the line:

config.active_record.schema_format = :sql

If it is set to output the schema as ruby, then all sorts of weird
things can go wrong. I haven’t found a good reason yet to override
the default of sql.

cr

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs