You may already know about `rspec` and `rubocop`, a testing tool and a checking tool (for ruby coding styles). They are not realted to be referred here in a same post but we’re using them these days in our company projects though. And actually we’re going to play with automation tests using `guard` and its plugins today, which are `guard-rspec` and `guard-rubocop`.
Rubocop and RSpec
For you who haven’t heard about `rubocop` and `rspec` have a look here:
`guard` helps us having things rerun automatically when new changes get saved. `guard-rspec` gets a spec re-run when you change and save it, `rubocop` gets fired by `guard-rubocorp` immediately after any of your files got saved (of course only the ones in the rubocop.yml configuration list), specs get run by `guard-rspec` when any of your spec gets changed and saved.
Note: One interesting thing is `guard-rspec` re-runs only the spec recently changed, not the whole spec directory.
Firstly make sure you have `guard` gem installed. Then add `guard-rspec` and `guard-rubocop` to the Gemfile:
group :development do
gem 'guard-rspec', require: false
Secondly let’s generate the `Guardfile` which contains the configurations.