diff --git a/images/accept.png b/images/accept.png
new file mode 100644
index 0000000..89c8129
Binary files /dev/null and b/images/accept.png differ
diff --git a/images/exclamation.png b/images/exclamation.png
new file mode 100644
index 0000000..c37bd06
Binary files /dev/null and b/images/exclamation.png differ
diff --git a/lib/jasmine.js b/lib/jasmine.js
index 8e2e246..976ee50 100644
--- a/lib/jasmine.js
+++ b/lib/jasmine.js
@@ -20,44 +20,63 @@ Function.prototype.method = function (name, func) {
******************************************************************************/
/*
- * Jasmine expectation constructor
+ * Matchers methods; add your own with Matchers.method()
*/
-var expects = function (actual) {
- var that = {};
- that.actual = actual;
-
- that.should_equal = function(expected) {
- var message = 'Passed.';
- result = (that.actual === expected);
-
- if (!result) {
- message = 'Expected ' + expected + ' but got ' + that.actual + '.';
- }
-
- Jasmine.results.push({
- passed: result,
- message: message
- });
-
- return result;
- }
-
- return that;
+Matchers = function (actual) {
+ this.actual = actual;
+ this.passing_message = 'Passed.'
}
-var spec = function (description, func) {
+Matchers.method('report', function (result, failing_message) {
+
+ Jasmine.results.push({
+ passed: result,
+ message: result ? this.passing_message : failing_message
+ });
+
+ return result;
+});
+
+Matchers.method('should_equal', function (expected) {
+ return this.report((this.actual === expected),
+ 'Expected ' + expected + ' but got ' + this.actual + '.');
+
+});
+
+Matchers.method('should_not_equal', function (expected) {
+ return this.report((this.actual !== expected),
+ 'Expected ' + expected + ' to not equal ' + this.actual + ', but it does.');
+});
+
+/*
+ * expects helper method that allows for chaining Matcher
+ */
+var expects_that = function (actual) {
+ return new Matchers(actual);
+}
+
+/*
+ * Jasmine spec constructor
+ */
+var it = function (description, func) {
return {
description: description,
execute: func
}
}
+/*
+ * Jasmine constructor
+ */
var jasmine_init = function () {
return {
results: []
}
}
+/*
+ * Jasmine instance
+ */
var Jasmine = jasmine_init();
// spec: {
@@ -78,4 +97,3 @@ var Jasmine = jasmine_init();
//var JasmineSpec = function(description, func) {
//
//}
-
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
new file mode 100644
index 0000000..c1f155a
--- /dev/null
+++ b/nbproject/private/private.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/test/bootstrap.html b/test/bootstrap.html
new file mode 100644
index 0000000..6ce59ac
--- /dev/null
+++ b/test/bootstrap.html
@@ -0,0 +1,30 @@
+
+
+
+ Jasmine Tests
+
+
+
+
+
+
+
+ Running all Jasmine Test Suites
+
+
+
+
+
+
+
+
+
diff --git a/test/bootstrap.js b/test/bootstrap.js
new file mode 100644
index 0000000..1d09c3a
--- /dev/null
+++ b/test/bootstrap.js
@@ -0,0 +1,140 @@
+// Bootstrap Test Reporter function
+var reporter = function () {
+
+ var total = 0;
+ var passes = 0;
+ var fails = 0;
+
+ var that = {
+ test: function (result, message) {
+ total++;
+
+ if (result) {
+ passes++;
+ iconElement = $('icons');
+ iconElement.appendChild(new Element('img', {src: '../images/accept.png'}));
+ }
+ else {
+ fails++;
+ var failsHeader = $('fails_header');
+ failsHeader.show();
+
+ iconElement = $('icons');
+ iconElement.appendChild(new Element('img', {src: '../images/exclamation.png'}));
+
+ var failMessages = $('fail_messages');
+ 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();
+ }
+ }
+ return that;
+}();
+
+var testMatchersComparisons = function () {
+ Jasmine = jasmine_init();
+
+ reporter.test(expects_that(true).should_equal(true),
+ 'expects_that(true).should_equal(true) returned false');
+
+ reporter.test(!(expects_that(false).should_equal(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');
+
+ reporter.test(!(expects_that(true).should_not_equal(true)),
+ 'expects_that(true).should_not_equal(false) retruned true');
+}
+
+var testMatchersReporting = function () {
+ Jasmine = jasmine_init();
+
+ expects_that(true).should_equal(true);
+ expects_that(false).should_equal(true);
+
+ reporter.test((Jasmine.results.length == 2),
+ "Jasmine results array doesn't have 2 results");
+
+ reporter.test((Jasmine.results[0].passed == true),
+ "First spec didn't pass");
+
+ reporter.test((Jasmine.results[1].passed == false),
+ "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");
+
+ Jasmine = jasmine_init();
+
+ expects_that(true).should_equal(true);
+
+ reporter.test((Jasmine.results[0].message == 'Passed.'),
+ "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");
+
+ Jasmine = jasmine_init();
+ var another_spec = it('another spec', function () {
+ var foo = 'bar';
+ expects_that(foo).should_equal('bar');
+ });
+ another_spec.execute();
+
+ reporter.test((Jasmine.results.length == 1),
+ "Results aren't there after a spec was executed");
+ reporter.test((Jasmine.results[0].passed == true),
+ "Results has a result, but it's true");
+
+ Jasmine = jasmine_init();
+ var yet_another_spec = it('spec with failing expectation', function () {
+ var foo = 'bar';
+ expects_that(foo).should_equal('baz');
+ });
+ yet_another_spec.execute();
+
+ reporter.test((Jasmine.results[0].passed == false),
+ "Expectation that failed, passed");
+
+ Jasmine = jasmine_init();
+ var yet_yet_another_spec = it('spec with multiple assertions', function () {
+ var foo = 'bar';
+ var baz = 'quux';
+
+ expects_that(foo).should_equal('bar');
+ expects_that(baz).should_equal('quux');
+ });
+ yet_yet_another_spec.execute();
+
+ reporter.test((Jasmine.results.length == 2),
+ "Spec doesn't support multiple expectations");
+}
+
+var runTests = function () {
+ $('spinner').show();
+
+ testMatchersComparisons();
+ testMatchersReporting();
+ testSpecs();
+
+ $('spinner').hide();
+ reporter.summary();
+}
\ No newline at end of file
diff --git a/test/prototype-1.6.0.3.js b/test/prototype-1.6.0.3.js
new file mode 100644
index 0000000..dfe8ab4
--- /dev/null
+++ b/test/prototype-1.6.0.3.js
@@ -0,0 +1,4320 @@
+/* Prototype JavaScript framework, version 1.6.0.3
+ * (c) 2005-2008 Sam Stephenson
+ *
+ * Prototype is freely distributable under the terms of an MIT-style license.
+ * For details, see the Prototype web site: http://www.prototypejs.org/
+ *
+ *--------------------------------------------------------------------------*/
+
+var Prototype = {
+ Version: '1.6.0.3',
+
+ Browser: {
+ IE: !!(window.attachEvent &&
+ navigator.userAgent.indexOf('Opera') === -1),
+ Opera: navigator.userAgent.indexOf('Opera') > -1,
+ WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
+ Gecko: navigator.userAgent.indexOf('Gecko') > -1 &&
+ navigator.userAgent.indexOf('KHTML') === -1,
+ MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
+ },
+
+ BrowserFeatures: {
+ XPath: !!document.evaluate,
+ SelectorsAPI: !!document.querySelector,
+ ElementExtensions: !!window.HTMLElement,
+ SpecificElementExtensions:
+ document.createElement('div')['__proto__'] &&
+ document.createElement('div')['__proto__'] !==
+ document.createElement('form')['__proto__']
+ },
+
+ ScriptFragment: '
+
diff --git a/test/test.js b/test/test.js
index 2e7f951..82c71d7 100644
--- a/test/test.js
+++ b/test/test.js
@@ -3,19 +3,19 @@
with(JSpec('Jasmine expectation results')) {
- it('should compare actual and expected values that are equal', function(){
+ it('should compare actual and expected values that are equal', function () {
var jasmine_result = expects(true).should_equal(true);
expects_that(jasmine_result).should_equal(true).and_finish();
});
- it('should compare actual and expected values that are NOT equal', function(){
+ it('should compare actual and expected values that are NOT equal', function () {
var jasmine_result = expects(false).should_equal(true);
expects_that(jasmine_result).should_equal(false).and_finish();
});
- it('should be able to store the results of assertions', function(){
+ it('should be able to store the results of assertions', function () {
Jasmine = jasmine_init(); // re-clears out Jasmine
expects(true).should_equal(true);
@@ -26,7 +26,7 @@ with(JSpec('Jasmine expectation results')) {
expects_that(Jasmine.results[1].passed).should_equal(false).and_finish();
});
- it('should store a message with a failed expectation', function(){
+ it('should store a message with a failed expectation', function () {
Jasmine = jasmine_init(); // re-clears out Jasmine
expects(false).should_equal(true);
@@ -35,7 +35,7 @@ with(JSpec('Jasmine expectation results')) {
expects_that(Jasmine.results[0].message).should_equal(expected_message).and_finish();
});
- it('should store a default message with a passed expectation', function(){
+ it('should store a default message with a passed expectation', function () {
Jasmine = jasmine_init();
expects(true).should_equal(true);
@@ -44,21 +44,39 @@ with(JSpec('Jasmine expectation results')) {
expects_that(Jasmine.results[0].message).should_equal(expected_message).and_finish();
});
+ it('should support should_not_equal() passing', function () {
+ Jasmine = jasmine_init();
+
+ expects(true).should_not_equal(false);
+
+ var expected_message = 'Passed.';
+ expects_that(Jasmine.results[0].message).should_equal(expected_message).and_finish();
+ });
+
+ it('should support should_not_equal() message', function () {
+ Jasmine = jasmine_init();
+
+ expects(true).should_not_equal(true);
+
+ var expected_message = 'Expected true to not equal true, but it does.';
+ expects_that(Jasmine.results[0].message).should_equal(expected_message).and_finish();
+ });
+
}
with(JSpec('Jasmine specs')){
- it('can have a description', function(){
+ it('can have a description', function () {
Jasmine = jasmine_init();
var a_spec = spec('new spec');
expects_that(a_spec.description).should_equal('new spec').and_finish();
});
- it('can execute some statements & expectations', function(){
+ it('can execute some statements & expectations', function () {
Jasmine = jasmine_init();
- var a_spec = spec('new spec', function() {
+ var a_spec = spec('new spec', function () {
var foo = 'bar';
expects(foo).should_equal('bar');
});
@@ -68,26 +86,33 @@ with(JSpec('Jasmine specs')){
expects_that(Jasmine.results.length).should_equal(1)
expects_that(Jasmine.results[0].passed).should_equal(true).and_finish();
});
-}
-// it('should return true if all of its results are true', function(){
-// });
-// it('can have multiple assertions', function(){
-//
-// var jasmine = Jasmine();
-// jasmine.expects_that(true).should_equal(true);
-//
-// var expected_message = 'Passed.';
-// expects_that(jasmine.results[0].message).should_equal(expected_message).and_finish();
-//
+ it('can have multiple assertions', function () {
+ Jasmine = jasmine_init();
+
+ var a_spec = spec('new spec', function () {
+ var foo = 'bar';
+ var baz = 'quux'
+
+ expects(foo).should_equal('bar');
+ expects(baz).should_equal('quux');
+ });
+
+ a_spec.execute();
+
+ expects_that(Jasmine.results.length).should_equal(2).and_finish();
+ });
+
+// it('can evaluate expectations after an asynchronous set of execution steps', function () {
// });
-//}
+}
+// should be able to run multiple specs in a suite in order
//with(JSpec('Test runner')) {
//
-// it('should run a test and collect a result', function(){
+// it('should run a test and collect a result', function () {
//
//
//