Skip to content

Instantly share code, notes, and snippets.

@samccone
Created April 4, 2013 13:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samccone/2e35182cf86a07800866 to your computer and use it in GitHub Desktop.
Save samccone/2e35182cf86a07800866 to your computer and use it in GitHub Desktop.
require 'open3'
namespace :casper do
namespace :test do
task :start_jasmine_runner => :environment do
Open3.popen3("rails s -p 5555")
# TODO MAKE THIS NOT BE A SIMPLE WAIT
sleep 30
puts "Rails + jasminerice started!"
end
task :run_casperjs => :environment do
sh "bundle exec casperjs test --verbose=true --log-level=debug --direct --includes=casperjs/helpers/base.coffee casperjs/tests/"
end
task :stop_jasmine_runner => :environment do
sin, sout, serr = Open3.popen3("ps aux | grep 5555")
lines = sout.readlines
line = lines.grep(/.5555/)
raise "Could not locate running test rails server!" if line.empty?
pid = line[0].split()[1]
Process.kill "SIGINT", pid.to_i
puts "Rails + jasminerice stopped."
end
end
task :test => ['casper:test:start_jasmine_runner', 'casper:test:run_casperjs', 'casper:test:stop_jasmine_runner']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment