Skip to content

Instantly share code, notes, and snippets.

@iain
Created April 17, 2011 15:27
Show Gist options
  • Select an option

  • Save iain/924124 to your computer and use it in GitHub Desktop.

Select an option

Save iain/924124 to your computer and use it in GitHub Desktop.
just a quick hack
#!/usr/bin/env ruby
CUCUMBER_PORT = 8990
RSPEC_PORT = 8989
def running?(port)
`netstat -an` =~ /\b#{port}\b/m
end
START_CUCUMBER = "spork cuc -p #{CUCUMBER_PORT}"
START_RSPEC = "spork -p #{RSPEC_PORT}"
def start
@rspec = false
@cucumber = false
system "screen -AmdS spork-cucumber #{START_CUCUMBER}"
system "screen -AmdS spork-rspec #{START_RSPEC}"
print "Starting Spork for Cucumber and RSpec "
until @rspec && @cucumber
print '.'
@rspec = true if running?(RSPEC_PORT)
@cucumber = true if running?(CUCUMBER_PORT)
sleep 0.2
end
puts " OK!"
end
def stop
processes = `ps aux`.split("\n")
[ START_CUCUMBER, START_RSPEC ].each do |type|
p = processes.find { |pr| pr =~ /#{type}$/ }
p =~ /(\d+)/
if $1
puts "Killing #{$1}"
system "kill #{$1}"
end
end
end
case ARGV[-1]
when "start"
start
when "stop"
stop
when "restart"
stop
start
else
puts "Possible options: start, stop, restart"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment