I’ve found that for some complicated controllers, doing things like
setting sessions in after_filters, the Integration Tests loose the
session.
The controllers work fine in development and production. But, under
Integration Tests, the sessions seem to drop.
I haven’t been able to isolate the bug - that is, build a simple
controller which demonstrates the behavior.
Mocking out the session by doing something crude like this always fixes
it:
$session = Hash.new
class ActionController::Base
def session
$session
end
end
class MyIntegrationTest < ActionController::IntegrationTest
…
(Not sure how to unmock that).
Has anyone else experienced this? And, how can I unmock that behavior,
so that my functional tests aren’t affected?
Some heavy duty logging/debugging shows that:
- It’s not due to loosing the cookie - the _session_id is correct
- The problems happen at the session[…]=… - for some reason, that
doesn’t call correctly under IntegrationTests
Robert J. wrote:
I’ve found that for some complicated controllers, doing things like
setting sessions in after_filters, the Integration Tests loose the
session.
The controllers work fine in development and production. But, under
Integration Tests, the sessions seem to drop.
I haven’t been able to isolate the bug - that is, build a simple
controller which demonstrates the behavior.
Mocking out the session by doing something crude like this always fixes
it:
$session = Hash.new
class ActionController::Base
def session
$session
end
end
class MyIntegrationTest < ActionController::IntegrationTest
…
(Not sure how to unmock that).
Has anyone else experienced this? And, how can I unmock that behavior,
so that my functional tests aren’t affected?
What version of Rails, are you using? The Rails 1.2 RC1 has bugs that
are
open for some of the Integration testing APIs.
I would take results of the Integration tests with a grain of salt. It
is
better to use something like Selenium on Rails as a substitute for
Integration testing.
Bala P. wrote:
What version of Rails, are you using? The Rails 1.2 RC1 has bugs that
are
open for some of the Integration testing APIs.
I would take results of the Integration tests with a grain of salt. It
is
better to use something like Selenium on Rails as a substitute for
Integration testing.
1.1.6 - (I think I tried with 1.2rc1 also).
I think the cause is that Integration tests try to capture out the
controller, invoking some vodoo. It may be better to just leave this
out - if you need access to the controller, use functional tests.