oojspec 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +174 -0
- data/Rakefile +27 -0
- data/app/views/oojspec/runner.html.erb +25 -0
- data/lib/assets/javascripts/oojspec.js.coffee +256 -0
- data/lib/assets/stylesheets/oojspec.css.erb +5 -0
- data/lib/oojspec/engine.rb +15 -0
- data/lib/oojspec/version.rb +3 -0
- data/lib/oojspec.rb +5 -0
- data/lib/tasks/oojspec_tasks.rake +4 -0
- data/vendor/assets/images/buster/logo.png +0 -0
- data/vendor/assets/javascripts/buster/all.js.coffee +3 -0
- data/vendor/assets/javascripts/buster/buster-assertions.js +782 -0
- data/vendor/assets/javascripts/buster/buster-core.js +222 -0
- data/vendor/assets/javascripts/buster/buster-event-emitter.js +152 -0
- data/vendor/assets/javascripts/buster/buster-format.js +199 -0
- data/vendor/assets/javascripts/buster/expect.js +63 -0
- data/vendor/assets/javascripts/buster/html.js +324 -0
- data/vendor/assets/javascripts/buster/stack-filter.js +63 -0
- data/vendor/assets/stylesheets/buster/buster-test.css +201 -0
- metadata +104 -0
@@ -0,0 +1,222 @@
|
|
1
|
+
var buster = (function (setTimeout, B) {
|
2
|
+
var isNode = typeof require == "function" && typeof module == "object";
|
3
|
+
var div = typeof document != "undefined" && document.createElement("div");
|
4
|
+
var F = function () {};
|
5
|
+
|
6
|
+
var buster = {
|
7
|
+
bind: function bind(obj, methOrProp) {
|
8
|
+
var method = typeof methOrProp == "string" ? obj[methOrProp] : methOrProp;
|
9
|
+
var args = Array.prototype.slice.call(arguments, 2);
|
10
|
+
return function () {
|
11
|
+
var allArgs = args.concat(Array.prototype.slice.call(arguments));
|
12
|
+
return method.apply(obj, allArgs);
|
13
|
+
};
|
14
|
+
},
|
15
|
+
|
16
|
+
partial: function partial(fn) {
|
17
|
+
var args = [].slice.call(arguments, 1);
|
18
|
+
return function () {
|
19
|
+
return fn.apply(this, args.concat([].slice.call(arguments)));
|
20
|
+
};
|
21
|
+
},
|
22
|
+
|
23
|
+
create: function create(object) {
|
24
|
+
F.prototype = object;
|
25
|
+
return new F();
|
26
|
+
},
|
27
|
+
|
28
|
+
extend: function extend(target) {
|
29
|
+
if (!target) { return; }
|
30
|
+
for (var i = 1, l = arguments.length, prop; i < l; ++i) {
|
31
|
+
for (prop in arguments[i]) {
|
32
|
+
target[prop] = arguments[i][prop];
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return target;
|
36
|
+
},
|
37
|
+
|
38
|
+
nextTick: function nextTick(callback) {
|
39
|
+
if (typeof process != "undefined" && process.nextTick) {
|
40
|
+
return process.nextTick(callback);
|
41
|
+
}
|
42
|
+
setTimeout(callback, 0);
|
43
|
+
},
|
44
|
+
|
45
|
+
functionName: function functionName(func) {
|
46
|
+
if (!func) return "";
|
47
|
+
if (func.displayName) return func.displayName;
|
48
|
+
if (func.name) return func.name;
|
49
|
+
var matches = func.toString().match(/function\s+([^\(]+)/m);
|
50
|
+
return matches && matches[1] || "";
|
51
|
+
},
|
52
|
+
|
53
|
+
isNode: function isNode(obj) {
|
54
|
+
if (!div) return false;
|
55
|
+
try {
|
56
|
+
obj.appendChild(div);
|
57
|
+
obj.removeChild(div);
|
58
|
+
} catch (e) {
|
59
|
+
return false;
|
60
|
+
}
|
61
|
+
return true;
|
62
|
+
},
|
63
|
+
|
64
|
+
isElement: function isElement(obj) {
|
65
|
+
return obj && obj.nodeType === 1 && buster.isNode(obj);
|
66
|
+
},
|
67
|
+
|
68
|
+
isArray: function isArray(arr) {
|
69
|
+
return Object.prototype.toString.call(arr) == "[object Array]";
|
70
|
+
},
|
71
|
+
|
72
|
+
flatten: function flatten(arr) {
|
73
|
+
var result = [], arr = arr || [];
|
74
|
+
for (var i = 0, l = arr.length; i < l; ++i) {
|
75
|
+
result = result.concat(buster.isArray(arr[i]) ? flatten(arr[i]) : arr[i]);
|
76
|
+
}
|
77
|
+
return result;
|
78
|
+
},
|
79
|
+
|
80
|
+
each: function each(arr, callback) {
|
81
|
+
for (var i = 0, l = arr.length; i < l; ++i) {
|
82
|
+
callback(arr[i]);
|
83
|
+
}
|
84
|
+
},
|
85
|
+
|
86
|
+
map: function map(arr, callback) {
|
87
|
+
var results = [];
|
88
|
+
for (var i = 0, l = arr.length; i < l; ++i) {
|
89
|
+
results.push(callback(arr[i]));
|
90
|
+
}
|
91
|
+
return results;
|
92
|
+
},
|
93
|
+
|
94
|
+
parallel: function parallel(fns, callback) {
|
95
|
+
function cb(err, res) {
|
96
|
+
if (typeof callback == "function") {
|
97
|
+
callback(err, res);
|
98
|
+
callback = null;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
if (fns.length == 0) { return cb(null, []); }
|
102
|
+
var remaining = fns.length, results = [];
|
103
|
+
function makeDone(num) {
|
104
|
+
return function done(err, result) {
|
105
|
+
if (err) { return cb(err); }
|
106
|
+
results[num] = result;
|
107
|
+
if (--remaining == 0) { cb(null, results); }
|
108
|
+
};
|
109
|
+
}
|
110
|
+
for (var i = 0, l = fns.length; i < l; ++i) {
|
111
|
+
fns[i](makeDone(i));
|
112
|
+
}
|
113
|
+
},
|
114
|
+
|
115
|
+
series: function series(fns, callback) {
|
116
|
+
function cb(err, res) {
|
117
|
+
if (typeof callback == "function") {
|
118
|
+
callback(err, res);
|
119
|
+
}
|
120
|
+
}
|
121
|
+
var remaining = fns.slice();
|
122
|
+
var results = [];
|
123
|
+
function callNext() {
|
124
|
+
if (remaining.length == 0) return cb(null, results);
|
125
|
+
var promise = remaining.shift()(next);
|
126
|
+
if (promise && typeof promise.then == "function") {
|
127
|
+
promise.then(buster.partial(next, null), next);
|
128
|
+
}
|
129
|
+
}
|
130
|
+
function next(err, result) {
|
131
|
+
if (err) return cb(err);
|
132
|
+
results.push(result);
|
133
|
+
callNext();
|
134
|
+
}
|
135
|
+
callNext();
|
136
|
+
},
|
137
|
+
|
138
|
+
countdown: function countdown(num, done) {
|
139
|
+
return function () {
|
140
|
+
if (--num == 0) done();
|
141
|
+
};
|
142
|
+
}
|
143
|
+
};
|
144
|
+
|
145
|
+
if (typeof process === "object") {
|
146
|
+
var crypto = require("crypto");
|
147
|
+
var path = require("path");
|
148
|
+
|
149
|
+
buster.tmpFile = function (fileName) {
|
150
|
+
var hashed = crypto.createHash("sha1");
|
151
|
+
hashed.update(fileName);
|
152
|
+
var tmpfileName = hashed.digest("hex");
|
153
|
+
|
154
|
+
if (process.platform == "win32") {
|
155
|
+
return path.join(process.env["TEMP"], tmpfileName);
|
156
|
+
} else {
|
157
|
+
return path.join("/tmp", tmpfileName);
|
158
|
+
}
|
159
|
+
};
|
160
|
+
}
|
161
|
+
|
162
|
+
if (Array.prototype.some) {
|
163
|
+
buster.some = function (arr, fn, thisp) {
|
164
|
+
return arr.some(fn, thisp);
|
165
|
+
};
|
166
|
+
} else {
|
167
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
|
168
|
+
buster.some = function (arr, fun, thisp) {
|
169
|
+
"use strict";
|
170
|
+
if (arr == null) { throw new TypeError(); }
|
171
|
+
arr = Object(arr);
|
172
|
+
var len = arr.length >>> 0;
|
173
|
+
if (typeof fun !== "function") { throw new TypeError(); }
|
174
|
+
|
175
|
+
for (var i = 0; i < len; i++) {
|
176
|
+
if (arr.hasOwnProperty(i) && fun.call(thisp, arr[i], i, arr)) {
|
177
|
+
return true;
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
return false;
|
182
|
+
};
|
183
|
+
}
|
184
|
+
|
185
|
+
if (Array.prototype.filter) {
|
186
|
+
buster.filter = function (arr, fn, thisp) {
|
187
|
+
return arr.filter(fn, thisp);
|
188
|
+
};
|
189
|
+
} else {
|
190
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter
|
191
|
+
buster.filter = function (fn, thisp) {
|
192
|
+
"use strict";
|
193
|
+
if (this == null) { throw new TypeError(); }
|
194
|
+
|
195
|
+
var t = Object(this);
|
196
|
+
var len = t.length >>> 0;
|
197
|
+
if (typeof fn != "function") { throw new TypeError(); }
|
198
|
+
|
199
|
+
var res = [];
|
200
|
+
for (var i = 0; i < len; i++) {
|
201
|
+
if (i in t) {
|
202
|
+
var val = t[i]; // in case fun mutates this
|
203
|
+
if (fn.call(thisp, val, i, t)) { res.push(val); }
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
207
|
+
return res;
|
208
|
+
};
|
209
|
+
}
|
210
|
+
|
211
|
+
if (isNode) {
|
212
|
+
module.exports = buster;
|
213
|
+
buster.eventEmitter = require("./buster-event-emitter");
|
214
|
+
Object.defineProperty(buster, "defineVersionGetter", {
|
215
|
+
get: function () {
|
216
|
+
return require("./define-version-getter");
|
217
|
+
}
|
218
|
+
});
|
219
|
+
}
|
220
|
+
|
221
|
+
return buster.extend(B || {}, buster);
|
222
|
+
}(setTimeout, buster));
|
@@ -0,0 +1,152 @@
|
|
1
|
+
/*jslint eqeqeq: false, onevar: false, plusplus: false*/
|
2
|
+
/*global buster, require, module*/
|
3
|
+
if (typeof require == "function" && typeof module == "object") {
|
4
|
+
var buster = require("./buster-core");
|
5
|
+
}
|
6
|
+
|
7
|
+
(function () {
|
8
|
+
function eventListeners(eventEmitter, event) {
|
9
|
+
if (!eventEmitter.listeners) {
|
10
|
+
eventEmitter.listeners = {};
|
11
|
+
}
|
12
|
+
|
13
|
+
if (!eventEmitter.listeners[event]) {
|
14
|
+
eventEmitter.listeners[event] = [];
|
15
|
+
}
|
16
|
+
|
17
|
+
return eventEmitter.listeners[event];
|
18
|
+
}
|
19
|
+
|
20
|
+
function throwLater(event, error) {
|
21
|
+
buster.nextTick(function () {
|
22
|
+
error.message = event + " listener threw error: " + error.message;
|
23
|
+
throw error;
|
24
|
+
});
|
25
|
+
}
|
26
|
+
|
27
|
+
function addSupervisor(emitter, listener, thisObject) {
|
28
|
+
if (!emitter.supervisors) { emitter.supervisors = []; }
|
29
|
+
emitter.supervisors.push({
|
30
|
+
listener: listener,
|
31
|
+
thisObject: thisObject
|
32
|
+
});
|
33
|
+
}
|
34
|
+
|
35
|
+
function notifyListener(emitter, event, listener, args) {
|
36
|
+
try {
|
37
|
+
listener.listener.apply(listener.thisObject || emitter, args);
|
38
|
+
} catch (e) {
|
39
|
+
throwLater(event, e);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
buster.eventEmitter = {
|
44
|
+
create: function () {
|
45
|
+
return buster.create(this);
|
46
|
+
},
|
47
|
+
|
48
|
+
addListener: function addListener(event, listener, thisObject) {
|
49
|
+
if (typeof event === "function") {
|
50
|
+
return addSupervisor(this, event, listener);
|
51
|
+
}
|
52
|
+
if (typeof listener != "function") {
|
53
|
+
throw new TypeError("Listener is not function");
|
54
|
+
}
|
55
|
+
eventListeners(this, event).push({
|
56
|
+
listener: listener,
|
57
|
+
thisObject: thisObject
|
58
|
+
});
|
59
|
+
},
|
60
|
+
|
61
|
+
once: function once(event, listener, thisObject) {
|
62
|
+
var self = this;
|
63
|
+
this.addListener(event, listener);
|
64
|
+
|
65
|
+
var wrapped = function () {
|
66
|
+
self.removeListener(event, listener);
|
67
|
+
self.removeListener(event, wrapped);
|
68
|
+
};
|
69
|
+
this.addListener(event, wrapped);
|
70
|
+
},
|
71
|
+
|
72
|
+
hasListener: function hasListener(event, listener, thisObject) {
|
73
|
+
var listeners = eventListeners(this, event);
|
74
|
+
|
75
|
+
for (var i = 0, l = listeners.length; i < l; i++) {
|
76
|
+
if (listeners[i].listener === listener &&
|
77
|
+
listeners[i].thisObject === thisObject) {
|
78
|
+
return true;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
return false;
|
83
|
+
},
|
84
|
+
|
85
|
+
removeListener: function (event, listener) {
|
86
|
+
var listeners = eventListeners(this, event);
|
87
|
+
|
88
|
+
for (var i = 0, l = listeners.length; i < l; ++i) {
|
89
|
+
if (listeners[i].listener == listener) {
|
90
|
+
listeners.splice(i, 1);
|
91
|
+
return;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
},
|
95
|
+
|
96
|
+
emit: function emit(event) {
|
97
|
+
var listeners = eventListeners(this, event).slice();
|
98
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
99
|
+
|
100
|
+
for (var i = 0, l = listeners.length; i < l; i++) {
|
101
|
+
notifyListener(this, event, listeners[i], args);
|
102
|
+
}
|
103
|
+
|
104
|
+
listeners = this.supervisors || [];
|
105
|
+
args = Array.prototype.slice.call(arguments);
|
106
|
+
for (i = 0, l = listeners.length; i < l; ++i) {
|
107
|
+
notifyListener(this, event, listeners[i], args);
|
108
|
+
}
|
109
|
+
},
|
110
|
+
|
111
|
+
bind: function (object, events) {
|
112
|
+
var method;
|
113
|
+
|
114
|
+
if (!events) {
|
115
|
+
for (method in object) {
|
116
|
+
if (object.hasOwnProperty(method) && typeof object[method] == "function") {
|
117
|
+
this.addListener(method, object[method], object);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
} else if (typeof events == "string" ||
|
121
|
+
Object.prototype.toString.call(events) == "[object Array]") {
|
122
|
+
events = typeof events == "string" ? [events] : events;
|
123
|
+
|
124
|
+
for (var i = 0, l = events.length; i < l; ++i) {
|
125
|
+
this.addListener(events[i], object[events[i]], object);
|
126
|
+
}
|
127
|
+
} else {
|
128
|
+
for (var prop in events) {
|
129
|
+
if (events.hasOwnProperty(prop)) {
|
130
|
+
method = events[prop];
|
131
|
+
|
132
|
+
if (typeof method == "function") {
|
133
|
+
object[buster.functionName(method) || prop] = method;
|
134
|
+
} else {
|
135
|
+
method = object[events[prop]];
|
136
|
+
}
|
137
|
+
|
138
|
+
this.addListener(prop, method, object);
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
return object;
|
144
|
+
}
|
145
|
+
};
|
146
|
+
|
147
|
+
buster.eventEmitter.on = buster.eventEmitter.addListener;
|
148
|
+
}());
|
149
|
+
|
150
|
+
if (typeof module != "undefined") {
|
151
|
+
module.exports = buster.eventEmitter;
|
152
|
+
}
|
@@ -0,0 +1,199 @@
|
|
1
|
+
if (typeof buster === "undefined") {
|
2
|
+
var buster = {};
|
3
|
+
}
|
4
|
+
|
5
|
+
if (typeof module === "object" && typeof require === "function") {
|
6
|
+
buster = require("buster-core");
|
7
|
+
}
|
8
|
+
|
9
|
+
buster.format = buster.format || {};
|
10
|
+
buster.format.excludeConstructors = ["Object", /^.$/];
|
11
|
+
buster.format.quoteStrings = true;
|
12
|
+
|
13
|
+
buster.format.ascii = (function () {
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
var hasOwn = Object.prototype.hasOwnProperty;
|
17
|
+
|
18
|
+
var specialObjects = [];
|
19
|
+
if (typeof global != "undefined") {
|
20
|
+
specialObjects.push({ obj: global, value: "[object global]" });
|
21
|
+
}
|
22
|
+
if (typeof document != "undefined") {
|
23
|
+
specialObjects.push({ obj: document, value: "[object HTMLDocument]" });
|
24
|
+
}
|
25
|
+
if (typeof window != "undefined") {
|
26
|
+
specialObjects.push({ obj: window, value: "[object Window]" });
|
27
|
+
}
|
28
|
+
|
29
|
+
function keys(object) {
|
30
|
+
var k = Object.keys && Object.keys(object) || [];
|
31
|
+
|
32
|
+
if (k.length == 0) {
|
33
|
+
for (var prop in object) {
|
34
|
+
if (hasOwn.call(object, prop)) {
|
35
|
+
k.push(prop);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
return k.sort();
|
41
|
+
}
|
42
|
+
|
43
|
+
function isCircular(object, objects) {
|
44
|
+
if (typeof object != "object") {
|
45
|
+
return false;
|
46
|
+
}
|
47
|
+
|
48
|
+
for (var i = 0, l = objects.length; i < l; ++i) {
|
49
|
+
if (objects[i] === object) {
|
50
|
+
return true;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
return false;
|
55
|
+
}
|
56
|
+
|
57
|
+
function ascii(object, processed, indent) {
|
58
|
+
if (typeof object == "string") {
|
59
|
+
var quote = typeof this.quoteStrings != "boolean" || this.quoteStrings;
|
60
|
+
return processed || quote ? '"' + object + '"' : object;
|
61
|
+
}
|
62
|
+
|
63
|
+
if (typeof object == "function" && !(object instanceof RegExp)) {
|
64
|
+
return ascii.func(object);
|
65
|
+
}
|
66
|
+
|
67
|
+
processed = processed || [];
|
68
|
+
|
69
|
+
if (isCircular(object, processed)) {
|
70
|
+
return "[Circular]";
|
71
|
+
}
|
72
|
+
|
73
|
+
if (Object.prototype.toString.call(object) == "[object Array]") {
|
74
|
+
return ascii.array.call(this, object);
|
75
|
+
}
|
76
|
+
|
77
|
+
if (!object) {
|
78
|
+
return "" + object;
|
79
|
+
}
|
80
|
+
|
81
|
+
if (buster.isElement(object)) {
|
82
|
+
return ascii.element(object);
|
83
|
+
}
|
84
|
+
|
85
|
+
if (typeof object.toString == "function" &&
|
86
|
+
object.toString !== Object.prototype.toString) {
|
87
|
+
return object.toString();
|
88
|
+
}
|
89
|
+
|
90
|
+
for (var i = 0, l = specialObjects.length; i < l; i++) {
|
91
|
+
if (object === specialObjects[i].obj) {
|
92
|
+
return specialObjects[i].value;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
return ascii.object.call(this, object, processed, indent);
|
97
|
+
}
|
98
|
+
|
99
|
+
ascii.func = function (func) {
|
100
|
+
return "function " + buster.functionName(func) + "() {}";
|
101
|
+
};
|
102
|
+
|
103
|
+
ascii.array = function (array, processed) {
|
104
|
+
processed = processed || [];
|
105
|
+
processed.push(array);
|
106
|
+
var pieces = [];
|
107
|
+
|
108
|
+
for (var i = 0, l = array.length; i < l; ++i) {
|
109
|
+
pieces.push(ascii.call(this, array[i], processed));
|
110
|
+
}
|
111
|
+
|
112
|
+
return "[" + pieces.join(", ") + "]";
|
113
|
+
};
|
114
|
+
|
115
|
+
ascii.object = function (object, processed, indent) {
|
116
|
+
processed = processed || [];
|
117
|
+
processed.push(object);
|
118
|
+
indent = indent || 0;
|
119
|
+
var pieces = [], properties = keys(object), prop, str, obj;
|
120
|
+
var is = "";
|
121
|
+
var length = 3;
|
122
|
+
|
123
|
+
for (var i = 0, l = indent; i < l; ++i) {
|
124
|
+
is += " ";
|
125
|
+
}
|
126
|
+
|
127
|
+
for (i = 0, l = properties.length; i < l; ++i) {
|
128
|
+
prop = properties[i];
|
129
|
+
obj = object[prop];
|
130
|
+
|
131
|
+
if (isCircular(obj, processed)) {
|
132
|
+
str = "[Circular]";
|
133
|
+
} else {
|
134
|
+
str = ascii.call(this, obj, processed, indent + 2);
|
135
|
+
}
|
136
|
+
|
137
|
+
str = (/\s/.test(prop) ? '"' + prop + '"' : prop) + ": " + str;
|
138
|
+
length += str.length;
|
139
|
+
pieces.push(str);
|
140
|
+
}
|
141
|
+
|
142
|
+
var cons = ascii.constructorName.call(this, object);
|
143
|
+
var prefix = cons ? "[" + cons + "] " : ""
|
144
|
+
|
145
|
+
return (length + indent) > 80 ?
|
146
|
+
prefix + "{\n " + is + pieces.join(",\n " + is) + "\n" + is + "}" :
|
147
|
+
prefix + "{ " + pieces.join(", ") + " }";
|
148
|
+
};
|
149
|
+
|
150
|
+
ascii.element = function (element) {
|
151
|
+
var tagName = element.tagName.toLowerCase();
|
152
|
+
var attrs = element.attributes, attribute, pairs = [], attrName;
|
153
|
+
|
154
|
+
for (var i = 0, l = attrs.length; i < l; ++i) {
|
155
|
+
attribute = attrs.item(i);
|
156
|
+
attrName = attribute.nodeName.toLowerCase().replace("html:", "");
|
157
|
+
|
158
|
+
if (attrName == "contenteditable" && attribute.nodeValue == "inherit") {
|
159
|
+
continue;
|
160
|
+
}
|
161
|
+
|
162
|
+
if (!!attribute.nodeValue) {
|
163
|
+
pairs.push(attrName + "=\"" + attribute.nodeValue + "\"");
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
var formatted = "<" + tagName + (pairs.length > 0 ? " " : "");
|
168
|
+
var content = element.innerHTML;
|
169
|
+
|
170
|
+
if (content.length > 20) {
|
171
|
+
content = content.substr(0, 20) + "[...]";
|
172
|
+
}
|
173
|
+
|
174
|
+
var res = formatted + pairs.join(" ") + ">" + content + "</" + tagName + ">";
|
175
|
+
|
176
|
+
return res.replace(/ contentEditable="inherit"/, "");
|
177
|
+
};
|
178
|
+
|
179
|
+
ascii.constructorName = function (object) {
|
180
|
+
var name = buster.functionName(object && object.constructor);
|
181
|
+
var excludes = this.excludeConstructors || buster.format.excludeConstructors || [];
|
182
|
+
|
183
|
+
for (var i = 0, l = excludes.length; i < l; ++i) {
|
184
|
+
if (typeof excludes[i] == "string" && excludes[i] == name) {
|
185
|
+
return "";
|
186
|
+
} else if (excludes[i].test && excludes[i].test(name)) {
|
187
|
+
return "";
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
return name;
|
192
|
+
};
|
193
|
+
|
194
|
+
return ascii;
|
195
|
+
}());
|
196
|
+
|
197
|
+
if (typeof module != "undefined") {
|
198
|
+
module.exports = buster.format;
|
199
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
if (typeof module == "object" && typeof require == "function") {
|
2
|
+
var buster = require("buster-core");
|
3
|
+
buster.assertions = require("../buster-assertions");
|
4
|
+
}
|
5
|
+
|
6
|
+
(function (ba) {
|
7
|
+
ba.expectation = {};
|
8
|
+
|
9
|
+
ba.expect = function (actual) {
|
10
|
+
var expectation = buster.extend(buster.create(ba.expectation), {
|
11
|
+
actual: actual,
|
12
|
+
assertMode: true
|
13
|
+
});
|
14
|
+
expectation.not = buster.create(expectation);
|
15
|
+
expectation.not.assertMode = false;
|
16
|
+
return expectation;
|
17
|
+
};
|
18
|
+
|
19
|
+
ba.expect.wrapAssertion = function (assertion, expectation) {
|
20
|
+
ba.expectation[expectation] = function () {
|
21
|
+
var args = [this.actual].concat(Array.prototype.slice.call(arguments));
|
22
|
+
var type = this.assertMode ? "assert" : "refute";
|
23
|
+
var callFunc;
|
24
|
+
|
25
|
+
if (assertion === "assert") {
|
26
|
+
callFunc = this.assertMode ? ba.assert : ba.refute;
|
27
|
+
} else if (assertion === "refute") {
|
28
|
+
callFunc = this.assertMode ? ba.refute : ba.assert;
|
29
|
+
} else {
|
30
|
+
callFunc = ba[type][assertion];
|
31
|
+
}
|
32
|
+
|
33
|
+
try {
|
34
|
+
return callFunc.apply(ba.expect, args);
|
35
|
+
} catch (e) {
|
36
|
+
e.message = (e.message || "").replace(
|
37
|
+
"[" + type + "." + assertion + "]",
|
38
|
+
"[expect." + (this.assertMode ? "" : "not.") + expectation + "]");
|
39
|
+
throw e;
|
40
|
+
}
|
41
|
+
};
|
42
|
+
};
|
43
|
+
|
44
|
+
var prop, expectationName;
|
45
|
+
|
46
|
+
for (prop in ba.assert) {
|
47
|
+
if (ba.assert[prop].expectationName) {
|
48
|
+
expectationName = ba.assert[prop].expectationName;
|
49
|
+
ba.expect.wrapAssertion(prop, expectationName);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
ba.expect.wrapAssertion("assert", "toBeTruthy");
|
54
|
+
ba.expect.wrapAssertion("refute", "toBeFalsy");
|
55
|
+
|
56
|
+
if (ba.expectation.toBeNear) {
|
57
|
+
ba.expectation.toBeCloseTo = ba.expectation.toBeNear;
|
58
|
+
}
|
59
|
+
|
60
|
+
if (typeof module == "object") {
|
61
|
+
module.exports = ba.expect;
|
62
|
+
}
|
63
|
+
}(buster.assertions));
|