Skip to content

Commit

Permalink
Merge pull request #2708 from rspec/add-default-hook-docs
Browse files Browse the repository at this point in the history
Add information about hook defaults to cucumber scenario
  • Loading branch information
JonRowe committed May 2, 2020
1 parent 4803790 commit abc6211
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions features/hooks/before_and_after_hooks.feature
Expand Up @@ -22,6 +22,8 @@ Feature: `before` and `after` hooks
after :suite
```

A bare `before` or `after` hook defaults to the `:example` scope.

`before` and `after` hooks can be defined directly in the example groups they
should run in, or in a global `RSpec.configure` block.

Expand Down Expand Up @@ -231,10 +233,18 @@ Feature: `before` and `after` hooks
puts "before example"
end
before do
puts "also before example but by default"
end
after(:example) do
puts "after example"
end
after do
puts "also after example but by default"
end
after(:context) do
puts "after context"
end
Expand All @@ -249,6 +259,8 @@ Feature: `before` and `after` hooks
"""
before context
before example
also before example but by default
also after example but by default
after example
.after context
"""
Expand Down

0 comments on commit abc6211

Please sign in to comment.