Skip to content

Commit

Permalink
Initialize SporkInstances "once"
Browse files Browse the repository at this point in the history
  • Loading branch information
Mange committed Nov 29, 2011
1 parent 6c60986 commit 9e218c5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/guard/spork/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def initialize(options={})
end

def launch_sporks(action)
initialize_spork_instances
UI.info "#{action.capitalize}ing Spork for #{sporked_gems} ", :reset => true
spawn_child(options[:test_unit_env], spork_command(:test_unit)) if test_unit?
spawn_child(options[:rspec_env], spork_command(:rspec)) if rspec?
Expand All @@ -35,6 +36,14 @@ def kill_sporks
end

private
attr_reader :spork_instances

def initialize_spork_instances
@spork_instances = {}
[:rspec, :cucumber, :test_unit].each do |type|
spork_instances[type] = SporkInstance.new(type, options[:"#{type}_port"], options[:"#{type}_env"], :bundler => bundler?)
end
end

def spawn_child(env, cmd)
pid = fork
Expand Down Expand Up @@ -82,8 +91,7 @@ def terminated_children
end

def spork_command(type)
instance = SporkInstance.new(type, options[:"#{type}_port"], options[:"#{type}_env"], :bundler => bundler?)
instance.command
spork_instances[type].command
end

def verify_launches(action)
Expand Down

0 comments on commit 9e218c5

Please sign in to comment.