Sha256: d8f65ff34eb466a0634386a687622ffe9e1b2ec78037a72b3b6bedb063ecbb8c
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
require 'rspactor' require 'socket' module RSpactor class Spork RSPEC_PORT = 8989 CUCUMBER_PORT = 8990 attr_accessor :use_cucumber def initialize(runner) @use_cucumber = runner.cucumber? end def start execute(:start) end def reload execute(:reload) end private def execute(start_or_reload) action_message = (start_or_reload == :start) ? "Starting" : "Reloading" message = "** #{action_message} Spork for rspec" message += " & cucumber" if use_cucumber kill_and_launch(message) end def kill_and_launch(message) Interactor.ticker_msg message do system("kill $(ps aux | awk '/spork/&&!/awk/{print $2;}') >/dev/null 2>&1") system("spork >/dev/null 2>&1 < /dev/null &") wait_for('RSpec', RSPEC_PORT) if use_cucumber system("spork cu >/dev/null 2>&1 < /dev/null &") wait_for('Cucumber', CUCUMBER_PORT) end end end def wait_for(sporker, port) 15.times do begin TCPSocket.new('localhost', port).close rescue Errno::ECONNREFUSED sleep(1) next end return true end raise "could not load spork for #{sporker}; make sure you can use it manually first" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rspactor-0.6.4 | lib/rspactor/spork.rb |
rspactor-0.6.3 | lib/rspactor/spork.rb |
rspactor-0.6.2 | lib/rspactor/spork.rb |