Contents

This page comes from RSpec Core 2.0.1. It is not part of the 3.12.1 docs. See the latest RSpec Core docs.

halt

In an example, before or after hook, you can halt the current example, group, or suite based on arbitrary criteria.

Scenario: halt group on failure

@wip

  • Given a directory named "spec"
  • And a file named "spec/example_spec.rb" with:
    ruby
    RSpec.configure do |c|
      c.after(:each) do
        example.halt(:group, :status => 'failed')
      end
    end
    describe "something" do
      it "fails" do
        fail 
      end
    
      it "does not run this example" do
      end
    end
  • When I run "rspec ./spec/example_spec.rb"
  • Then the output should contain "1 example, 1 failure"

Source: features/hooks/halt.feature at v2.0.1, RSpec Core (MIT license).