[rspec-devel] Should all teardown blocks run regardless of error?

David Chelimsky dchelimsky at gmail.com
Wed Jun 27 12:01:12 EDT 2007


On 6/27/07, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:
> Old words die hard. I meant *after* blocks, not teardown ;-)
>
> On 6/27/07, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:
> > I was just bitten by some unexpected behaviour. Look at the following spec.
> >
> > Spec::Runner.configure do |config|
> >   config.after(:each) do
> >     puts "C"
> >   end
> > end
> >
> > describe "examples and teardowns" do
> >   it "should all run" do
> >     puts "A"
> >   end
> >
> >   after(:each) do
> >     puts "B"
> >     raise "oh no"
> >   end
> > end
> >
> > I would have expected to see:
> >
> > A
> > B
> > C
> >
> > But in fact I see:
> >
> > A
> > B
> >
> > The last (global) teardown doesn't get run - the first teardown block
> > raising an error causes the other ones to not be run at all. This
> > seems inconsistent to me - if an example fails, the (first) teardown
> > will still run.
> >
> > I'd like to change this so that all teardowns get run, even if
> > previous ones fail (likewise for multiple setups). Does anyone have
> > any objections to that?

+1 (no objection)

> >
> > Aslak
> >
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>


More information about the rspec-devel mailing list