Skip to content

Instantly share code, notes, and snippets.

@jasonm
Created September 17, 2011 21:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonm/1224382 to your computer and use it in GitHub Desktop.
Save jasonm/1224382 to your computer and use it in GitHub Desktop.
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