[rspec-users] How to Spec a Module to be used in a Controller
pergesu at gmail.com
Thu Oct 23 09:49:23 EDT 2008
Matt Wynne <matt at mattwynne.net> writes:
> I want to be able to factor out bits of a controller's behaviour into
> modules, and spec them independently. E.g. modules like Authentication
> and ExceptionHandling that are mixed into ApplicationController.
> In my spec, I create a FakeController class which inherits from
> ActionController::Base, and mix in the module.
> 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.
> I have to set up the routing for this FakeController in a
> before(:all), then reload the default routing in after(:all) so as not
> to pollute the other specs.
> 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
More information about the rspec-users