jasmine-rails 0.5.6 → 0.6.0
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/app/helpers/jasmine_rails/spec_runner_helper.rb +13 -1
- data/lib/assets/javascripts/jasmine-boot.js +0 -5
- data/lib/assets/javascripts/jasmine-console-reporter.js +50 -36
- data/lib/assets/javascripts/jasmine-runner.js +21 -4
- data/lib/jasmine_rails/runner.rb +4 -1
- data/lib/jasmine_rails/version.rb +1 -1
- metadata +12 -6
@@ -19,13 +19,25 @@ module JasmineRails
|
|
19
19
|
# * jasmine-specs.js built by asset pipeline which merges application specific libraries and specs
|
20
20
|
def jasmine_js_files
|
21
21
|
files = Jasmine::Core.js_files
|
22
|
+
files << jasmine_boot_file
|
22
23
|
if params[:console]
|
23
24
|
files << 'jasmine-console-shims.js'
|
24
25
|
files << 'jasmine-console-reporter.js'
|
25
26
|
end
|
26
|
-
files << 'jasmine-boot.js'
|
27
27
|
files << 'jasmine-specs.js'
|
28
28
|
files
|
29
29
|
end
|
30
|
+
|
31
|
+
def jasmine_boot_file
|
32
|
+
if jasmine2?
|
33
|
+
Jasmine::Core.boot_files.first
|
34
|
+
else
|
35
|
+
'jasmine-boot.js'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def jasmine2?
|
40
|
+
Jasmine::Core.respond_to?(:boot_files)
|
41
|
+
end
|
30
42
|
end
|
31
43
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
var jsApiReporter;
|
2
2
|
(function() {
|
3
3
|
var jasmineEnv = jasmine.getEnv();
|
4
|
-
|
5
4
|
jsApiReporter = new jasmine.JsApiReporter();
|
6
5
|
jasmineEnv.addReporter(jsApiReporter);
|
7
6
|
|
@@ -11,10 +10,6 @@ var jsApiReporter;
|
|
11
10
|
return htmlReporter.specFilter(spec);
|
12
11
|
};
|
13
12
|
|
14
|
-
if (jasmine.ConsoleReporter) {
|
15
|
-
jasmineEnv.addReporter(new jasmine.ConsoleReporter());
|
16
|
-
}
|
17
|
-
|
18
13
|
function execJasmine() {
|
19
14
|
jasmineEnv.execute();
|
20
15
|
}
|
@@ -4,27 +4,29 @@
|
|
4
4
|
|
5
5
|
Usage:
|
6
6
|
// From your html file that loads jasmine:
|
7
|
-
jasmine.getEnv().addReporter(new jasmine.ConsoleReporter());
|
8
7
|
jasmine.getEnv().execute();
|
9
8
|
*/
|
10
9
|
|
11
|
-
(function(
|
10
|
+
(function() {
|
11
|
+
var ConsoleReporter,
|
12
|
+
root = this;
|
13
|
+
|
12
14
|
if (!jasmine) {
|
13
15
|
throw "jasmine library isn't loaded!";
|
14
16
|
}
|
15
17
|
|
16
|
-
var ANSI = {}
|
18
|
+
var ANSI = {};
|
17
19
|
ANSI.color_map = {
|
18
20
|
"green" : 32,
|
19
21
|
"red" : 31
|
20
|
-
}
|
22
|
+
};
|
21
23
|
|
22
24
|
ANSI.colorize_text = function(text, color) {
|
23
25
|
var color_code = this.color_map[color];
|
24
26
|
return "\033[" + color_code + "m" + text + "\033[0m";
|
25
|
-
}
|
27
|
+
};
|
26
28
|
|
27
|
-
|
29
|
+
ConsoleReporter = function() {
|
28
30
|
if (!console || !console.log) { throw "console isn't present!"; }
|
29
31
|
this.status = this.statuses.stopped;
|
30
32
|
};
|
@@ -37,7 +39,7 @@
|
|
37
39
|
success : "success"
|
38
40
|
};
|
39
41
|
|
40
|
-
proto.reportRunnerStarting = function(runner) {
|
42
|
+
proto.reportRunnerStarting = proto.jasmineStarted = function(runner) {
|
41
43
|
this.status = this.statuses.running;
|
42
44
|
this.start_time = (new Date()).getTime();
|
43
45
|
this.executed_specs = 0;
|
@@ -45,7 +47,7 @@
|
|
45
47
|
this.log("Starting...");
|
46
48
|
};
|
47
49
|
|
48
|
-
proto.reportRunnerResults = function(runner) {
|
50
|
+
proto.reportRunnerResults = proto.jasmineDone = function(runner) {
|
49
51
|
var failed = this.executed_specs - this.passed_specs;
|
50
52
|
var spec_str = this.executed_specs + (this.executed_specs === 1 ? " spec, " : " specs, ");
|
51
53
|
var fail_str = failed + (failed === 1 ? " failure in " : " failures in ");
|
@@ -65,40 +67,51 @@
|
|
65
67
|
this.log("ConsoleReporter finished");
|
66
68
|
};
|
67
69
|
|
68
|
-
|
69
|
-
proto.reportSpecStarting = function(spec) {
|
70
|
+
proto.reportSpecStarting = proto.specStarted = function(spec) {
|
70
71
|
this.executed_specs++;
|
71
72
|
};
|
72
73
|
|
73
|
-
proto.reportSpecResults = function(spec) {
|
74
|
-
if
|
75
|
-
|
74
|
+
proto.reportSpecResults = proto.specDone = function(spec) {
|
75
|
+
if(spec.results) { //jasmine 1.x
|
76
|
+
var specResult = spec.results()
|
77
|
+
if(specResult.skipped) {
|
78
|
+
return;
|
79
|
+
} else if(specResult.passed()) {
|
80
|
+
this.passed_specs++;
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
} else { //jasmine 2.x
|
84
|
+
if(spec.status === "passed") {
|
85
|
+
this.passed_specs++;
|
86
|
+
return;
|
87
|
+
} else if(spec.status !== "failed") {
|
88
|
+
//Skipped or Pending
|
89
|
+
return;
|
90
|
+
}
|
76
91
|
}
|
77
|
-
if (spec.results().passed()) {
|
78
|
-
this.passed_specs++;
|
79
|
-
return;
|
80
|
-
}
|
81
|
-
|
82
|
-
var resultText = spec.suite.description + " : " + spec.description;
|
83
|
-
this.log(resultText, "red");
|
84
92
|
|
85
|
-
var
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
93
|
+
var fullName, failedExpectations;
|
94
|
+
if(spec.suite) { //jasmine 1.x
|
95
|
+
fullName = spec.suite.description + " " + spec.description;
|
96
|
+
failedExpectations = spec.results().getItems().map(function(expectation){
|
97
|
+
console.log(JSON.stringify(expectation))
|
98
|
+
return " " + expectation.message +
|
99
|
+
(expectation.trace && expectation.trace.stack ? "\n " + expectation.trace.stack : "" );
|
100
|
+
});
|
101
|
+
} else { //jasmine 2.x
|
102
|
+
fullName = spec.fullName;
|
103
|
+
failedExpectations = spec.failedExpectations.map(function(expectation){
|
104
|
+
if(expectation.message === "undefined: undefined") {
|
105
|
+
return " An unstructured exception was thrown (use `new Error(message)` for better output).";
|
106
|
+
} else {
|
107
|
+
return " " + expectation.message + "\n" +
|
108
|
+
" " + expectation.stack;
|
109
|
+
}
|
110
|
+
});
|
90
111
|
}
|
91
|
-
};
|
92
112
|
|
93
|
-
|
94
|
-
|
95
|
-
var results = suite.results();
|
96
|
-
if (results.totalCount === 0) {
|
97
|
-
return;
|
98
|
-
}
|
99
|
-
var failed = results.totalCount - results.passedCount;
|
100
|
-
var color = (failed > 0)? "red" : "green";
|
101
|
-
this.log(suite.description + ": " + results.passedCount + " of " + results.totalCount + " passed.", color);
|
113
|
+
this.log(fullName, "red");
|
114
|
+
this.log(failedExpectations.join("\n\n"), "red");
|
102
115
|
};
|
103
116
|
|
104
117
|
proto.log = function(str, color) {
|
@@ -107,4 +120,5 @@
|
|
107
120
|
};
|
108
121
|
|
109
122
|
jasmine.ConsoleReporter = ConsoleReporter;
|
110
|
-
|
123
|
+
jasmine.getEnv().addReporter(new jasmine.ConsoleReporter());
|
124
|
+
})();
|
@@ -47,17 +47,34 @@
|
|
47
47
|
page.onInitialized = function() {
|
48
48
|
return page.evaluate(function() {
|
49
49
|
return window.onload = function() {
|
50
|
-
|
50
|
+
var exitCode = 0,
|
51
|
+
originalReportSpecResults = jsApiReporter.reportSpecResults,
|
52
|
+
originalJasmineDone = jsApiReporter.reportRunnerResults || jsApiReporter.jasmineDone;
|
53
|
+
|
54
|
+
//jasmine 1.x - determine failure by overwriting #reportSpecResults
|
51
55
|
jsApiReporter.reportSpecResults = function(spec) {
|
56
|
+
originalReportSpecResults.call(jsApiReporter, spec);
|
52
57
|
if (spec.results().failedCount > 0) {
|
53
|
-
|
58
|
+
exitCode = 1;
|
54
59
|
}
|
55
60
|
};
|
56
|
-
|
61
|
+
|
62
|
+
jsApiReporter.reportRunnerResults = jsApiReporter.jasmineDone = function(runner) {
|
63
|
+
originalJasmineDone.call(jsApiReporter, runner);
|
64
|
+
|
65
|
+
//jasmine 2.x - loop over the specs stored on the reporter to find failures
|
66
|
+
if(jsApiReporter.specs) {
|
67
|
+
jsApiReporter.specs().forEach(function(spec) {
|
68
|
+
if(spec.status === "failed") {
|
69
|
+
exitCode = 1;
|
70
|
+
}
|
71
|
+
})
|
72
|
+
}
|
73
|
+
|
57
74
|
setTimeout(function() {
|
58
75
|
window.callPhantom({
|
59
76
|
event: 'exit',
|
60
|
-
exitCode:
|
77
|
+
exitCode: exitCode
|
61
78
|
});
|
62
79
|
}, 1);
|
63
80
|
};
|
data/lib/jasmine_rails/runner.rb
CHANGED
@@ -57,7 +57,10 @@ module JasmineRails
|
|
57
57
|
JasmineRails::OfflineAssetPaths.disabled = false
|
58
58
|
app.get path, :console => 'true', :spec => spec_filter
|
59
59
|
JasmineRails::OfflineAssetPaths.disabled = true
|
60
|
-
|
60
|
+
unless app.response.success?
|
61
|
+
raise "Jasmine runner at '#{path}' returned a #{app.response.status} error: #{app.response.message} \n\n" +
|
62
|
+
"The most common cause is an asset compilation failure. Full HTML response: \n\n #{app.response.body}"
|
63
|
+
end
|
61
64
|
app.response.body
|
62
65
|
end
|
63
66
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jasmine-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-02-
|
14
|
+
date: 2014-02-20 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -50,17 +50,23 @@ dependencies:
|
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ! '>='
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '1.3'
|
56
|
+
- - <
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '3.0'
|
56
59
|
type: :runtime
|
57
60
|
prerelease: false
|
58
61
|
version_requirements: !ruby/object:Gem::Requirement
|
59
62
|
none: false
|
60
63
|
requirements:
|
61
|
-
- -
|
64
|
+
- - ! '>='
|
62
65
|
- !ruby/object:Gem::Version
|
63
66
|
version: '1.3'
|
67
|
+
- - <
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.0'
|
64
70
|
- !ruby/object:Gem::Dependency
|
65
71
|
name: phantomjs
|
66
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
148
|
version: '0'
|
143
149
|
segments:
|
144
150
|
- 0
|
145
|
-
hash:
|
151
|
+
hash: -2098666322319327429
|
146
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
153
|
none: false
|
148
154
|
requirements:
|
@@ -151,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
157
|
version: '0'
|
152
158
|
segments:
|
153
159
|
- 0
|
154
|
-
hash:
|
160
|
+
hash: -2098666322319327429
|
155
161
|
requirements: []
|
156
162
|
rubyforge_project:
|
157
163
|
rubygems_version: 1.8.23
|