Guard RSpec

Autorun RSpec using guard
Icons/chart bar
Used 103 times
Created by
F Fajarullah

Usage

Run this command in your Rails app directory in the terminal:

rails app:template LOCATION="https://railsbytes.com/script/x7msmL"
Template Source

Review the code before running this template on your machine.

def add_gem_if_not_present(*args, **options)
  gem(*args, **options) unless Gem.loaded_specs.has_key?(args.first)
end

use_spring = ask("use spring ? [y/n]").strip.upcase == "Y"

gem_group :development do
  add_gem_if_not_present 'guard-rspec', require: false
  if use_spring
    add_gem_if_not_present 'spring'
    add_gem_if_not_present 'spring-commands-rspec'
  end
end

Bundler.with_unbundled_env { run "bundle install" }
run "bundle exec guard init rspec"
run "bundle binstub guard"

if use_spring
  run "bundle exec spring binstub rspec"
  gsub_file "Guardfile", 'cmd: "bundle exec rspec"', 'cmd: "bin/rspec"'
end
Comments
John Meehan
bundle exec guard init rspec

Fajarullah
Updated.