Skip to content

Commit

Permalink
Merge pull request rspec#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 Mar 27, 2020
2 parents b8ac182 + 2234373 commit 695399f
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 695399f

Please sign in to comment.