• Stars
    star
    300
  • Rank 134,238 (Top 3 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 13 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Guard::Spork automatically manage Spork DRb servers

Guard::Spork Build Status Dependency Status Gem Version

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

  • Compatible with Spork 0.8.4 & 0.9.0.rcX.
  • Tested against Ruby 1.9.3, 2.0.0, 2.1.2, and JRuby.

Install

Please be sure to have Guard installed before continuing.

Install the gem:

$ gem install guard-spork

Add it to your Gemfile (inside development group):

group :development do
  gem 'guard-spork'
end

Add guard definition to your Guardfile with:

$ guard init spork

Usage

Please read the Guard usage documentation.

Guardfile

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

IMPORTANT: place Spork guard before RSpec/Cucumber/Test::Unit 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('Gemfile.lock')
  watch('spec/spec_helper.rb') { :rspec }
  watch('test/test_helper.rb') { :test_unit }
  watch(%r{features/support/}) { :cucumber }
end

Running specs over Spork

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

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

guard 'cucumber', :cmd => "rspec --drb" do
  # ...
end

For MiniTest Guard you should pass the :drb => true option:

guard 'minitest', :drb => true do
  # ...
end

Options

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

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

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

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

If your application runs on Heroku or otherwise uses Foreman, you can provide the :foreman => true option to have environment variables present in the .env file passed on to the Spork server.

Available options:

:wait => 60                                # Seconds to wait for the server to start, default: 30. Setting it to nil will cause it to wait indefinitely.
:retry_delay => 60                         # Seconds to wait before retrying booting the server, default: 30. Setting it to nil will cause it to wait indefinitely.
:cucumber => false
:rspec => false
:test_unit => false
:minitest => false
:bundler => false                          # Don't use "bundle exec"
:test_unit_port => 1233                    # Default: 8988
:rspec_port => 1234                        # Default: 8989
:cucumber_port => 4321                     # Default: 8990
:test_unit_env => { 'RAILS_ENV' => 'baz' } # Default: nil
:rspec_env => { 'RAILS_ENV' => 'foo' }     # Default: nil
:cucumber_env => { 'RAILS_ENV' => 'bar' }  # Default: nil
:aggressive_kill => false                  # Default: true, will search Spork pids from `ps aux` and kill them all on start.
:notify_on_start => true                   # Default: false, will notify as soon as starting begins.
:foreman => true                           # Default: false, will start Spork through `foreman run` to pick up environment variables used by Foreman. Pass an env file {:env => ".env.test"}
:quiet => true                             # Default: false, will silence some of the debugging output which can get repetitive (only work with Spork edge at the moment).

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 => 60 option before any further investigation. It's possible that this error is the result of an unnecessary /test directory in the root of your application. Removing the /test directory entirely may resolve this error.

Development

Pull requests are very welcome! Please try to follow these simple "rules", though:

  • Please create a topic branch for every separate change you make.
  • Make sure your patches are well tested.
  • Update the README (if applicable).
  • Please do not change the version number.

For questions please join us on our Google group or on #guard (irc.freenode.net).

Author

Thibaud Guillaume-Gentil

More Repositories

1

guard

Guard is a command line tool to easily handle events on file system modifications.
Ruby
6,191
star
2

guard-livereload

Guard::LiveReload automatically reload your browser when 'view' files are modified.
JavaScript
2,100
star
3

listen

The Listen gem listens to file modifications and notifies you about the changes.
Ruby
1,893
star
4

guard-rspec

Guard::RSpec automatically run your specs (much like autotest)
Ruby
1,301
star
5

rb-inotify

A thorough inotify wrapper for Ruby using FFI.
Ruby
314
star
6

guard-jasmine

The Swiss Army knife for automated Jasmine specs in your console.
Ruby
305
star
7

guard-minitest

Guard::Minitest automatically run your tests (much like autotest)
Ruby
246
star
8

rb-fsevent

FSEvents API with signals handled (without RubyCocoa)
C
243
star
9

guard-bundler

Guard::Bundler automatically install/update your gem bundle when needed
Ruby
116
star
10

guard-test

Guard::Test automatically run your tests (much like autotest)
Ruby
95
star
11

guard-less

Guard::Less automatically compiles less (like lessc --watch)
Ruby
44
star
12

guard-pow

Guard::Pow automatically manage Pow applications restart
Ruby
43
star
13

guard-process

Guard extension to run cli processes
Ruby
43
star
14

guard-haml

Watch haml files with guard
Ruby
40
star
15

guard-nanoc

A Guard for nanoc
39
star
16

notiffany

wrapper for popular notification libs
Ruby
34
star
17

guard-yield

Run any Ruby code when files are changed/added/removed
Ruby
14
star
18

shellany

portable shell command output capturing
Ruby
8
star
19

guard-phpcs

Guard::PHPCS automatically runs PHP Code Sniffer when watched files are modified
Ruby
5
star
20

guard-compat

Test helper for testing Guard plugins
Ruby
5
star
21

guard-ronn

Guard::Ronn automatically builds manuals.
Ruby
5
star
22

guard-steering

Guard for Steering, a Handlebars.js Ruby precompiler wrapper.
Ruby
4
star
23

guard-phpmd

Guard::PHPMD automatically runs PHP Mess Detector when watched files are modified
Ruby
3
star
24

guard-premailer

Inline your css into html for e-mail templates with guard
Ruby
2
star
25

guard.github.com

Guard homepage (work in progress)
Ruby
1
star
26

guard-post

Watch Static Files, Convert them to Database Records (Mongoid, ActiveRecord, etc.)
Ruby
1
star
27

listen-compat

Compatibility wrapper for the Listen gem
Ruby
1
star