[rspec-devel] names for setup and teardown methods
Matthew Heidemann
matthew.heidemann at gmail.com
Wed Apr 18 19:20:36 EDT 2007
I personally like before :each_example. The first time I read it I said,
"before :each what?".
I think once people run the spec and see 1 example 0 failures, they know
that the 'it do' is an example
On 4/11/07, Matt Aimonetti <matt at aimonetti.net> wrote:
>
> 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
> >
>
>
> _______________________________________________
> 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/20070418/5d923c1e/attachment-0001.html
More information about the rspec-devel
mailing list