Created
September 17, 2011 21:19
-
-
Save jasonm/1224382 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guard 'process', :name => 'Jasmine server', :command => 'bundle exec rake jasmine' do | |
watch(%r{spec/javascripts/support/*}) | |
end | |
JASMINE_HOST = '127.0.0.1' | |
JASMINE_PORT = '8888' | |
JASMINE_URL = "http://#{JASMINE_HOST}:#{JASMINE_PORT}/" | |
Thread.new do | |
require 'socket' | |
puts "\nWaiting for Jasmine to accept connections on #{JASMINE_URL}..." | |
wait_for_open_connection(JASMINE_HOST, JASMINE_PORT) | |
puts "Jasmine is now ready to accept connections; change a file or press ENTER run your suite." | |
puts "You can also view and run specs by visiting:" | |
puts JASMINE_URL | |
guard 'jasmine', :jasmine_url => JASMINE_URL do | |
watch(%r{app/assets/javascripts/(.+)\.(js\.coffee|js)}) { |m| "spec/javascripts/#{m[1]}_spec.#{m[2]}" } | |
watch(%r{public/javascripts/(.+)\.(js\.coffee|js)}) { |m| "spec/javascripts/#{m[1]}_spec.#{m[2]}" } | |
watch(%r{spec/javascripts/(.+)_spec\.(js\.coffee|js)}) { |m| "spec/javascripts/#{m[1]}_spec.#{m[2]}" } | |
watch(%r{spec/javascripts/spec\.(js\.coffee|js)}) { "spec/javascripts" } | |
end | |
end | |
def wait_for_open_connection(host, port) | |
while true | |
begin | |
TCPSocket.new(host, port).close | |
return | |
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment