[Rspec-users] Living Dangerously?

Jerry West jerry.west at ntlworld.com
Fri Sep 29 17:49:46 EDT 2006

how can I get the benefits of integration testing with Rspec on Rails 
REL_0_6_3, please?

When I first started playing with Rspec on Rails, I hacked 
spec_helper.rb to include the IntegrationTest interface (diff below) as 
it was the minimum change I could make to get the the ability to run 
multiple actions across controllers in my spec.  I use it to specify 
authenticated sessions and stuff.  No, I didn't know what I was doing, 
but it seemed to work.

Today it bit me.  I most-always run my specs separately so I know what's 
failed but today I was doing some regression testing so ran rake 
spec:controllers for the first time (gasp!).

Specs started to fail on the basic "controller.should_be_instance_of ...":

 <ApreviousController> should be an instance of <ThisNewController>

A simple trace in lib/rspec_on_rails.rb (around lines 43-48) shows the 

 >>>>>looking for AccountController
 >>>>>found #<AccountController:0xb74cff20>
(next test)
 >>>>>looking for FeedbackController
 >>>>>found #<AccountController:0xb74ce288>
 >>>>>looking for FeedbackController
 >>>>>found #<AccountController:0xb74ce288>

What really messes my brain is that the call to FeedbackController.new 
is returning an AccountController.   Ouch.  I'm messing something up big 
time.  Each spec runs fine on its own by the way, with the trace as 
you'd expect.

Two questions (perhaps one)

1.  I am now using REL_0_6_3; how can I get the benefits of integration 
testing without this hack please?  If I take it out, my cross controller 
(routed) url's fail.

2.  If I have to keep the hack, is it likely that my specs are failing 
by failing to fail ?  In other words - can I trust the output any more?

Many thanks,

*** spec_helper.orig    2006-09-29 21:22:40.000000000 +0100
--- spec_helper.rb      2006-09-29 21:29:52.000000000 +0100
*** 27,34 ****
      class Context
        def before_context_eval
          inherit SpecTestCase
!         inherit ActionController::IntegrationTest

More information about the Rspec-users mailing list