[rspec-users] Failure trying to test ApplicationController

David Chelimsky dchelimsky at gmail.com
Tue Oct 16 02:02:58 EDT 2007

On 10/16/07, Steve <vertebrate at gmail.com> wrote:
> On Tue, 16 Oct 2007 00:26:13 -0500, David Chelimsky wrote:
> > 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.
> 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
> made.
> 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.

But how do you know that it's being used? The behaviour you're
spec'ing is that a given action should redirect if the user is not
logged in, right? If you look at it that way, then it seems perfectly
acceptable to do this:

describe "some action on some controller" do
  it_should_behave_like "action that requires login"

More information about the rspec-users mailing list