Forum: RSpec Terminate on first failure?

Posted by Peter Nost (solutionmeister)
on 2010-02-09 17:10
We have thousands of code examples ('it' methods) in each of our rspec
files, each of which is dependent upon the success of the previous one.
These are wrapped in a few example groups ('desc' methods).

There's no changing that; that's the way they were written.

We are making significant changes to the code base, and the tests are
failing.  They are also taking a huge amount of time failing each of the
successive code examples.

Is there any way to get RSpec to terminate upon the first failure?

Thanks,
Pete
Posted by David Chelimsky (Guest)
on 2010-02-09 23:02
(Received via mailing list)
On Tue, Feb 9, 2010 at 12:10 PM, Erik Nost <lists@ruby-forum.com> wrote:
> Is there any way to get RSpec to terminate upon the first failure?
There's no way that I'm aware of to do this in rspec-1. There will
likely be a way to do it in rspec-2, but not yet (some of the
necessary pieces aren't in place). Once we get there, you'll be able
to do something like:

# purely hypothetical code - do not try this at home
Rspec::Core.configure do |c|
  c.after(:each) do
    if running_example.metadata[:status] == 'failed'
      running_example.example_group.break
    end
  end
end

Coming soon, but not quite yet.

Cheers,
David
Posted by Peter Nost (solutionmeister)
on 2010-02-10 15:21
David Chelimsky wrote:
> # purely hypothetical code - do not try this at home
> Rspec::Core.configure do |c|
>   c.after(:each) do
>     if running_example.metadata[:status] == 'failed'
>       running_example.example_group.break
>     end
>   end
> end
> 
> Coming soon, but not quite yet.

Very cool.

Thanks,
Pete
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.