Guard::Spork allows to automatically & intelligently start/reload your RSpec/Cucumber Spork server(s).
-
Compatible with Spork 0.8.4 & 0.9.0.rc3.
-
Tested on Ruby 1.8.6, 1.8.7 & 1.9.2.
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
Please read Guard usage doc.
Please read Guard doc for more info about the Guardfile DSL.
IMPORTANT: place Spork guard before RSpec/Cucumber guards!
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
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
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
To append additional environment variables for rspec and cucumber you can provided a hash to rspec_env/cucumber_env:
guard 'spork', :cucumber_env => {'RAILS_ENV' => 'cucumber'}, :rspec_env => {'RAILS_ENV' => 'test'} do ... end
IMPORTANT: when using ruby 1.8.x please set the env for both rspec and cucumber as they will overwrite each other and the system env’s
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 :cucumber_env
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.
-
Source hosted at GitHub
-
Report issues/Questions/Feature requests on GitHub Issues
Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make.