Created
June 15, 2010 16:08
-
-
Save mistersourcerer/439306 to your computer and use it in GitHub Desktop.
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
require "rubygems" | |
require "celerity" | |
module Screwlerity | |
class Runner | |
def initialize(browser = Celerity::Browser.new) | |
@browser = browser | |
end | |
def run_all | |
@suites = find_suites | |
@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 = @browser.text.scan(/(\d+) test\(s\), (\d+) failure\(s\)/)[0] | |
puts "#{specs_run} examples, #{specs_failed} failures" | |
end | |
end | |
def find_suites | |
default_paths = %w('/' 'javascript/spec' 'spec/javascript') | |
suites = [] | |
current_dir = Dir.pwd | |
filename_patterns = /^(spec\..+\.html)|(.+\.spec\.html)$/ | |
# find specs: | |
default_paths.each do |path| | |
current_abs_path = File.join(current_dir, path) | |
is_directory = File.exist? current_abs_path | |
if is_directory | |
files = Dir.entries(current_abs_path).select do |file| | |
file_found = !file.index(filename_patterns).nil? | |
end | |
files.map! { |element| 'file://' + ( File.join(current_abs_path, element) ) } | |
suites |= files | |
end | |
end | |
suites | |
end | |
end | |
end | |
runner = Screwlerity::Runner.new | |
runner.run_all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment