[rspec-users] Difference between :each and :all

John Feminella johnf at bitsbuilder.com
Thu Jan 27 22:08:25 EST 2011

Not to shoot my own patch in the foot, but my personal opinion is to
have only one way to do it. I think whatever ambiguity there may be in
before(:all) isn't adequately compensated by the additional confusion
of having before(:any), which sounds like it would do something subtly
John Feminella
Principal Consultant, BitsBuilder
LI: http://www.linkedin.com/in/johnxf
SO: http://stackoverflow.com/users/75170/

On Thu, Jan 27, 2011 at 21:58, David Chelimsky <dchelimsky at gmail.com> wrote:
> On Thu, Jan 27, 2011 at 8:53 PM, Rick DeNatale <rick.denatale at gmail.com> wrote:
>> On Thu, Jan 27, 2011 at 6:16 PM, David Chelimsky <dchelimsky at gmail.com> wrote:
>>> On Jan 27, 2011, at 5:11 PM, John Feminella wrote:
>>>> That's not quite right. :each runs before _each_ spec, while :all runs
>>>> once, before _any_ spec.
>>> Perhaps :any is a better name? We could add it as an alternative for the same as :all. WDYT?
>> Speaking for myself, I never was confused between before(:each) and
>> before(:all).  The first always meant before each OF the examples, and
>> the latter before all the examples.
>> As a devil's advocate, while before(:any) might evoke the current
>> meaning of before(:all) for some people, after(:any) to me evokes the
>> curent meaning of after(:each) more than it does after(:all), i.e.
>> after any OF the examples rather than after all the examples, because
>> I'd never say after any the examples.
>> But that might just be me.
> You're absolutely right that it would be confusing for after, and
> given that, I think we should probably not add it.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list