[rspec-users] Failure trying to test ApplicationController

Steve vertebrate at gmail.com
Tue Oct 16 01:54:08 EDT 2007

On Tue, 16 Oct 2007 00:26:13 -0500, David Chelimsky wrote:
> You get responses (i.e. the response object in the spec) from actions
> using get, post, put, delete, not by calling methods directly on the
> controller.
> Part of the problem is that you're trying to spec something that
> already exists. Developing spec-first, you wouldn't likely end up with
> this problem because this method would have appeared because you
> refactored it out of an existing action, which was already spec'd.
> To be honest, I'm not quite sure how to spec this. One way would be to
> set a message expectation for the call to redirect_to:
>   controller.should_receive(:redirect_to)
>   controller.require_login
> Anybody else have any ideas?

I see what you're saying I think. That the application controller stuff
isn't setup properly because no initial request(get/post) has been

Attaching these tests to every describe out there for a given
controller seems overkill. Since if the one spec for testing the
application controller tests all of its methods, then it should be fine
wherever its used it would seem. Would it be enough to just make a call to
some controller/action in the app to get everything initialized?

More information about the rspec-users mailing list