[rspec-users] How to Spec a Module to be used in a Controller

Matt Wynne matt at mattwynne.net
Fri Oct 24 03:53:16 EDT 2008


On 23 Oct 2008, at 14:49, Pat Maddox wrote:

> Matt Wynne <matt at mattwynne.net> writes:
>>
>> Is this how other people do this? Is there a trick that I'm missing?
>
> Yeah, it's kind of a bummer, just something you have to deal with  
> cause
> of Rails.  What I do is set up a default route, you know the old- 
> school
> ':controller/:action/:id' kind.
>
> Pat
>

Ok, so here's my best attempt at this:

         # Briefly enables the old-fashioned wide-open routing for the  
block, allowing you to run code that spins up a random controller
         def with_basic_routing
           ActionController::Routing::Routes.clear!
           ActionController::Routing::Routes.draw do |map|
             map.connect ':controller/:action'
           end

           yield

           SK::Routing::DefaultRoutes.load_routes
         end

Any advance?



More information about the rspec-users mailing list