Codecabulary Home / Learn Test Driven Development / RSpec|Learn Test Driven Development / Automate Tests with Guard
Guard is a command line tool that watches a file structure and automates events when changes are made in those files. While Guard has many uses, this article explores how we can use RSpec and Guard together to automate tests.
Installing Guard
Once you have RSpec setup in your Rails project, you're ready to add Guard.
-
Add guard-rspec to the Gemfile
group :development, :test do gem 'rspec-rails' # These are set up from installing RSpec and Capybara gem 'capybara' gem 'guard-rspec' end
-
Add other :test group gems
group :test do gem 'rb-fsevent' gem 'growl' end
-
bundle
-
guard init spec
-
To run:
`bundle exec guard`
-
To exit:
`exit`