Permalink
Browse files

Updated usage of js-test-driver, driver qunit adapter, and driver-cap…

…tured browser list. moved test driver config out of root and updated suite to appease test driver
  • Loading branch information...
1 parent 96d4b9a commit b8dfce12e472357cbd93ccb39c6ce388d0484205 @mmonteleone committed Sep 4, 2011
View
@@ -14,6 +14,7 @@ task :default => :test
BROWSERS = [
'/Applications/Safari.app/Contents/MacOS/Safari',
'/Applications/Firefox.app/Contents/MacOS/firefox',
+ '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
'/Applications/Chromium.app/Contents/MacOS/Chromium',
'/Applications/Opera.app/Contents/MacOS/Opera',
'C:/Program Files/Mozilla Firefox/firefox.exe',
@@ -86,23 +87,23 @@ end
desc "Run the tests against JsTestDriver"
task :testdrive => [:build] do
- sh("java -jar spec/lib/js-test-driver/JsTestDriver.jar --tests all --captureConsole --reset")
+ sh("java -jar spec/lib/js-test-driver/JsTestDriver.jar --tests all --captureConsole --reset --basePath ./ --config spec/lib/js-test-driver/jsTestDriver.conf")
end
desc "Start the JsTestDriver server"
-task :server => [:install_server] do
+task :server => [:install_server, :build] do
browsers = BROWSERS.find_all{|b| File.exists? b}.join(',')
- sh("java -jar spec/lib/js-test-driver/JsTestDriver.jar --port 9876 --browser \"#{browsers}\"")
+ sh("java -jar spec/lib/js-test-driver/JsTestDriver.jar --port 9876 --basePath ./ --config spec/lib/js-test-driver/jsTestDriver.conf --browser \"#{browsers}\"")
end
desc "Download Google JsTestDriver"
task :install_server do
if !File.exist?('spec/lib/js-test-driver/JsTestDriver.jar') then
- puts 'Downloading JsTestDriver from Google (http://js-test-driver.googlecode.com/files/JsTestDriver-1.0b.jar) ...'
+ puts 'Downloading JsTestDriver from Google (http://js-test-driver.googlecode.com/files/JsTestDriver-1.3.2.jar) ...'
Net::HTTP.start("js-test-driver.googlecode.com") do |http|
- resp = http.get("/files/JsTestDriver-1.0b.jar")
+ resp = http.get("/files/JsTestDriver-1.3.2.jar")
open("spec/lib/js-test-driver/JsTestDriver.jar", "wb") do |file|
file.write(resp.body)
end
File renamed without changes.
@@ -1,6 +1,6 @@
/*
QUnitAdapter
-Version: 1.0.1
+Version: 1.1.0
Run qunit tests using JS Test Driver
@@ -15,26 +15,32 @@ you need to set it up and tear it down in each test.
*/
(function() {
-
+
+ if(!(window.equiv)) {
+ throw new Error("QUnitAdapter.js - Unable to find equiv function. Ensure you have added equiv.js to the load section of your jsTestDriver.conf");
+ }
+
+ var QUnitTestCase;
+
window.module = function(name, lifecycle) {
QUnitTestCase = TestCase(name);
- QUnitTestCase.tearDown = function() {};
-
- if (lifecycle) {
- QUnitTestCase.prototype.setUp = lifecycle.setup;
- QUnitTestCase.tearDown = lifecycle.teardown;
- }
+ QUnitTestCase.prototype.lifecycle = lifecycle || {};
};
- window.test = function(name, test) {
- var tearDown = QUnitTestCase.tearDown;
- QUnitTestCase.prototype['test ' + name] = function() {
- try {
- test();
- } catch(ex) {
- throw(ex);
- } finally {
- tearDown();
+ window.test = function(name, expected, test) {
+ QUnitTestCase.prototype['test ' + name] = function() {
+ if(this.lifecycle.setup) {
+ this.lifecycle.setup();
+ }
+ if(expected.constructor === Number) {
+ expectAsserts(expected);
+ } else {
+ test = expected;
+ }
+ test.call(this.lifecycle);
+
+ if(this.lifecycle.teardown) {
+ this.lifecycle.teardown();
}
};
};
@@ -74,4 +80,6 @@ you need to set it up and tear it down in each test.
ok: window.ok
};
-})();
+ module('Default Module');
+
+})();
@@ -2,7 +2,7 @@
// Tests for equality any JavaScript type and structure without unexpected results.
// Discussions and reference: http://philrathe.com/articles/equiv
// Test suites: http://philrathe.com/tests/equiv
-// Author: Philippe RathŽ <prathe@gmail.com>
+// Author: Philippe RathŽ <prathe@gmail.com>
window.equiv = function () {
var innerEquiv; // the real equiv function
View
@@ -18,6 +18,8 @@ pavlov.util.extend(pavlov.adapter, {
}
});
+var global = this;
+
(function(){
var isArray = function(obj) {
@@ -204,8 +206,8 @@ pavlov.specify("Pavlov", function() {
});
it("should not pollute the global namespace", function() {
- pavlov.util.each("describe,it,wait,assert,before,after,given".split(','), function() {
- assert(window[String(this)]).isUndefined();
+ pavlov.util.each("describe,it,wait,before,after,given".split(','), function() {
+ assert(global[String(this)]).isUndefined();
});
});
});
@@ -410,7 +412,7 @@ pavlov.specify("Pavlov", function() {
var original = {
pause: pavlov.adapter.pause,
resume: pavlov.adapter.resume,
- setTimeout: window.setTimeout
+ setTimeout: global.setTimeout
};
var calls = [];
var setTimeoutMs = 0;
@@ -420,7 +422,7 @@ pavlov.specify("Pavlov", function() {
// mock timing functions to capture their calls from wait()
pavlov.adapter.pause = function() { calls.push('pause'); };
pavlov.adapter.resume = function() { calls.push('resume'); };
- window.setTimeout = function(fn, ms) {
+ global.setTimeout = function(fn, ms) {
calls.push('settimeout');
setTimeoutMs = ms;
fn();
@@ -435,7 +437,7 @@ pavlov.specify("Pavlov", function() {
// undo mocking
pavlov.adapter.pause = original.pause;
pavlov.adapter.resume = original.resume;
- window.setTimeout = original.setTimeout;
+ global.setTimeout = original.setTimeout;
}
// check if calls to mocked fn's occurred correctly
@@ -987,12 +989,14 @@ pavlov.specify("Pavlov", function() {
describe("initiate", function(){
it("should update heading to suite name", function(){
var h1s = document.getElementsByTagName('h1');
- assert(h1s[0].innerHTML).equals('Pavlov Specifications');
+ if(h1s && h1s.length > 0) {
+ assert(h1s[0].innerHTML).equals('Pavlov Specifications');
+ }
});
});
describe("assert", function(){
it("should proxy QUnit's ok()", function(){
- var args = mock(window, 'ok', function(expression, message){
+ var args = mock(global, 'ok', function(expression, message){
pavlov.adapter.assert(true, "some message");
});
assert(args).contentsEqual([true, 'some message']);
@@ -1001,7 +1005,7 @@ pavlov.specify("Pavlov", function() {
describe("pause", function(){
it("should proxy QUnit's stop()", function(){
var stopped = false;
- mock(window, 'stop', function(){
+ mock(global, 'stop', function(){
stopped = true;
pavlov.adapter.pause();
});
@@ -1011,7 +1015,7 @@ pavlov.specify("Pavlov", function() {
describe("resume", function(){
it("should proxy QUnit's start()", function(){
var started = false;
- mock(window, 'start', function(){
+ mock(global, 'start', function(){
started = true;
pavlov.adapter.resume();
});
@@ -1021,15 +1025,15 @@ pavlov.specify("Pavlov", function() {
describe("assertion extensions", function(){
describe("isSameAs", function(){
it("should proxy QUnit's deepEqual()", function(){
- var args = mock(window, 'deepEqual', function(actual, expected, message){
+ var args = mock(global, 'deepEqual', function(actual, expected, message){
assert('something').isSameAs('somethingElse', "some message");
});
assert(args).contentsEqual(['something','somethingElse','some message']);
});
});
describe("isNotSameAs", function(){
it("should proxy QUnit's notDeepEqual()", function(){
- var args = mock(window, 'notDeepEqual', function(actual, expected, message){
+ var args = mock(global, 'notDeepEqual', function(actual, expected, message){
assert('something').isNotSameAs('somethingElse', "some message");
});
assert(args).contentsEqual(['something','somethingElse','some message']);
@@ -1039,7 +1043,7 @@ pavlov.specify("Pavlov", function() {
});
});
-module("Standard QUnit module");
+module("Second Standard QUnit module");
var secondStandardQUnitTestRan = false;
test("should be able to run after Pavlov's QUnit Adapter", function() {
expect(1);

0 comments on commit b8dfce1

Please sign in to comment.