smparkes-jazrb 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +41 -0
- data/bin/autojaz +4 -0
- data/bin/jazrb +11 -0
- data/doc/jasmine/files.html +292 -0
- data/doc/jasmine/index.html +322 -0
- data/doc/jasmine/symbols/_global_.html +918 -0
- data/doc/jasmine/symbols/jasmine.Block.html +349 -0
- data/doc/jasmine/symbols/jasmine.Env.html +517 -0
- data/doc/jasmine/symbols/jasmine.EnvjsReporter.html +326 -0
- data/doc/jasmine/symbols/jasmine.JsApiReporter.html +326 -0
- data/doc/jasmine/symbols/jasmine.Matchers.html +885 -0
- data/doc/jasmine/symbols/jasmine.MultiReporter.html +326 -0
- data/doc/jasmine/symbols/jasmine.NestedResults.html +710 -0
- data/doc/jasmine/symbols/jasmine.Reporter.html +326 -0
- data/doc/jasmine/symbols/jasmine.Runner.html +337 -0
- data/doc/jasmine/symbols/jasmine.Spec.html +406 -0
- data/doc/jasmine/symbols/jasmine.Spy.html +855 -0
- data/doc/jasmine/symbols/jasmine.Suite.html +355 -0
- data/doc/jasmine/symbols/jasmine.html +770 -0
- data/doc/jasmine/symbols/jasmine.util.html +326 -0
- data/doc/jasmine/symbols/src/lib_EnvjsReporter.js.html +149 -0
- data/doc/jasmine/symbols/src/lib_TrivialReporter.js.html +127 -0
- data/doc/jasmine/symbols/src/lib_consolex.js.html +35 -0
- data/doc/jasmine/symbols/src/lib_jasmine-0.10.0.js.html +2302 -0
- data/doc/jasmine/symbols/src/lib_jasmine-0.9.0.js.html +2212 -0
- data/doc/jasmine/symbols/src/lib_json2.js.html +486 -0
- data/lib/autotest/discover.rb +3 -0
- data/lib/autotest/jazrb.rb +55 -0
- data/lib/jazrb/intro.js +18 -0
- data/lib/jazrb/jasmine/EnvjsReporter.js +141 -0
- data/lib/jazrb/jasmine/TrivialReporter.js +119 -0
- data/lib/jazrb/jasmine/consolex.js +28 -0
- data/lib/jazrb/jasmine/jasmine-0.10.0.js +2294 -0
- data/lib/jazrb/jasmine/jasmine.js +2294 -0
- data/lib/jazrb/jasmine/json2.js +478 -0
- data/lib/jazrb/outro.js +3 -0
- data/lib/jazrb.rb +0 -0
- data/test/jazrb_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +116 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'autotest'
|
2
|
+
|
3
|
+
Autotest.add_hook :initialize do |at|
|
4
|
+
# at.clear_mappings
|
5
|
+
at.add_mapping(%r%^spec/(suites/)?.*Spec.js$%) { |filename, _|
|
6
|
+
filename
|
7
|
+
}
|
8
|
+
at.add_mapping(%r%^spec/(suites/)?.*_spec.js$%) { |filename, _|
|
9
|
+
filename
|
10
|
+
}
|
11
|
+
at.add_mapping(%r%^lib/(.*)\.js$%) { |_, m|
|
12
|
+
["spec/#{m[1]}Spec.js", "spec/suites/#{m[1]}Spec.js"]
|
13
|
+
}
|
14
|
+
at.add_mapping(%r%^src/(.*)\.js$%) { |_, m|
|
15
|
+
["spec/#{m[1]}Spec.js", "spec/suites/#{m[1]}Spec.js"]
|
16
|
+
}
|
17
|
+
at.add_mapping(%r%^lib/(.*)\.js$%) { |_, m|
|
18
|
+
["spec/#{m[1]}_spec.js", "spec/suites/#{m[1]}_spec.js"]
|
19
|
+
}
|
20
|
+
at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.js$%) {
|
21
|
+
at.files_matching %r%^spec/.*Spec\.js$%
|
22
|
+
}
|
23
|
+
at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.js$%) {
|
24
|
+
at.files_matching %r%^spec/.*_spec\.js$%
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
class Autotest::Jazrb < Autotest
|
29
|
+
|
30
|
+
def initialize
|
31
|
+
super
|
32
|
+
self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n\n?(.*?(\n\n\(.*?)?)\n\n/m
|
33
|
+
self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
|
34
|
+
end
|
35
|
+
|
36
|
+
def consolidate_failures(failed)
|
37
|
+
filters = new_hash_of_arrays
|
38
|
+
failed.each do |spec, trace|
|
39
|
+
if trace =~ /\n(\.\/)?(.*_spec\.js):[\d]+:/
|
40
|
+
filters[$2] << spec
|
41
|
+
end
|
42
|
+
if trace =~ /\n(\.\/)?(.*Spec\.js):[\d]+:/
|
43
|
+
filters[$2] << spec
|
44
|
+
end
|
45
|
+
end
|
46
|
+
return filters
|
47
|
+
end
|
48
|
+
|
49
|
+
def make_test_cmd(files_to_test)
|
50
|
+
return '' if files_to_test.empty?
|
51
|
+
spec_program = "jazrb"
|
52
|
+
return "#{spec_program} #{files_to_test.keys.flatten.join(' ')}"
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
data/lib/jazrb/intro.js
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
(function(){
|
2
|
+
var prefix = Ruby.ENV["JAZRB_JS_PATH"];
|
3
|
+
load(prefix + "/jasmine/jasmine.js");
|
4
|
+
load(prefix + "/jasmine/TrivialReporter.js");
|
5
|
+
load(prefix + "/jasmine/EnvjsReporter.js");
|
6
|
+
})();
|
7
|
+
|
8
|
+
(function () {
|
9
|
+
var jasmineEnv = jasmine.getEnv();
|
10
|
+
jasmineEnv.updateInterval = 1000;
|
11
|
+
|
12
|
+
var _EnvjsReporter = new jasmine.EnvjsReporter();
|
13
|
+
jasmineEnv.addReporter(_EnvjsReporter);
|
14
|
+
|
15
|
+
window.onload = function() {
|
16
|
+
jasmineEnv.execute();
|
17
|
+
};
|
18
|
+
})();
|
@@ -0,0 +1,141 @@
|
|
1
|
+
/** JavaScript API reporter.
|
2
|
+
*
|
3
|
+
* @constructor
|
4
|
+
*/
|
5
|
+
jasmine.EnvjsReporter = function() {
|
6
|
+
this.started = false;
|
7
|
+
this.finished = false;
|
8
|
+
this.suites_ = [];
|
9
|
+
this.results_ = {};
|
10
|
+
};
|
11
|
+
|
12
|
+
jasmine.EnvjsReporter.prototype.reportRunnerStarting = function(runner) {
|
13
|
+
this.started = true;
|
14
|
+
var suites = runner.suites();
|
15
|
+
for (var i = 0; i < suites.length; i++) {
|
16
|
+
var suite = suites[i];
|
17
|
+
this.suites_.push(this.summarize_(suite));
|
18
|
+
}
|
19
|
+
this.startedAt = new Date();
|
20
|
+
};
|
21
|
+
|
22
|
+
jasmine.EnvjsReporter.prototype.suites = function() {
|
23
|
+
return this.suites_;
|
24
|
+
};
|
25
|
+
|
26
|
+
jasmine.EnvjsReporter.prototype.summarize_ = function(suiteOrSpec) {
|
27
|
+
var isSuite = suiteOrSpec instanceof jasmine.Suite
|
28
|
+
var summary = {
|
29
|
+
id: suiteOrSpec.id,
|
30
|
+
name: suiteOrSpec.description,
|
31
|
+
type: isSuite ? 'suite' : 'spec',
|
32
|
+
children: []
|
33
|
+
};
|
34
|
+
if (isSuite) {
|
35
|
+
var specs = suiteOrSpec.specs();
|
36
|
+
for (var i = 0; i < specs.length; i++) {
|
37
|
+
summary.children.push(this.summarize_(specs[i]));
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return summary;
|
41
|
+
};
|
42
|
+
|
43
|
+
jasmine.EnvjsReporter.prototype.results = function() {
|
44
|
+
return this.results_;
|
45
|
+
};
|
46
|
+
|
47
|
+
jasmine.EnvjsReporter.prototype.resultsForSpec = function(specId) {
|
48
|
+
return this.results_[specId];
|
49
|
+
};
|
50
|
+
|
51
|
+
//noinspection JSUnusedLocalSymbols
|
52
|
+
jasmine.EnvjsReporter.prototype.reportRunnerResults = function(runner) {
|
53
|
+
this.finished = true;
|
54
|
+
var results = runner.results();
|
55
|
+
var specs = runner.specs();
|
56
|
+
var specCount = specs.length;
|
57
|
+
print();
|
58
|
+
var count = 1;
|
59
|
+
var red = "\x1b[31m";
|
60
|
+
var normal = "\x1b[0m";
|
61
|
+
var green = "\x1b[32m";
|
62
|
+
for(var i in this.results_) {
|
63
|
+
var result = this.results_[i];
|
64
|
+
if( result.result == "failed" ) {
|
65
|
+
var messages = result.messages;
|
66
|
+
for(var j in messages) {
|
67
|
+
var expectation = messages[j];
|
68
|
+
if( !expectation.passed() ) {
|
69
|
+
print();
|
70
|
+
print(count++ + ")");
|
71
|
+
print(red+result.spec.description+normal);
|
72
|
+
var message;
|
73
|
+
message = expectation.message.replace(/(<br \/>)+/g, " ");
|
74
|
+
print(red+message+normal);
|
75
|
+
print_exception(expectation.trace);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
var message = "\nFinished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
81
|
+
print(message);
|
82
|
+
message = "\n" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
83
|
+
if(results.failedCount > 0){
|
84
|
+
message = red + message;
|
85
|
+
} else {
|
86
|
+
message = green + message;
|
87
|
+
}
|
88
|
+
print(message+normal);
|
89
|
+
};
|
90
|
+
|
91
|
+
//noinspection JSUnusedLocalSymbols
|
92
|
+
jasmine.EnvjsReporter.prototype.reportSuiteResults = function(suite) {
|
93
|
+
};
|
94
|
+
|
95
|
+
//noinspection JSUnusedLocalSymbols
|
96
|
+
jasmine.EnvjsReporter.prototype.reportSpecResults = function(spec) {
|
97
|
+
puts(spec.results().failedCount > 0 ? "\x1b[31mF\x1b[0m" : "\x1b[32m.\x1b[0m");
|
98
|
+
this.results_[spec.id] = {
|
99
|
+
spec: spec,
|
100
|
+
messages: spec.results().getItems(),
|
101
|
+
result: spec.results().failedCount > 0 ? "failed" : "passed"
|
102
|
+
};
|
103
|
+
};
|
104
|
+
|
105
|
+
//noinspection JSUnusedLocalSymbols
|
106
|
+
jasmine.EnvjsReporter.prototype.log = function(str) {
|
107
|
+
// print(str);
|
108
|
+
};
|
109
|
+
|
110
|
+
jasmine.EnvjsReporter.prototype.resultsForSpecs = function(specIds){
|
111
|
+
var results = {};
|
112
|
+
for (var i = 0; i < specIds.length; i++) {
|
113
|
+
var specId = specIds[i];
|
114
|
+
results[specId] = this.summarizeResult_(this.results_[specId]);
|
115
|
+
}
|
116
|
+
return results;
|
117
|
+
};
|
118
|
+
|
119
|
+
jasmine.EnvjsReporter.prototype.summarizeResult_ = function(result){
|
120
|
+
var summaryMessages = [];
|
121
|
+
for (var messageIndex in result.messages) {
|
122
|
+
var resultMessage = result.messages[messageIndex];
|
123
|
+
summaryMessages.push({
|
124
|
+
text: resultMessage.text,
|
125
|
+
passed: resultMessage.passed ? resultMessage.passed() : true,
|
126
|
+
type: resultMessage.type,
|
127
|
+
message: resultMessage.message,
|
128
|
+
trace: {
|
129
|
+
stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : undefined
|
130
|
+
}
|
131
|
+
});
|
132
|
+
};
|
133
|
+
|
134
|
+
var summaryResult = {
|
135
|
+
result : result.result,
|
136
|
+
messages : summaryMessages
|
137
|
+
};
|
138
|
+
|
139
|
+
return summaryResult;
|
140
|
+
};
|
141
|
+
|
@@ -0,0 +1,119 @@
|
|
1
|
+
jasmine.TrivialReporter = function(doc) {
|
2
|
+
this.document = doc || document;
|
3
|
+
this.suiteDivs = {};
|
4
|
+
};
|
5
|
+
|
6
|
+
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
7
|
+
var el = document.createElement(type);
|
8
|
+
|
9
|
+
for (var i = 2; i < arguments.length; i++) {
|
10
|
+
var child = arguments[i];
|
11
|
+
|
12
|
+
if (typeof child === 'string') {
|
13
|
+
el.appendChild(document.createTextNode(child));
|
14
|
+
} else {
|
15
|
+
if (child) { el.appendChild(child); }
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
for (var attr in attrs) {
|
20
|
+
el[attr] = attrs[attr];
|
21
|
+
}
|
22
|
+
|
23
|
+
return el;
|
24
|
+
};
|
25
|
+
|
26
|
+
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
27
|
+
var suites = runner.suites();
|
28
|
+
|
29
|
+
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
30
|
+
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
31
|
+
this.runnerMessageSpan = this.createDom('span', {}, "Running..."));
|
32
|
+
this.document.body.appendChild(this.runnerDiv);
|
33
|
+
|
34
|
+
for (var i = 0; i < suites.length; i++) {
|
35
|
+
var suite = suites[i];
|
36
|
+
var suiteDiv = this.createDom('div', { className: 'suite' },
|
37
|
+
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
38
|
+
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
39
|
+
this.suiteDivs[suite.getFullName()] = suiteDiv;
|
40
|
+
var parentDiv = this.document.body;
|
41
|
+
if (suite.parentSuite) {
|
42
|
+
parentDiv = this.suiteDivs[suite.parentSuite.getFullName()];
|
43
|
+
}
|
44
|
+
parentDiv.appendChild(suiteDiv);
|
45
|
+
}
|
46
|
+
|
47
|
+
this.startedAt = new Date();
|
48
|
+
};
|
49
|
+
|
50
|
+
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
51
|
+
var results = runner.results();
|
52
|
+
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
53
|
+
this.runnerDiv.setAttribute("class", className);
|
54
|
+
//do it twice for IE
|
55
|
+
this.runnerDiv.setAttribute("className", className);
|
56
|
+
var specs = runner.specs();
|
57
|
+
var specCount = 0;
|
58
|
+
for (var i = 0; i < specs.length; i++) {
|
59
|
+
if (this.specFilter(specs[i])) {
|
60
|
+
specCount++;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
64
|
+
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
65
|
+
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
66
|
+
};
|
67
|
+
|
68
|
+
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
69
|
+
var results = suite.results();
|
70
|
+
var status = results.passed() ? 'passed' : 'failed';
|
71
|
+
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
72
|
+
status = 'skipped';
|
73
|
+
}
|
74
|
+
this.suiteDivs[suite.getFullName()].className += " " + status;
|
75
|
+
};
|
76
|
+
|
77
|
+
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
78
|
+
var results = spec.results();
|
79
|
+
var status = results.passed() ? 'passed' : 'failed';
|
80
|
+
if (results.skipped) {
|
81
|
+
status = 'skipped';
|
82
|
+
}
|
83
|
+
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
84
|
+
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
85
|
+
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, spec.getFullName()));
|
86
|
+
|
87
|
+
|
88
|
+
var resultItems = results.getItems();
|
89
|
+
for (var i = 0; i < resultItems.length; i++) {
|
90
|
+
var result = resultItems[i];
|
91
|
+
if (result.passed && !result.passed()) {
|
92
|
+
var resultMessageDiv = this.createDom('div', {className: 'resultMessage fail'});
|
93
|
+
resultMessageDiv.innerHTML = result.message; // todo: lame; mend
|
94
|
+
specDiv.appendChild(resultMessageDiv);
|
95
|
+
specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
96
|
+
}
|
97
|
+
}
|
98
|
+
this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv);
|
99
|
+
};
|
100
|
+
|
101
|
+
jasmine.TrivialReporter.prototype.log = function() {
|
102
|
+
this.console && console.log.apply(console, arguments);
|
103
|
+
};
|
104
|
+
|
105
|
+
jasmine.TrivialReporter.prototype.getLocation = function() {
|
106
|
+
return this.document.location;
|
107
|
+
};
|
108
|
+
|
109
|
+
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
110
|
+
var paramMap = {};
|
111
|
+
var params = this.getLocation().search.substring(1).split('&');
|
112
|
+
for (var i = 0; i < params.length; i++) {
|
113
|
+
var p = params[i].split('=');
|
114
|
+
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
115
|
+
}
|
116
|
+
|
117
|
+
if (!paramMap["spec"]) return true;
|
118
|
+
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
119
|
+
};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/** Console X
|
2
|
+
* http://github.com/deadlyicon/consolex.js
|
3
|
+
*
|
4
|
+
* By Jared Grippe <jared@jaredgrippe.com>
|
5
|
+
*
|
6
|
+
* Copyright (c) 2009 Jared Grippe
|
7
|
+
* Licensed under the MIT license.
|
8
|
+
*
|
9
|
+
* consolex avoids ever having to see javascript bugs in browsers that do not implement the entire
|
10
|
+
* firebug console suit
|
11
|
+
*
|
12
|
+
*/
|
13
|
+
(function(window) {
|
14
|
+
window.console || (window.console = {});
|
15
|
+
|
16
|
+
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
|
17
|
+
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
18
|
+
|
19
|
+
function emptyFunction(){}
|
20
|
+
|
21
|
+
for (var i = 0; i < names.length; ++i){
|
22
|
+
window.console[names[i]] || (window.console[names[i]] = emptyFunction);
|
23
|
+
if (typeof window.console[names[i]] !== 'function')
|
24
|
+
window.console[names[i]] = (function(method) {
|
25
|
+
return function(){ return Function.prototype.apply.apply(method, [console,arguments]); };
|
26
|
+
})(window.console[names[i]]);
|
27
|
+
}
|
28
|
+
})(this);
|