[rspec-users] nuby: how spec redirect_to at ApplicationController
dchelimsky at gmail.com
Fri Aug 24 10:05:46 EDT 2007
On 8/24/07, Priit Tamboom <priit.tamboom at eesti.ee> wrote:
> On 8/16/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > On 8/15/07, Courtenay <court3nay at gmail.com> wrote:
> > > On 8/15/07, Priit Tamboom <priit.tamboom at gmail.com> wrote:
> > > > describe ApplicationController do
> > > > it "method login_required should redirect to home path without
> login" do
> > >
> > > heh. "it" is so out of place here :)
> > I agree. The goal is to describe behaviours of objects, not methods.
> > So, I'd write:
> > it "should redirect anonymous user to home path"
> > Cheers,
> > David
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> Thanks for great answers!
> By the way, David, your blog post was good additional help about what to do
> with application methods:
> I wonder how far you go just testing "concrete" controllers. For example, if
> I move login methods from application controller to module under lib
> directory then do you change your style (write separate spec for module) or
> just keep testing concrete controllers as usually you do.
Typically I'd only move something up to Application when I find that I
need it in two controllers. But I start by implementing it
(spec-first) in both. Then I've got duplicated specs and duplicated
code. Then I'd extract a shared behaviour, followed by moving the
method up to Application. Which extraction happens first is not
important - what IS important is that they are separate activities and
you don't start the second extraction until you have a green bar.
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users