Guard::RSpec automatically run your specs (much like autotest)
Ruby
Pull request Compare This branch is 648 commits behind guard:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/guard
spec
.gitignore
Gemfile
Guardfile
LICENSE
README.rdoc
Rakefile
guard-rspec.gemspec

README.rdoc

Guard::RSpec

RSpec guard allows to automatically & intelligently launch specs when files are modified.

  • Compatible with RSpec 1.x & RSpec 2.x

  • Tested on Ruby 1.8.6, 1.8.7 & 1.9.2.

Install

Please be sure to have Guard installed before continue.

Install the gem:

gem install guard-rspec

Add it to your Gemfile (inside test group):

gem 'guard-rspec'

Add guard definition to your Guardfile by running this command:

guard init rspec

Usage

Please read Guard usage doc

Guardfile

RSpec guard can be really adapted to all kind of projects.

Standard ruby gems

guard 'rspec' do
  watch(%r{spec/(.*)_spec.rb})
  watch(%r{lib/(.*)\.rb})      { |m| "spec/lib/#{m[1]}_spec.rb" }
  watch('spec/spec_helper.rb') { "spec" }
end

Rails app

guard 'rspec' do
  watch(%r{spec/(.*)_spec.rb})
  watch(%r{app/(.*)\.rb})                            { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{lib/(.*)\.rb})                            { |m| "spec/lib/#{m[1]}_spec.rb" }
  watch('spec/spec_helper.rb')                       { "spec" }
  watch('config/routes.rb')                          { "spec/routing" }
  watch('app/controllers/application_controller.rb') { "spec/controllers" }
  watch('spec/factories.rb')                         { "spec/models" }
end

Please read Guard doc for more info about Guardfile DSL.

Options

RSpec guard should automatically detect RSpec version (via spec_helper syntax or Bundler) but you can force version with:

guard 'rspec', :version => 2 do
  ...
end

Other available options:

:color => false
:drb => true
:bundler => false # don't use "bundle exec"
:rvm => ['1.8.7', '1.9.2'] # directly run your specs on multiple ruby
:formatter => "instafail" # show failing specs instantly
:fail_fast => true # RSpec 2.1+ only

Development

Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make.

Testing

Please run “rake spec:prepare_fixtures” once before launching specs.

Authors

Thibaud Guillaume-Gentil