[rspec-devel] names for setup and teardown methods

Matt Aimonetti matt at aimonetti.net
Wed Apr 11 22:55:05 EDT 2007


I fully agree with Dean and prefer the "before :each", "after :all" option,
it reads better and is easier to understand for newbies.

-Matt

On 4/11/07, Dean Wampler <deanwampler at gmail.com> wrote:
>
> Setup and teardown are more approachable to converts from Test::Unit,
> but "before :all" and "after :each" read better, IMHO.
>
> "all_examples" might cause people to ask "what examples?" I'm not sure
> most people will think of the "it blocks" as examples. Still, you
> could just accept any symbol that begins with "each" and "all", so
> people can invent their own name ;)
>
> dean
>
>
> On 4/11/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > We're going to rename context_setup and context_teardown because they
> > no longer read well when using "describe/id". There are two ideas
> > floating around about this. The first:
> >
> > setup :each        #default - works like setup does now
> > setup :all             #replaces context_setup
> > teardown :each #default - works like teardown does now
> > teardown :all      #replaces context teardown
> >
> > The second uses "before" and "after" in the same way:
> >
> > before :each   #default - works like setup does now
> > before :all        #replaces context_setup
> > after :each       #default - works like teardown does now
> > after :all            #replaces context teardown
> >
> > In both cases, the default is :each, so you can just say "setup do" or
> > "before do" instead of "setup :each do" or "before :each do".
> >
> > == Examples
> >
> > describe Thing do
> >   setup :all { ... }
> >   setup :each { ... }
> >   it "should do something" { ... }
> >   it "should do something else" { ... }
> >   teardown :each { ... }
> >   teardown :all { ... }
> > end
> >
> > describe Thing do
> >   before :all { ... }
> >   before :each { ... }
> >   it "should do something" { ... }
> >   it "should do something else" { ... }
> >   after :each { ... }
> >   after :all { ... }
> > end
> >
> > describe Thing do
> >   before { ... } # works like before :each
> >   it "should do something" { ... }
> >   it "should do something else" { ... }
> >   after { ... } # works like after :each
> > end
> >
> > One other thing that occurs to me is that "before :each" really means
> > "before each example" - so perhaps it should be "before :each_example"
> > and "before :all_examples" (or :each and :each_example could both be
> > supported, etc).
> >
> > WDYT?
> > _______________________________________________
> > rspec-devel mailing list
> > rspec-devel at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-devel
> >
>
>
> --
> Dean Wampler
> http://www.objectmentor.com
> http://www.aspectprogramming.com
> http://www.contract4j.org
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20070411/494d47fa/attachment.html 


More information about the rspec-devel mailing list