Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit b8dfce12e472357cbd93ccb39c6ce388d0484205 1 parent 96d4b9a
Michael Monteleone authored September 04, 2011
11  Rakefile
@@ -14,6 +14,7 @@ task :default => :test
14 14
 BROWSERS = [
15 15
   '/Applications/Safari.app/Contents/MacOS/Safari',
16 16
   '/Applications/Firefox.app/Contents/MacOS/firefox',
  17
+  '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
17 18
   '/Applications/Chromium.app/Contents/MacOS/Chromium',
18 19
   '/Applications/Opera.app/Contents/MacOS/Opera',
19 20
   'C:/Program Files/Mozilla Firefox/firefox.exe',
@@ -86,23 +87,23 @@ end
86 87
 
87 88
 desc "Run the tests against JsTestDriver"
88 89
 task :testdrive => [:build] do
89  
-  sh("java -jar spec/lib/js-test-driver/JsTestDriver.jar --tests all --captureConsole --reset")
  90
+  sh("java -jar spec/lib/js-test-driver/JsTestDriver.jar --tests all --captureConsole --reset  --basePath ./ --config spec/lib/js-test-driver/jsTestDriver.conf")
90 91
 end
91 92
 
92 93
 
93 94
 desc "Start the JsTestDriver server"
94  
-task :server => [:install_server] do
  95
+task :server => [:install_server, :build] do
95 96
   browsers = BROWSERS.find_all{|b| File.exists? b}.join(',')
96  
-  sh("java -jar spec/lib/js-test-driver/JsTestDriver.jar --port 9876 --browser \"#{browsers}\"")
  97
+  sh("java -jar spec/lib/js-test-driver/JsTestDriver.jar --port 9876  --basePath ./ --config spec/lib/js-test-driver/jsTestDriver.conf --browser \"#{browsers}\"")
97 98
 end
98 99
 
99 100
 
100 101
 desc "Download Google JsTestDriver"
101 102
 task :install_server do
102 103
   if !File.exist?('spec/lib/js-test-driver/JsTestDriver.jar') then
103  
-    puts 'Downloading JsTestDriver from Google (http://js-test-driver.googlecode.com/files/JsTestDriver-1.0b.jar) ...'
  104
+    puts 'Downloading JsTestDriver from Google (http://js-test-driver.googlecode.com/files/JsTestDriver-1.3.2.jar) ...'
104 105
     Net::HTTP.start("js-test-driver.googlecode.com") do |http|
105  
-      resp = http.get("/files/JsTestDriver-1.0b.jar")
  106
+      resp = http.get("/files/JsTestDriver-1.3.2.jar")
106 107
       open("spec/lib/js-test-driver/JsTestDriver.jar", "wb") do |file|
107 108
         file.write(resp.body)
108 109
       end
0  jsTestDriver.conf → spec/lib/js-test-driver/jsTestDriver.conf
File renamed without changes
44  spec/lib/js-test-driver/qunit/QUnitAdapter.js
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
 QUnitAdapter
3  
-Version: 1.0.1
  3
+Version: 1.1.0
4 4
 
5 5
 Run qunit tests using JS Test Driver
6 6
 
@@ -15,26 +15,32 @@ you need to set it up and tear it down in each test.
15 15
 
16 16
 */
17 17
 (function() {
18  
-   
  18
+
  19
+	if(!(window.equiv)) {
  20
+		throw new Error("QUnitAdapter.js - Unable to find equiv function. Ensure you have added equiv.js to the load section of your jsTestDriver.conf");
  21
+	}
  22
+
  23
+	var QUnitTestCase;
  24
+
19 25
     window.module = function(name, lifecycle) {
20 26
         QUnitTestCase = TestCase(name);
21  
-		QUnitTestCase.tearDown = function() {};
22  
-
23  
-        if (lifecycle) {
24  
-            QUnitTestCase.prototype.setUp = lifecycle.setup;
25  
-            QUnitTestCase.tearDown = lifecycle.teardown;
26  
-        }
  27
+        QUnitTestCase.prototype.lifecycle = lifecycle || {};
27 28
     };
28 29
     
29  
-    window.test = function(name, test) {
30  
-		var tearDown = QUnitTestCase.tearDown;
31  
-        QUnitTestCase.prototype['test ' + name] = function() {
32  
-			try {
33  
-				test();
34  
-			} catch(ex) {
35  
-				throw(ex);
36  
-			} finally {
37  
-				tearDown();
  30
+    window.test = function(name, expected, test) {
  31
+    	QUnitTestCase.prototype['test ' + name] = function() {
  32
+        	if(this.lifecycle.setup) {
  33
+        		this.lifecycle.setup();
  34
+        	}
  35
+       		if(expected.constructor === Number) {
  36
+       			expectAsserts(expected);	
  37
+       		} else {
  38
+       			test = expected;
  39
+       		}
  40
+       		test.call(this.lifecycle);
  41
+       		
  42
+			if(this.lifecycle.teardown) {
  43
+				this.lifecycle.teardown();
38 44
 			}
39 45
 		};
40 46
     };
@@ -74,4 +80,6 @@ you need to set it up and tear it down in each test.
74 80
     	ok: window.ok
75 81
     };
76 82
 
77  
-})();
  83
+	module('Default Module');
  84
+
  85
+})();
2  spec/lib/js-test-driver/qunit/equiv.js
@@ -2,7 +2,7 @@
2 2
 // Tests for equality any JavaScript type and structure without unexpected results.
3 3
 // Discussions and reference: http://philrathe.com/articles/equiv
4 4
 // Test suites: http://philrathe.com/tests/equiv
5  
-// Author: Philippe RathŽ <prathe@gmail.com>
  5
+// Author: Philippe RathŽ <prathe@gmail.com>
6 6
 window.equiv = function () {
7 7
 
8 8
     var innerEquiv; // the real equiv function
28  spec/pavlov.specs.js
@@ -18,6 +18,8 @@ pavlov.util.extend(pavlov.adapter, {
18 18
     }
19 19
 });
20 20
 
  21
+var global = this;
  22
+
21 23
 
22 24
 (function(){
23 25
     var isArray = function(obj) {
@@ -204,8 +206,8 @@ pavlov.specify("Pavlov", function() {
204 206
         });
205 207
 
206 208
         it("should not pollute the global namespace", function() {
207  
-            pavlov.util.each("describe,it,wait,assert,before,after,given".split(','), function() {
208  
-                assert(window[String(this)]).isUndefined();
  209
+            pavlov.util.each("describe,it,wait,before,after,given".split(','), function() {
  210
+                assert(global[String(this)]).isUndefined();
209 211
             });
210 212
         });
211 213
     });
@@ -410,7 +412,7 @@ pavlov.specify("Pavlov", function() {
410 412
                 var original = {
411 413
                     pause: pavlov.adapter.pause,
412 414
                     resume: pavlov.adapter.resume,
413  
-                    setTimeout: window.setTimeout
  415
+                    setTimeout: global.setTimeout
414 416
                 };
415 417
                 var calls = [];
416 418
                 var setTimeoutMs = 0;
@@ -420,7 +422,7 @@ pavlov.specify("Pavlov", function() {
420 422
                     // mock timing functions to capture their calls from wait()
421 423
                     pavlov.adapter.pause = function() { calls.push('pause'); };
422 424
                     pavlov.adapter.resume = function() { calls.push('resume'); };
423  
-                    window.setTimeout = function(fn, ms) {
  425
+                    global.setTimeout = function(fn, ms) {
424 426
                         calls.push('settimeout');
425 427
                         setTimeoutMs = ms;
426 428
                         fn();
@@ -435,7 +437,7 @@ pavlov.specify("Pavlov", function() {
435 437
                     // undo mocking
436 438
                     pavlov.adapter.pause = original.pause;
437 439
                     pavlov.adapter.resume = original.resume;
438  
-                    window.setTimeout = original.setTimeout;
  440
+                    global.setTimeout = original.setTimeout;
439 441
                 }
440 442
 
441 443
                 // check if calls to mocked fn's occurred correctly
@@ -987,12 +989,14 @@ pavlov.specify("Pavlov", function() {
987 989
         describe("initiate", function(){
988 990
             it("should update heading to suite name", function(){
989 991
                 var h1s = document.getElementsByTagName('h1');
990  
-                assert(h1s[0].innerHTML).equals('Pavlov Specifications');
  992
+                if(h1s && h1s.length > 0) {
  993
+                    assert(h1s[0].innerHTML).equals('Pavlov Specifications');
  994
+                }
991 995
             });
992 996
         });
993 997
         describe("assert", function(){
994 998
             it("should proxy QUnit's ok()", function(){
995  
-                var args = mock(window, 'ok', function(expression, message){
  999
+                var args = mock(global, 'ok', function(expression, message){
996 1000
                     pavlov.adapter.assert(true, "some message");
997 1001
                 });
998 1002
                 assert(args).contentsEqual([true, 'some message']);
@@ -1001,7 +1005,7 @@ pavlov.specify("Pavlov", function() {
1001 1005
         describe("pause", function(){
1002 1006
             it("should proxy QUnit's stop()", function(){
1003 1007
                 var stopped = false;
1004  
-                mock(window, 'stop', function(){
  1008
+                mock(global, 'stop', function(){
1005 1009
                     stopped = true;
1006 1010
                     pavlov.adapter.pause();
1007 1011
                 });
@@ -1011,7 +1015,7 @@ pavlov.specify("Pavlov", function() {
1011 1015
         describe("resume", function(){
1012 1016
             it("should proxy QUnit's start()", function(){
1013 1017
                 var started = false;
1014  
-                mock(window, 'start', function(){
  1018
+                mock(global, 'start', function(){
1015 1019
                     started = true;
1016 1020
                     pavlov.adapter.resume();
1017 1021
                 });
@@ -1021,7 +1025,7 @@ pavlov.specify("Pavlov", function() {
1021 1025
         describe("assertion extensions", function(){
1022 1026
             describe("isSameAs", function(){
1023 1027
                 it("should proxy QUnit's deepEqual()", function(){
1024  
-                    var args = mock(window, 'deepEqual', function(actual, expected, message){
  1028
+                    var args = mock(global, 'deepEqual', function(actual, expected, message){
1025 1029
                         assert('something').isSameAs('somethingElse', "some message");
1026 1030
                     });
1027 1031
                     assert(args).contentsEqual(['something','somethingElse','some message']);
@@ -1029,7 +1033,7 @@ pavlov.specify("Pavlov", function() {
1029 1033
             });
1030 1034
             describe("isNotSameAs", function(){
1031 1035
                 it("should proxy QUnit's notDeepEqual()", function(){
1032  
-                    var args = mock(window, 'notDeepEqual', function(actual, expected, message){
  1036
+                    var args = mock(global, 'notDeepEqual', function(actual, expected, message){
1033 1037
                         assert('something').isNotSameAs('somethingElse', "some message");
1034 1038
                     });
1035 1039
                     assert(args).contentsEqual(['something','somethingElse','some message']);
@@ -1039,7 +1043,7 @@ pavlov.specify("Pavlov", function() {
1039 1043
     });
1040 1044
 });
1041 1045
 
1042  
-module("Standard QUnit module");
  1046
+module("Second Standard QUnit module");
1043 1047
 var secondStandardQUnitTestRan = false;
1044 1048
 test("should be able to run after Pavlov's QUnit Adapter", function() {
1045 1049
     expect(1);

0 notes on commit b8dfce1

Please sign in to comment.
Something went wrong with that request. Please try again.