0
@@ -2,24 +2,31 @@ jspec = {
0
fn_contents: function(fn) {
0
return fn.toString().match(/^[^\{]*{((.*\n*)*)}/m)[1];
0
+ TOP_LEVEL: 0, DESCRIBE: 1, IT_SHOULD_PASS: 2, IT_SHOULD_FAIL: 3,
0
+ FAILURE: 4, DONE_EXAMPLE: 5, DONE_GROUP: 6,
0
logger: function(state, message) {
0
+ console.
group(message);
0
- console.
log("- " + message);
0
+ console.
group(message);
0
- console.log(" - " + message);
0
+ case jspec.IT_SHOULD_PASS:
0
+ console.info(message);
0
+ case jspec.IT_SHOULD_FAIL:
0
+ console.group(message);
0
- console.log(" " + message);
0
+ console.error(message);
0
+ case jspec.DONE_EXAMPLE:
0
+ case jspec.DONE_GROUP:
0
@@ -28,6 +35,7 @@ jspec = {
0
var it = function(str, fn) {
0
jspec.logger(jspec.DESCRIBE, str);
0
+ jspec.logger(jspec.DONE_EXAMPLE);
0
var Expectation = function(p) { this.expectation = p; };
0
Expectation.prototype.to = function(fn_str, to_compare, not) {
0
@@ -41,9 +49,9 @@ jspec = {
0
jspec.matchers[fn_str].describe(this.expectation, to_compare, not)) ||
0
this.toString() + " should " + (not ? "not " : "") + fn_str + " " + to_compare;
0
- jspec.logger(jspec.IT_SHOULD
, should_string + " (PASS)");
0
+ jspec.logger(jspec.IT_SHOULD
_PASS, should_string + " (PASS)");
0
- jspec.logger(jspec.IT_SHOULD
, should_string + (pass == false ? " (FAIL)" : " (ERROR)"));
0
+ jspec.logger(jspec.IT_SHOULD
_FAIL, should_string + (pass == false ? " (FAIL)" : " (ERROR)"));
0
jspec.logger(jspec.FAILURE, jspec.matchers[fn_str].failure_message(this.expectation, to_compare, not))
0
@@ -53,6 +61,7 @@ jspec = {
0
var fn_body = this.fn_contents(desc);
0
var fn = new Function("it", "expect", fn_body);
0
fn.call(this, it, expect);
0
+ jspec.logger(jspec.DONE_GROUP);
Comments
No one has commented yet.