I’m a fan of test driven development, in order to speed up my turnaround time from writing functionality to testing the functionality, I use Guard(https://github.com/guard/guard) tool to automatically run my test any time I make a change.
This greatly speeds up my development time and hopefully it’ll help you too.
This is going to be our final files and folder structure.
First step is to setup a gem file with the dependencies that we will be using.
Create a new file named ‘Gemfile’ in your main project directory with the following contents
Once done, run the bundle install commind in the terminal to install the dependencies, like so.
Seting up Guard
Create a new file named ‘Guardfile’ with the following content
This file configures the Guardfile tool to watch for any changes to ruby files within the lib and spec directories and runs rspec.
Note: We have taken this route of manually creating a Guardfile rather than running “guard init” so we more easily see what the guard file is doing. Guard init generates a lot of code that we won’t be using in this guide.
Finally we launch our Guard instance to start watching our files by running the following command in the terminal.
That’s it, hopefully this helps speeds up your development time.
Here is the completed repo.