lib/qunited/runner.rb in qunited-0.0.1 vs lib/qunited/runner.rb in qunited-0.1.0

- old
+ new

@@ -1,23 +1,23 @@ module QUnited class Runner + + # The drivers in order of which to use first when not otherwise specified + DRIVERS = [:PhantomJs, :Rhino].map { |driver| ::QUnited::Driver.const_get(driver) }.freeze + def self.run(js_source_files, js_test_files) - js_runner_klass = self.js_runner - # TODO: test that this JsRunner can run with current environment - runner = js_runner_klass.new(js_source_files, js_test_files) + driver_class = self.best_available_driver + runner = driver_class.new(js_source_files, js_test_files) puts "\n# Running JavaScript tests with #{runner.name}:\n\n" - results = runner.run.results + results = runner.run puts results results.to_i end # Get the runner that we will be using to run the JavaScript tests. - # - # Right now we only have one JavaScript runner, but when we have multiple we will have to - # determine which one we will used unless explicitly configured. - def self.js_runner - ::QUnited::JsRunner::Rhino + def self.best_available_driver + DRIVERS.find { |driver| driver.available? } end end end