Skip to content

Instantly share code, notes, and snippets.

@mcmire
Created October 1, 2012 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcmire/3814710 to your computer and use it in GitHub Desktop.
Save mcmire/3814710 to your computer and use it in GitHub Desktop.
Running two instances of Spork for two separate projects using Guard

Instructions:

  • Take a look at the Guardfile here and copy and paste relevant parts.
  • Install spork to script/spork
  • Install drspec to script/drspec
  • Remove --drb from your .rspec file. Using Spork has to be opt-in in order to properly customize the DRb port.
  • Install .spork-port to .spork-port. Change the port to whatever you want.
spork_port = File.read(File.expand_path('../.spork-port', __FILE__)).to_i
guard 'spork', :rspec_port => spork_port do
watch('Gemfile')
watch('Gemfile.lock')
watch('spec/spec_helper.rb') { :rspec }
# ... whatever else you want here ...
end
rspec_config_file = File.expand_path('../.rspec', __FILE__)
rspec_opts = File.read(rspec_config_file).split("\n").join(" ")
guard(:rspec,
:cli => "#{rspec_opts} --drb-port #{spork_port}"
# ... whatever else you want here ...
) do
watch(%r(^spec/(.+)_spec\.rb$))
# ... whatever else you want here ...
end
#!/bin/bash
spork_port=$(< .spork-port)
bundle exec spork --port $spork_port "$@"
#!/bin/bash
spork_port=$(< .spork-port)
rspec --drb --drb-port $spork_port "$@"
@jmuheim
Copy link

jmuheim commented Oct 2, 2012

This works quite well so far. But what exactly does the script/drspec file? Where is it called?

@jmuheim
Copy link

jmuheim commented Oct 2, 2012

And what does "Using Spork has to be opt-in in order to properly customize the DRb port." mean?

@jmuheim
Copy link

jmuheim commented Oct 2, 2012

Let's discuss it here: guard/guard-spork#78 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment