GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: A JavaScript BDD Testing Library
Homepage: http://www.yehudakatz.com
Clone URL: git://github.com/wycats/jspec.git
Prettier console.logs
wycats (author)
Thu Jan 17 01:06:01 -0800 2008
commit  798da3d0aa19f5456efcbe8b5ba1df4628c5207b
tree    2ec2147e5652fd8bf9d99eddf33068fecce0d8b7
parent  7860e59d803f330f3c3955eae7cde9e7994bfda9
...
2
3
4
5
6
7
8
 
 
9
10
11
12
 
13
14
15
 
16
17
18
 
 
 
 
 
19
20
21
 
 
 
 
 
22
 
 
23
24
25
...
28
29
30
 
31
32
33
...
41
42
43
44
 
45
46
 
47
48
49
...
53
54
55
 
56
57
58
...
2
3
4
 
 
 
 
5
6
7
8
9
 
10
11
12
 
13
14
 
 
15
16
17
18
19
20
21
 
22
23
24
25
26
27
28
29
30
31
32
...
35
36
37
38
39
40
41
...
49
50
51
 
52
53
 
54
55
56
57
...
61
62
63
64
65
66
67
0
@@ -2,24 +2,31 @@ jspec = {
0
   fn_contents: function(fn) {
0
     return fn.toString().match(/^[^\{]*{((.*\n*)*)}/m)[1];
0
   },
0
- TOP_LEVEL: 0,
0
- DESCRIBE: 1,
0
- IT_SHOULD: 2,
0
- FAILURE: 3,
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
     switch(state) {
0
       case jspec.TOP_LEVEL:
0
- console.log(message);
0
+ console.group(message);
0
         break;
0
       case jspec.DESCRIBE:
0
- console.log("- " + message);
0
+ console.group(message);
0
         break;
0
- case jspec.IT_SHOULD:
0
- console.log(" - " + message);
0
+ case jspec.IT_SHOULD_PASS:
0
+ console.info(message);
0
+ break;
0
+ case jspec.IT_SHOULD_FAIL:
0
+ console.group(message);
0
         break;
0
       case jspec.FAILURE:
0
- console.log(" " + message);
0
+ console.error(message);
0
+ console.groupEnd();
0
+ break;
0
+ case jspec.DONE_EXAMPLE:
0
+ console.groupEnd();
0
         break;
0
+ case jspec.DONE_GROUP:
0
+ console.groupEnd();
0
     }
0
     
0
   },
0
@@ -28,6 +35,7 @@ jspec = {
0
     var it = function(str, fn) {
0
       jspec.logger(jspec.DESCRIBE, str);
0
       fn();
0
+ jspec.logger(jspec.DONE_EXAMPLE);
0
     };
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
       if(pass) {
0
- jspec.logger(jspec.IT_SHOULD, should_string + " (PASS)");
0
+ jspec.logger(jspec.IT_SHOULD_PASS, should_string + " (PASS)");
0
       }  else {
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
       }
0
     }
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);
0
   }
0
 }
0
 

Comments

    No one has commented yet.