Skip to content

Instantly share code, notes, and snippets.

@sousk
Created December 13, 2011 10:40
Show Gist options
  • Save sousk/1471617 to your computer and use it in GitHub Desktop.
Save sousk/1471617 to your computer and use it in GitHub Desktop.
Rake task running headless JavaScript test with QUnit-Tap & PhantomJS
namespace :test do
desc "run headless test"
task :run do
tg = ENV['target'];
runner = 'tmp.sh'
unless tg
puts "an argument required: target=path_to_test.hml"
exit
end
url = File.expand_path tg
Dir.chdir('test') do
File.open(runner,'w') { |f|
f.puts "#!/bin/sh"
f.puts "phantomjs run_qunit.js file://#{url}"
}
opts = if ENV['v'] || ENV['verbose']
%w(-v)
else
[]
end
system "prove #{opts.join(' ')} #{runner}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment