Odd Behavior During Testing

I’m completely lost here. Can anyone shed some light on this?

In the SnS extension I have created the following…

In styles_n_scripts_extension.rb (activate method):
SiteController.send :include, SiteControllerExtensions

In the /lib/site_controller_extensions.rb file:
module SiteControllerExtensions; end (Yes, it’s empty. I stripped
everything out trying to debug)

In the failing spec (describing SiteController):
it “should render an existing page” do
get :show_page, :url => ‘/’
response.body.should == “Hello World!”
end

Apparently, the SiteController also mixes-in the login_system which
creates its own before_filter that calls the #authenticate method. This
method, in turn, calls no_login_required? SiteController should
respond ‘true’ – that no login is required. But here’s where it gets
weird…

If I comment out my include line (the one in the extension’s activate
method above) SiteController does, indeed respond ‘true’ to
no_login_required? But, the minute I add in that include and mix in my
extensions – even with nothing in my mixed-in module –
SiteController starts responding ‘false’ – that login is required. My
spec’ed get request then returns a redirect to the login page.

This only happens when running specs. Testing with a server in
development mode works fine. Thoughts anyone?

-Chris

Anyone?

Further testing shows that when I don’t include my module, I can verify
during any controller’s spec that:
controllers_where_no_login_required = [SiteController]

As soon as I mix it in (even though it’s an empty module), during the
environment init and just before specs start to run:
controllers_where_no_login_required = [SiteController]

But once the specs start to run, I get:
controllers_where_no_login_required = []

Which, of course, messes up the tests.

Sounds like rSpec could be getting in the way but I don’t even know
where to start here. Can anyone provide some insight – or even just
suggest some way to start tackling this?

-Chris

Does the site work ok when you boot the server? Or is it only tests
that are broken?

-Alex

Only tests (specs, actually).