Search code examples
ruby-on-railsguardrails-enginesspork

Rails, Spork & Guard: how to run many spork servers in parallel?


I'm developing an engine (deployed as gem) which I use directly in my host app. As I load it through

gem 'my_gem', path: 'some/local/path'

all changes in the engine are directly reflected in my host app without server restart. So far, so good.

I use the well known Spork&Guard combination to develop and test my Rails apps. Until now, I never needed to run more than one guard process, as I didn't develop engines before. But now, I have a host app AND an engine that are both developed in parallel, so I need each's Spork&Guard combo to run at the same time.

Sadly, this doesn't seem to work, as Guard uses standard ports for Spork. Is there any way to tell Guard, which ports it should use when firing up spork?


Solution

  • In your guardfile:

    guard 'spork', :rspec_port => 12345 do
       # ...
       watch('spec/spec_helper.rb') { :rspec }
    end
    
    guard 'rspec', :cli => "--drb --drb-port 12345" do
       # ...
    end