RSpec hooks are essentially code blocks which are automatically called and executed when a test reaches a certain condition or state. For RSpec, in this tutorial we will cover two hooks. We will cover the before and after hook. The before hook is used to run code before a given test is executed. We can use the before hook to help us run code which can be used to setup a given test. Similar we can also write and run an after hook. The after hook can be used to run code after a test has finished. After hooks are prefect places to run code such as closing browsers, setting variables to null etc.