The following is a quick reference to exact order of hook execution in RSpec. The output from hook_spec.rb
is:
describe: "a thing"
-> before: all (top)
-> around: before (top)
-> before: each (top)
-> example: "success" (top)
-> after: each (top)
-> around: after (top)
result: example: "success"
-> around: before (top)
-> before: each (top)
-> example: "failure" (top)
-> after: each (top)
-> around: after (top)
result: example: "failures" (FAILED - 1)
-> around: before (top)
-> before: each (top)
-> example: "exception" (top)
-> after: each (top)
-> around: after (top)
result: example: "exception" (FAILED - 2)
context: "when a thing"
-> before: all (context)
-> around: before (top)
-> around: before (context)
-> before: each (top)
-> before: each (context)
-> example: "success" (context)
-> after: each (context)
-> after: each (top)
-> around: after (context)
-> around: after (top)
result: context example: "success"
-> around: before (top)
-> around: before (context)
-> before: each (top)
-> before: each (context)
-> example: "failure" (context)
-> after: each (context)
-> after: each (top)
-> around: after (context)
-> around: after (top)
result: context example: "failures" (FAILED - 3)
-> around: before (top)
-> around: before (context)
-> before: each (top)
-> before: each (context)
-> example: "exception" (context)
-> after: each (context)
-> after: each (top)
-> around: after (context)
-> around: after (top)
result: context example: "exception" (FAILED - 4)
-> after: all (context)
-> after: all (top)