Created
December 13, 2011 10:40
-
-
Save sousk/1471617 to your computer and use it in GitHub Desktop.
Rake task running headless JavaScript test with QUnit-Tap & PhantomJS
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
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