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

Stephen Eley sfeley at gmail.com
Thu Oct 23 08:51:35 EDT 2008


On Thu, Oct 23, 2008 at 7:00 AM, Matt Wynne <matt at mattwynne.net> wrote:
>
> This is working OK, but I'm struggling with the routing so that I can use
> the integration session #get method to spin up my FakeController.

Is that strictly necessary?  Your fake controller's never going to get
routed to in real life, so testing that isn't important.  Why not just
put things in the params[] array that matter to your module and call
the controller method directly?  (I.e., don't call "get :index" --
just call "index.")

Another option would be to skip the fake controller, put the tests for
your module into a shared behavior spec, and include that shared
behavior in the spec for every controller that uses the module with
it_should_behave_like.  You'd be testing the module's behavior a few
times over, but you'd be doing it in the real controllers that really
use it.


-- 
Have Fun,
   Steve Eley (sfeley at gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org


More information about the rspec-users mailing list