Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Guard::Spork automatically manage Spork DRb servers
Ruby

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/guard
spec
.gitignore
.travis.yml
Gemfile
Guardfile
LICENSE
README.rdoc
Rakefile
guard-spork.gemspec

README.rdoc

Guard::Spork

Guard::Spork allows to automatically & intelligently start/reload your RSpec/Cucumber Spork server(s).

  • Compatible with Spork 0.8.4 & 0.9.0.rcXX.

  • Tested on Ruby 1.8.6, 1.8.7, REE, 1.9.2, JRuby & Rubinius.

Install

Please be sure to have Guard installed before continue.

Install the gem:

gem install guard-spork

Add it to your Gemfile (inside test group):

gem 'guard-spork'

Add guard definition to your Guardfile with:

guard init spork

Usage

Please read Guard usage doc.

Guardfile

Please read Guard doc for more info about the Guardfile DSL.

IMPORTANT: place Spork guard before RSpec/Cucumber guards!

Rails app

guard 'spork' do
  watch('config/application.rb')
  watch('config/environment.rb')
  watch(%r{^config/environments/.*\.rb$})
  watch(%r{^config/initializers/.*\.rb$})
  watch('spec/spec_helper.rb')
end

Running specs over Spork

Pass the :cli => "--drb" option to Guard::RSpec and/or Guard::Cucumber to run them over the Spork DRb server:

guard 'rspec', :cli => "--drb" do
  ...
end

guard 'cucumber', :cli => "--drb" do
  ...
end

Options

Guard::Spork automatically detect RSpec/Cucumber/Bundler presence but you can disable any of them with the corresponding options:

guard 'spork', :cucumber => false, :bundler => false do
  ...
end

You can provide additional environment variables for RSpec and Cucumber with the :rspec_env and :cucumber_env options:

guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'cucumber' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
  ...
end

Available options:

:wait => 30                               # Seconds to wait for the server to starts, default: 20
:cucumber => false
:rspec => false
:bundler => false                         # Don't use "bundle exec"
:rspec_port => 1234                       # Default: 8989
:cucumber_port => 4321                    # Default: 8990
:rspec_env => { 'RAILS_ENV' => 'foo' }    # Default: nil
:cucumber_env => { 'RAILS_ENV' => 'bar' } # Default: nil

Common troubleshooting

If you can start Spork manually but get the following error message when using Guard::Spork:

Starting Spork for RSpec ERROR: Could not start Spork for RSpec/Cucumber. Make sure you can use it manually first.

Try to increase the value of the :wait option before any further investigation.

Development

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

Authors

Thibaud Guillaume-Gentil

Something went wrong with that request. Please try again.