diff --git a/images/accept.png b/images/accept.png
old mode 100644
new mode 100755
diff --git a/images/exclamation.png b/images/exclamation.png
old mode 100644
new mode 100755
diff --git a/jasmine.iml b/jasmine.iml
old mode 100644
new mode 100755
diff --git a/jasmine.ipr b/jasmine.ipr
old mode 100644
new mode 100755
diff --git a/jasmine.iws b/jasmine.iws
index a3c3c38..646707e 100644
--- a/jasmine.iws
+++ b/jasmine.iws
@@ -77,13 +77,31 @@
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -92,25 +110,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -166,7 +166,7 @@
-
+
@@ -180,11 +180,11 @@
-
+
-
+
@@ -198,11 +198,11 @@
-
+
-
+
@@ -216,11 +216,11 @@
-
+
-
+
@@ -234,15 +234,15 @@
-
+
-
+
-
+
@@ -266,6 +266,7 @@
+
@@ -297,19 +298,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -331,6 +319,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -394,33 +395,33 @@
-
+
-
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
@@ -490,33 +491,57 @@
-
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
+
-
+
diff --git a/lib/jasmine.js b/lib/jasmine.js
old mode 100644
new mode 100755
index 976ee50..b46c2cd
--- a/lib/jasmine.js
+++ b/lib/jasmine.js
@@ -10,9 +10,11 @@ if (typeof Object.create !== 'function') {
}
// Klass.method instead of Klass.prototype.name = function
-Function.prototype.method = function (name, func) {
- this.prototype[name] = func;
- return this;
+if (typeof Function.method !== 'function') {
+ Function.prototype.method = function (name, func) {
+ this.prototype[name] = func;
+ return this;
+ }
}
/******************************************************************************
@@ -49,7 +51,7 @@ Matchers.method('should_not_equal', function (expected) {
});
/*
- * expects helper method that allows for chaining Matcher
+ * expects_hat helper method that allows for chaining Matcher
*/
var expects_that = function (actual) {
return new Matchers(actual);
@@ -59,12 +61,45 @@ var expects_that = function (actual) {
* Jasmine spec constructor
*/
var it = function (description, func) {
- return {
+ var that = {
description: description,
- execute: func
+ func: func,
+ done: false,
+ execute: function() {
+ that.func.apply(that);
+ }
}
+ return that;
}
+var it_async = function (description) {
+ var that = {
+ description: description,
+ queue: [],
+ waits: function (timeout) {
+ return that;
+ },
+ done: false,
+ execute: function () {
+ for(i = 0; i < that.queue.length; i++) {
+ that.queue[i]();
+ }
+ }
+
+};
+
+ var addToQueue = function(func) {
+ that.queue.push(func);
+ return that;
+ }
+
+ that.runs = addToQueue;
+ that.then = addToQueue;
+
+ return that;
+}
+
+
/*
* Jasmine constructor
*/
@@ -79,21 +114,27 @@ var jasmine_init = function () {
*/
var Jasmine = jasmine_init();
-// spec: {
-// description: description,
-// func: func,
-// execute: function() {with(jasmine) {func();}}
-// },
-//
-// expects_that: function(actual) {
-//
-// this.actual = actual;
-// return this;
-// },
-//
-// }
-//}
-//
-//var JasmineSpec = function(description, func) {
-//
-//}
+/*
+ * TODO:
+ * - add spec or description to results
+ * - spec.execute needs to wait until the spec is done
+ * - an async test will be killed after X ms if not done and then listed as failed with an "async fail" message of some sort
+ * - Suite to run tests in order, constructed with a function called describe
+ * - Suite supports before
+ * - Suite supports after
+ * - Suite supports before_each
+ * - Suite supports after_each
+ * - Suite supports asynch
+ * - Runner that runs suites in order
+ * - Runner supports async
+ * - HTML reporter
+ * - Shows pass/fail progress (just like bootstrap reporter)
+ * - Lists a Summary: total # specs, # of passed, # of failed
+ * - Failed reports lists all specs that failed and what the failure was
+ * - Failed output is styled with red
+ * - JSON reporter
+ * - Lists full results as a JSON object/string
+ * - Luna reporter
+ * - each result calls back into widgets for rendering to Luna views
+ */
+
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
old mode 100644
new mode 100755
diff --git a/nbproject/project.properties b/nbproject/project.properties
old mode 100644
new mode 100755
diff --git a/nbproject/project.xml b/nbproject/project.xml
old mode 100644
new mode 100755
diff --git a/test/bootstrap.html b/test/bootstrap.html
old mode 100644
new mode 100755
index 6ce59ac..054c6c7
--- a/test/bootstrap.html
+++ b/test/bootstrap.html
@@ -19,8 +19,8 @@
Summary
-
diff --git a/test/bootstrap.js b/test/bootstrap.js
old mode 100644
new mode 100755
index 1d09c3a..87bfb55
--- a/test/bootstrap.js
+++ b/test/bootstrap.js
@@ -16,25 +16,26 @@ var reporter = function () {
}
else {
fails++;
- var failsHeader = $('fails_header');
- failsHeader.show();
+ var fails_report = $('fails');
+ fails_report.show();
iconElement = $('icons');
iconElement.appendChild(new Element('img', {src: '../images/exclamation.png'}));
var failMessages = $('fail_messages');
- var newFail = new Element('p', {class: 'fail'});
+ var newFail = new Element('p', {'class': 'fail'});
newFail.innerHTML = message;
failMessages.appendChild(newFail);
}
},
summary: function () {
- summary = new Element('p', {class: ((fails > 0) ? 'fail_in_summary' : '') });
- summary.innerHTML = total + ' tests, ' + passes + ' passing, ' + fails + ' failed.';
- var summaryElement = $('results_summary');
- summaryElement.appendChild(summary);
- summaryElement.show();
+ summary = new Element('p', {'class': ((fails > 0) ? 'fail_in_summary' : '') });
+ summary.innerHTML = total + ' tests, ' + passes + ' passing, ' + fails + ' failed.';
+
+ var summaryElement = $('results_summary');
+ summaryElement.appendChild(summary);
+ summaryElement.show();
}
}
return that;
@@ -42,18 +43,17 @@ var reporter = function () {
var testMatchersComparisons = function () {
Jasmine = jasmine_init();
-
reporter.test(expects_that(true).should_equal(true),
- 'expects_that(true).should_equal(true) returned false');
+ 'expects_that(true).should_equal(true) returned false');
reporter.test(!(expects_that(false).should_equal(true)),
- 'expects_that(true).should_equal(true) returned true');
+ 'expects_that(true).should_equal(true) returned true');
reporter.test(expects_that(true).should_not_equal(false),
- 'expects_that(true).should_not_equal(false) retruned false');
+ 'expects_that(true).should_not_equal(false) retruned false');
reporter.test(!(expects_that(true).should_not_equal(true)),
- 'expects_that(true).should_not_equal(false) retruned true');
+ 'expects_that(true).should_not_equal(false) retruned true');
}
var testMatchersReporting = function () {
@@ -63,46 +63,47 @@ var testMatchersReporting = function () {
expects_that(false).should_equal(true);
reporter.test((Jasmine.results.length == 2),
- "Jasmine results array doesn't have 2 results");
+ "Jasmine results array doesn't have 2 results");
reporter.test((Jasmine.results[0].passed == true),
- "First spec didn't pass");
+ "First spec didn't pass");
reporter.test((Jasmine.results[1].passed == false),
- "Second spec did pass");
+ "Second spec did pass");
Jasmine = jasmine_init();
expects_that(false).should_equal(true);
reporter.test((Jasmine.results[0].message == 'Expected true but got false.'),
- "Failed expectation didn't test the failure message");
+ "Failed expectation didn't test the failure message");
Jasmine = jasmine_init();
expects_that(true).should_equal(true);
reporter.test((Jasmine.results[0].message == 'Passed.'),
- "Passing expectation didn't test the passing message");
+ "Passing expectation didn't test the passing message");
}
var testSpecs = function () {
Jasmine = jasmine_init();
var spec = it('new spec');
reporter.test((spec.description == 'new spec'),
- "Spec did not have a description");
+ "Spec did not have a description");
Jasmine = jasmine_init();
- var another_spec = it('another spec', function () {
+ var another_spec = it('spec with an expectation', function () {
var foo = 'bar';
expects_that(foo).should_equal('bar');
});
another_spec.execute();
+ another_spec.done = true;
reporter.test((Jasmine.results.length == 1),
- "Results aren't there after a spec was executed");
+ "Results aren't there after a spec was executed");
reporter.test((Jasmine.results[0].passed == true),
- "Results has a result, but it's true");
+ "Results has a result, but it's true");
Jasmine = jasmine_init();
var yet_another_spec = it('spec with failing expectation', function () {
@@ -110,9 +111,10 @@ var testSpecs = function () {
expects_that(foo).should_equal('baz');
});
yet_another_spec.execute();
+ another_spec.done = true;
reporter.test((Jasmine.results[0].passed == false),
- "Expectation that failed, passed");
+ "Expectation that failed, passed");
Jasmine = jasmine_init();
var yet_yet_another_spec = it('spec with multiple assertions', function () {
@@ -123,18 +125,76 @@ var testSpecs = function () {
expects_that(baz).should_equal('quux');
});
yet_yet_another_spec.execute();
+ another_spec.done = true;
reporter.test((Jasmine.results.length == 2),
- "Spec doesn't support multiple expectations");
+ "Spec doesn't support multiple expectations");
+}
+
+var testAsyncSpecs = function () {
+ Jasmine = jasmine_init();
+ var foo = 0;
+
+ var a_spec = it_async('simple queue test').
+ runs(function () {
+ foo++;
+ }).then(function() {
+ expects_that(foo).should_equal(1)
+ });
+
+ reporter.test(a_spec.queue.length === 2,
+ 'Spec queue length is not 2');
+
+ Jasmine = jasmine_init();
+ foo = 0;
+ a_spec = it_async('spec w/ queued statments').
+ runs(function () {
+ foo++;
+ }).then(function() {
+ expects_that(foo).should_equal(1)
+ });
+
+ a_spec.execute();
+
+ reporter.test((Jasmine.results.length === 1),
+ 'Spec queue did not run all functions');
+ reporter.test((Jasmine.results[0].passed === true),
+ 'Queued expectation failed');
+
+ Jasmine = jasmine_init();
+ foo = 0;
+ a_spec = it_async('spec w/ queued statments').
+ runs(function () {
+ setTimeout(function() {
+ foo++
+ }, 500);
+ }).waits(1000).then(function() {
+ expects_that(foo).should_equal(1);
+ });
+
+ a_spec.execute();
+
+ reporter.test((Jasmine.results.length === 1),
+ 'Spec queue did not run all functions');
+
+ reporter.test((Jasmine.results[0].passed === true),
+ 'Queued expectation failed');
}
var runTests = function () {
$('spinner').show();
- testMatchersComparisons();
- testMatchersReporting();
- testSpecs();
+// testMatchersComparisons();
+ // testMatchersReporting();
+ // testSpecs();
+ testAsyncSpecs();
$('spinner').hide();
reporter.summary();
-}
\ No newline at end of file
+}
+
+ //it('should be an async test') {
+ // run(function() {setup}).and.wait(2000).then.expects_that(true).should_equal(true).and.expects_that
+ //}
+
+
diff --git a/test/prototype-1.6.0.3.js b/test/prototype-1.6.0.3.js
old mode 100644
new mode 100755
diff --git a/test/spinner.gif b/test/spinner.gif
old mode 100644
new mode 100755
diff --git a/test/test.css b/test/test.css
old mode 100644
new mode 100755
diff --git a/test/test.html b/test/test.html
old mode 100644
new mode 100755
diff --git a/test/test.js b/test/test.js
old mode 100644
new mode 100755