Created
October 7, 2008 11:08
-
-
Save songkick/15273 to your computer and use it in GitHub Desktop.
very basic spike of using celerity to drive screw-unit javascript specs
This file contains 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
#!/usr/bin/env jruby | |
# fast script for running javascript unit tests | |
# requires a bit of setup, as it uses jruby | |
# see http://celerity.rubyforge.org/ | |
require "rubygems" | |
require "celerity" | |
module Javascript | |
class SpecRunner | |
def initialize(suites, browser = Celerity::Browser.new) | |
@browser = browser | |
@suites = suites | |
end | |
def run_all | |
@suites.each do |suite| | |
@browser.goto(suite) | |
puts "Running Javascript specs in #{suite}" | |
sleep(0.1) until @browser.text.include?("test(s)") | |
specs_run, specs_failed, duration = @browser.text.scan(/(\d+) test\(s\), (\d+) failure\(s\) (\d+\.\d+) seconds elapsed/)[0] | |
puts "Finished in #{duration} seconds" | |
puts | |
puts "#{specs_run} examples, #{specs_failed} failures" | |
end | |
end | |
end | |
end | |
# TODO: scan for files, and don't hardcode the path! | |
suites = ['file://localhost/Users/matt/projects/songkick/skweb/spec/javascripts/comments_spec.html'] | |
runner = Javascript::SpecRunner.new(suites) | |
runner.run_all | |
puts "ENTER to run again." | |
while readline == "\n" | |
runner.run_all | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment