💪 How I set up a test suite

Setting up RSpec to run nicely with all the nice to haves can be a real pain at the beginning of a project.

I’ve lost countless hours trying to find previous examples and copying and pasting files from here, there and everywhere. The truth of the matter is that I don’t care about the setup - I just want to write my tests using the tools that I’m familiar with.

Currently, I have a bin file that will install the gems that I want and then copy a few support files. Run once and forget about it 🚀

Spec Setup script

To start with I’ve put all the commands into a spec_setup file that lives in my bin folder - bin/spec_setup. In addition to this file, I have a folder of sample files in the bin/templates folder.

The spec_setup script adds the gems that I find useful using bundle add <GEM_NAME>, performs any install commands - like rails g rspec:install - and copies sample files into the spec/support folder.

I’ve used this script a grand total of… pause for dramatic effect … once and it has a problem of not having a spec/support folder available, so for now I created that folder manually.

Future

I’d like to be able to run this from any project - I don’t think it makes sense to be a gem that is added to a projects Gemfile but having a command to run would be lovely


Side notes

standard and i18n-tasks are also added as I would tend to set up my CI to fail on incorrect code style or missing translations