I decided to make a simple rspec like the ones you find in the rspec docs describing the leftovers in the before and after hooks documentation that they never discussed. I ran into issues in my project, because it’s not necessarily totally intuitive what order things are happening when you get into a lot of befores and afters.
Here it is:
Here’s what happens when we run the spec:
As you can see, the intersting bit is in the nested describe group of tests, where it first does the inner before all, then it does the outer before each before doing the inner before each. Weird! So be careful not to get zapped by any outer before each block if you want to do an inner before all in a nested group of tests. Also notice when the descriptions get printed vs. when the spec actually runs.
Let’s see if it continues the trend when we nest another level: