janitor_rails 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/vendor/assets/javascripts/janitor.js +81 -67
- metadata +2 -2
@@ -54,13 +54,13 @@ window.Janitor.Stitch = {};
|
|
54
54
|
}).call(this)({"assertions": function(exports, require, module) {
|
55
55
|
module.exports = {
|
56
56
|
assertEqual: function(val1, val2) {
|
57
|
-
return this.
|
57
|
+
return this.storeAssert('equal', val1 === val2, {
|
58
58
|
val1: val1,
|
59
59
|
val2: val2
|
60
60
|
});
|
61
61
|
},
|
62
62
|
assert: function(exp) {
|
63
|
-
return this.
|
63
|
+
return this.storeAssert('true', exp, {
|
64
64
|
exp: exp
|
65
65
|
});
|
66
66
|
},
|
@@ -70,12 +70,12 @@ window.Janitor.Stitch = {};
|
|
70
70
|
error = null;
|
71
71
|
try {
|
72
72
|
callback();
|
73
|
-
} catch (
|
73
|
+
} catch (thrownError) {
|
74
74
|
caught = true;
|
75
|
-
error =
|
75
|
+
error = thrownError;
|
76
76
|
}
|
77
77
|
success = caught && (!check || check(error));
|
78
|
-
return this.
|
78
|
+
return this.storeAssert('throw', success, {
|
79
79
|
callback: callback,
|
80
80
|
error: error
|
81
81
|
});
|
@@ -86,12 +86,12 @@ window.Janitor.Stitch = {};
|
|
86
86
|
error = null;
|
87
87
|
try {
|
88
88
|
callback();
|
89
|
-
} catch (
|
89
|
+
} catch (thrownError) {
|
90
90
|
caught = true;
|
91
|
-
error =
|
91
|
+
error = thrownError;
|
92
92
|
}
|
93
93
|
success = !caught;
|
94
|
-
return this.
|
94
|
+
return this.storeAssert('refuteThrow', success, {
|
95
95
|
callback: callback,
|
96
96
|
error: error
|
97
97
|
});
|
@@ -99,10 +99,20 @@ window.Janitor.Stitch = {};
|
|
99
99
|
assertContains: function(container, value) {
|
100
100
|
var result;
|
101
101
|
result = container.indexOf(value) !== -1;
|
102
|
-
return this.
|
102
|
+
return this.storeAssert('contains', result, {
|
103
103
|
container: container,
|
104
104
|
value: value
|
105
105
|
});
|
106
|
+
},
|
107
|
+
assertAll: function(enumerable, callback) {
|
108
|
+
var success;
|
109
|
+
success = true;
|
110
|
+
enumerable.forEach(function(item) {
|
111
|
+
if (success) return success = callback(item);
|
112
|
+
});
|
113
|
+
return this.storeAssert('all', success, {
|
114
|
+
callback: callback
|
115
|
+
});
|
106
116
|
}
|
107
117
|
};
|
108
118
|
}, "browser_presenter": function(exports, require, module) {(function() {
|
@@ -119,9 +129,9 @@ window.Janitor.Stitch = {};
|
|
119
129
|
_Class.__super__.constructor.apply(this, arguments);
|
120
130
|
}
|
121
131
|
|
122
|
-
_Class.prototype.outputFailedAssert = function(
|
132
|
+
_Class.prototype.outputFailedAssert = function(failedAssert) {
|
123
133
|
var el, text;
|
124
|
-
text = this.failedAssertDescription(
|
134
|
+
text = this.failedAssertDescription(failedAssert);
|
125
135
|
el = document.createElement('div');
|
126
136
|
el.innerHTML = text;
|
127
137
|
el.style.color = 'red';
|
@@ -156,7 +166,7 @@ window.Janitor.Stitch = {};
|
|
156
166
|
_Class.__super__.constructor.apply(this, arguments);
|
157
167
|
}
|
158
168
|
|
159
|
-
_Class.prototype.
|
169
|
+
_Class.prototype.presenterClass = BrowserPresenter;
|
160
170
|
|
161
171
|
_Class.prototype.tests = function() {
|
162
172
|
var key, _i, _len, _ref, _results;
|
@@ -188,8 +198,8 @@ window.Janitor.Stitch = {};
|
|
188
198
|
_Class.__super__.constructor.apply(this, arguments);
|
189
199
|
}
|
190
200
|
|
191
|
-
_Class.prototype.outputFailedAssert = function(
|
192
|
-
return console.log(this.failedAssertDescription(
|
201
|
+
_Class.prototype.outputFailedAssert = function(failedAssert) {
|
202
|
+
return console.log(this.failedAssertDescription(failedAssert));
|
193
203
|
};
|
194
204
|
|
195
205
|
_Class.prototype.complete = function() {
|
@@ -220,15 +230,25 @@ window.Janitor.Stitch = {};
|
|
220
230
|
return _results;
|
221
231
|
}
|
222
232
|
};
|
223
|
-
}, "
|
224
|
-
|
233
|
+
}, "failed_assertion_message": function(exports, require, module) {(function() {
|
234
|
+
var FailedAssertionMessage;
|
235
|
+
|
236
|
+
module.exports = FailedAssertionMessage = (function() {
|
225
237
|
|
226
|
-
function
|
227
|
-
this.type =
|
228
|
-
this.options =
|
238
|
+
function FailedAssertionMessage(failedAssert) {
|
239
|
+
this.type = failedAssert.type;
|
240
|
+
this.options = failedAssert.options;
|
229
241
|
}
|
230
242
|
|
231
|
-
|
243
|
+
FailedAssertionMessage.prototype.equal = function() {
|
244
|
+
return "" + this.options.val1 + " does not equal " + this.options.val2;
|
245
|
+
};
|
246
|
+
|
247
|
+
FailedAssertionMessage.prototype["true"] = function() {
|
248
|
+
return "" + this.options.exp + " is not true";
|
249
|
+
};
|
250
|
+
|
251
|
+
FailedAssertionMessage.prototype.toString = function() {
|
232
252
|
if (this[this.type]) {
|
233
253
|
return this[this.type]();
|
234
254
|
} else {
|
@@ -236,17 +256,11 @@ window.Janitor.Stitch = {};
|
|
236
256
|
}
|
237
257
|
};
|
238
258
|
|
239
|
-
|
240
|
-
return "" + this.options.val1 + " does not equal " + this.options.val2;
|
241
|
-
};
|
242
|
-
|
243
|
-
_Class.prototype["true"] = function() {
|
244
|
-
return "" + this.options.exp + " is not true";
|
245
|
-
};
|
246
|
-
|
247
|
-
return _Class;
|
259
|
+
return FailedAssertionMessage;
|
248
260
|
|
249
261
|
})();
|
262
|
+
|
263
|
+
}).call(this);
|
250
264
|
}, "main": function(exports, require, module) {
|
251
265
|
module.exports = {
|
252
266
|
TestCase: require('./test_case'),
|
@@ -270,7 +284,7 @@ window.Janitor.Stitch = {};
|
|
270
284
|
_Class.__super__.constructor.apply(this, arguments);
|
271
285
|
}
|
272
286
|
|
273
|
-
_Class.prototype.
|
287
|
+
_Class.prototype.presenterClass = ConsolePresenter;
|
274
288
|
|
275
289
|
_Class.prototype.tests = function() {
|
276
290
|
var file, _i, _len, _ref, _results;
|
@@ -293,9 +307,9 @@ window.Janitor.Stitch = {};
|
|
293
307
|
|
294
308
|
}).call(this);
|
295
309
|
}, "presenter": function(exports, require, module) {(function() {
|
296
|
-
var
|
310
|
+
var FailedAssertionMessage;
|
297
311
|
|
298
|
-
|
312
|
+
FailedAssertionMessage = require('./failed_assertion_message');
|
299
313
|
|
300
314
|
module.exports = (function() {
|
301
315
|
|
@@ -306,7 +320,7 @@ window.Janitor.Stitch = {};
|
|
306
320
|
this.options = options;
|
307
321
|
this.completed = 0;
|
308
322
|
this.succeeded_asserts = 0;
|
309
|
-
this.
|
323
|
+
this.failedAsserts = 0;
|
310
324
|
this.asserts = 0;
|
311
325
|
_ref = this.tests;
|
312
326
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
@@ -321,15 +335,15 @@ window.Janitor.Stitch = {};
|
|
321
335
|
}
|
322
336
|
|
323
337
|
_Class.prototype.handleCompletedRun = function(run) {
|
324
|
-
var
|
325
|
-
this.asserts += run.
|
326
|
-
this.
|
327
|
-
this.succeeded_asserts += run.
|
328
|
-
_ref = run.
|
338
|
+
var failedAssert, _i, _len, _ref, _results;
|
339
|
+
this.asserts += run.failedAsserts.length + run.succeededAssertsCount;
|
340
|
+
this.failedAsserts += run.failedAsserts.length;
|
341
|
+
this.succeeded_asserts += run.succeededAssertsCount;
|
342
|
+
_ref = run.failedAsserts;
|
329
343
|
_results = [];
|
330
344
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
331
|
-
|
332
|
-
_results.push(this.outputFailedAssert(
|
345
|
+
failedAssert = _ref[_i];
|
346
|
+
_results.push(this.outputFailedAssert(failedAssert));
|
333
347
|
}
|
334
348
|
return _results;
|
335
349
|
};
|
@@ -339,16 +353,16 @@ window.Janitor.Stitch = {};
|
|
339
353
|
if (this.completed === this.tests.length) return this.complete();
|
340
354
|
};
|
341
355
|
|
342
|
-
_Class.prototype.failedAssertDescription = function(
|
343
|
-
return "" +
|
356
|
+
_Class.prototype.failedAssertDescription = function(failedAssert) {
|
357
|
+
return "" + failedAssert.run.constructor.name + "[" + failedAssert.run.methodName + "]: " + (this.failedAssertMessage(failedAssert));
|
344
358
|
};
|
345
359
|
|
346
|
-
_Class.prototype.failedAssertMessage = function(
|
347
|
-
return new
|
360
|
+
_Class.prototype.failedAssertMessage = function(failedAssert) {
|
361
|
+
return new FailedAssertionMessage(failedAssert).toString();
|
348
362
|
};
|
349
363
|
|
350
364
|
_Class.prototype.summaryMessage = function() {
|
351
|
-
return "COMPLETE: " + this.asserts + " asserts, " + this.
|
365
|
+
return "COMPLETE: " + this.asserts + " asserts, " + this.failedAsserts + " failed, " + this.succeeded_asserts + " succeeded";
|
352
366
|
};
|
353
367
|
|
354
368
|
return _Class;
|
@@ -365,7 +379,7 @@ window.Janitor.Stitch = {};
|
|
365
379
|
|
366
380
|
_Class.prototype.run = function() {
|
367
381
|
var Test, _i, _len, _ref, _results;
|
368
|
-
new this.
|
382
|
+
new this.presenterClass(this.tests(), this.options);
|
369
383
|
_ref = this.tests();
|
370
384
|
_results = [];
|
371
385
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
@@ -392,14 +406,14 @@ window.Janitor.Stitch = {};
|
|
392
406
|
_Class.runs = [];
|
393
407
|
|
394
408
|
_Class.runAll = function() {
|
395
|
-
var
|
409
|
+
var methodName, _i, _len, _ref, _results;
|
396
410
|
this.completed = 0;
|
397
411
|
if (this.testMethodNames().length > 0) {
|
398
412
|
_ref = this.testMethodNames();
|
399
413
|
_results = [];
|
400
414
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
401
|
-
|
402
|
-
_results.push(this.run(
|
415
|
+
methodName = _ref[_i];
|
416
|
+
_results.push(this.run(methodName));
|
403
417
|
}
|
404
418
|
return _results;
|
405
419
|
} else {
|
@@ -407,10 +421,10 @@ window.Janitor.Stitch = {};
|
|
407
421
|
}
|
408
422
|
};
|
409
423
|
|
410
|
-
_Class.run = function(
|
424
|
+
_Class.run = function(methodName) {
|
411
425
|
var run;
|
412
426
|
var _this = this;
|
413
|
-
run = new this(
|
427
|
+
run = new this(methodName);
|
414
428
|
run.bind('completed', function() {
|
415
429
|
return _this.runCompleted(run);
|
416
430
|
});
|
@@ -429,37 +443,37 @@ window.Janitor.Stitch = {};
|
|
429
443
|
};
|
430
444
|
|
431
445
|
_Class.testMethodNames = function() {
|
432
|
-
var
|
446
|
+
var methodName, _i, _len, _ref, _results;
|
433
447
|
_ref = Object.keys(this.prototype);
|
434
448
|
_results = [];
|
435
449
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
436
|
-
|
437
|
-
if (
|
438
|
-
_results.push(
|
450
|
+
methodName = _ref[_i];
|
451
|
+
if (methodName.substr(0, 5) === 'test ' || this.methodNameIsAsync(methodName)) {
|
452
|
+
_results.push(methodName);
|
439
453
|
}
|
440
454
|
}
|
441
455
|
return _results;
|
442
456
|
};
|
443
457
|
|
444
|
-
_Class.methodNameIsAsync = function(
|
445
|
-
return
|
458
|
+
_Class.methodNameIsAsync = function(methodName) {
|
459
|
+
return methodName.substr(0, 11) === 'async test ';
|
446
460
|
};
|
447
461
|
|
448
|
-
function _Class(
|
449
|
-
this.
|
450
|
-
this.
|
451
|
-
this.
|
462
|
+
function _Class(methodName) {
|
463
|
+
this.methodName = methodName;
|
464
|
+
this.succeededAssertsCount = 0;
|
465
|
+
this.failedAsserts = [];
|
452
466
|
}
|
453
467
|
|
454
468
|
_Class.prototype.run = function() {
|
455
469
|
if (this.setup) this.setup();
|
456
|
-
this[this.
|
470
|
+
this[this.methodName]();
|
457
471
|
if (this.teardown) this.teardown();
|
458
472
|
if (!this.async()) return this.complete();
|
459
473
|
};
|
460
474
|
|
461
475
|
_Class.prototype.async = function() {
|
462
|
-
return this.constructor.methodNameIsAsync(this.
|
476
|
+
return this.constructor.methodNameIsAsync(this.methodName);
|
463
477
|
};
|
464
478
|
|
465
479
|
_Class.prototype.complete = function() {
|
@@ -467,12 +481,12 @@ window.Janitor.Stitch = {};
|
|
467
481
|
return this.trigger('completed');
|
468
482
|
};
|
469
483
|
|
470
|
-
_Class.prototype.
|
484
|
+
_Class.prototype.storeAssert = function(type, succeeded, options) {
|
471
485
|
if (options == null) options = {};
|
472
486
|
if (succeeded) {
|
473
|
-
return this.
|
487
|
+
return this.succeededAssertsCount += 1;
|
474
488
|
} else {
|
475
|
-
return this.
|
489
|
+
return this.failedAsserts.push({
|
476
490
|
type: type,
|
477
491
|
succeeded: succeeded,
|
478
492
|
options: options,
|
@@ -482,7 +496,7 @@ window.Janitor.Stitch = {};
|
|
482
496
|
};
|
483
497
|
|
484
498
|
_Class.prototype.succeeded = function() {
|
485
|
-
return this.completed && this.
|
499
|
+
return this.completed && this.failedAsserts === 0;
|
486
500
|
};
|
487
501
|
|
488
502
|
return _Class;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: janitor_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: janitor_rails lets you easily test Javascript code with Janitor.
|
15
15
|
email: rasmusrnielsen@gmail.com
|