[rspec-users] Terminate on first failure?

David Chelimsky dchelimsky at gmail.com
Tue Feb 9 17:00:46 EST 2010


On Tue, Feb 9, 2010 at 12:10 PM, Erik Nost <lists at ruby-forum.com> wrote:
> 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?

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


More information about the rspec-users mailing list