learn-test 1.2.25 → 1.2.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/learn-test.gemspec +1 -1
- data/lib/learn_test/jasmine/runners/run-jasmine.js +48 -47
- data/lib/learn_test/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34bfbc3b76dddc66031d2b5cd1219a412f490354
|
4
|
+
data.tar.gz: d5a26157552218763f27cdee4d12dac7e38e7dd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab0ce891184c8c0e20f3ab3b35fce1feda5cb57d11e62ac6e4351e3ddfc0e949e5a565177d7b6f2d89d495c632fb14d0ff58bb1cee86695062f912df7a93a767
|
7
|
+
data.tar.gz: 9bf5c0067ad6eeae26f94cc13dee01e22872c78fdd852ae53bebb5d9c71ae74c2ab9505e23952a4ce6e72699f8ca3e8da3faad73bac3d9b8c162ca3223a57373
|
data/learn-test.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Flatiron School"]
|
10
10
|
spec.email = ["learn@flatironschool.com"]
|
11
11
|
spec.summary = %q{Runs RSpec, Jasmine, and Python Unit Test builds and pushes JSON output to Learn.}
|
12
|
-
spec.homepage = "https://learn
|
12
|
+
spec.homepage = "https://github.com/learn-co/learn-test"
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -1,23 +1,20 @@
|
|
1
|
-
/* globals
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
var args = system.args;
|
1
|
+
/* globals jasmineRequire, phantom */
|
2
|
+
// Verify arguments
|
3
|
+
var system = require('system');
|
4
|
+
var args;
|
5
|
+
|
6
|
+
if(phantom.args) {
|
7
|
+
args = phantom.args;
|
9
8
|
} else {
|
10
|
-
|
11
|
-
var args = phantom.args;
|
9
|
+
args = system.args.slice(1);//use system args for phantom 2.0+
|
12
10
|
}
|
13
11
|
|
14
|
-
|
15
|
-
if ( (phantom.version.major === 1 && !args.length ) || ( !args.length ) ) {
|
12
|
+
if (args.length === 0) {
|
16
13
|
console.log("Simple JasmineBDD test runner for phantom.js");
|
17
14
|
console.log("Usage: phantomjs-testrunner.js url_to_runner.html");
|
18
15
|
console.log("Accepts http:// and file:// urls");
|
19
16
|
console.log("");
|
20
|
-
console.log("NOTE: This script depends on jasmine.
|
17
|
+
console.log("NOTE: This script depends on jasmine.HtmlReporter being used\non the page, for the DOM elements it creates.\n");
|
21
18
|
phantom.exit(2);
|
22
19
|
}
|
23
20
|
else {
|
@@ -28,7 +25,6 @@ else {
|
|
28
25
|
|
29
26
|
var setupPageFn = function(p, k) {
|
30
27
|
return function() {
|
31
|
-
overloadPageEvaluate(p);
|
32
28
|
setupWriteFileFunction(p, k, fs.separator);
|
33
29
|
};
|
34
30
|
};
|
@@ -37,6 +33,9 @@ else {
|
|
37
33
|
address = args[i];
|
38
34
|
console.log("Loading " + address);
|
39
35
|
|
36
|
+
// if provided a url without a protocol, try to use file://
|
37
|
+
address = address.indexOf("://") === -1 ? "file://" + address : address;
|
38
|
+
|
40
39
|
// create a WebPage object to work with
|
41
40
|
page = require("webpage").create();
|
42
41
|
page.url = address;
|
@@ -76,7 +75,6 @@ function logAndWorkAroundDefaultLineBreaking(msg) {
|
|
76
75
|
var interpretAsWithoutNewline = /(^(\033\[\d+m)*[\.F](\033\[\d+m)*$)|( \.\.\.$)/;
|
77
76
|
if (navigator.userAgent.indexOf("Windows") < 0 && interpretAsWithoutNewline.test(msg)) {
|
78
77
|
try {
|
79
|
-
var system = require('system');
|
80
78
|
system.stdout.write(msg);
|
81
79
|
} catch (e) {
|
82
80
|
var fs = require('fs');
|
@@ -109,14 +107,14 @@ function replaceFunctionPlaceholders(fn, replacements) {
|
|
109
107
|
}
|
110
108
|
|
111
109
|
/**
|
112
|
-
*
|
110
|
+
* Custom "evaluate" method which we can easily do substitution with.
|
113
111
|
*
|
114
112
|
* @param {phantomjs.WebPage} page The WebPage object to overload
|
113
|
+
* @param {function} fn The function to replace occurrences within.
|
114
|
+
* @param {object} replacements Key => Value object of string replacements.
|
115
115
|
*/
|
116
|
-
function
|
117
|
-
|
118
|
-
page.evaluate = function(fn, replacements) { return page._evaluate(replaceFunctionPlaceholders(fn, replacements)); };
|
119
|
-
return page;
|
116
|
+
function evaluate(page, fn, replacements) {
|
117
|
+
return page.evaluate(replaceFunctionPlaceholders(fn, replacements));
|
120
118
|
}
|
121
119
|
|
122
120
|
/** Stubs a fake writeFile function into the test runner.
|
@@ -127,7 +125,7 @@ function overloadPageEvaluate(page) {
|
|
127
125
|
*/
|
128
126
|
// TODO: not bothering with error checking for now (closed environment)
|
129
127
|
function setupWriteFileFunction(page, key, path_separator) {
|
130
|
-
|
128
|
+
evaluate(page, function(){
|
131
129
|
window["%resultsObj%"] = {};
|
132
130
|
window.fs_path_separator = "%fs_path_separator%";
|
133
131
|
window.__phantom_writeFile = function(filename, text) {
|
@@ -144,7 +142,7 @@ function setupWriteFileFunction(page, key, path_separator) {
|
|
144
142
|
* be the same key provided to setupWriteFileFunction.
|
145
143
|
*/
|
146
144
|
function getXmlResults(page, key) {
|
147
|
-
return
|
145
|
+
return evaluate(page, function(){
|
148
146
|
return window["%resultsObj%"] || {};
|
149
147
|
}, {resultsObj: key});
|
150
148
|
}
|
@@ -168,20 +166,28 @@ function processPage(status, page, resultsKey) {
|
|
168
166
|
}
|
169
167
|
else {
|
170
168
|
var isFinished = function() {
|
171
|
-
return
|
169
|
+
return evaluate(page, function(){
|
172
170
|
// if there's a JUnitXmlReporter, return a boolean indicating if it is finished
|
173
|
-
if (window.
|
174
|
-
return window.
|
171
|
+
if (window.jasmineReporters && window.jasmineReporters.startTime) {
|
172
|
+
return !!window.jasmineReporters.endTime;
|
173
|
+
}
|
174
|
+
// otherwise, scrape the DOM for the HtmlReporter "finished in ..." output
|
175
|
+
var durElem = document.querySelector(".html-reporter .duration");
|
176
|
+
if (!durElem) {
|
177
|
+
durElem = document.querySelector(".jasmine_html-reporter .duration");
|
175
178
|
}
|
176
|
-
|
177
|
-
return false;
|
179
|
+
return durElem && durElem.textContent && durElem.textContent.toLowerCase().indexOf("finished in") === 0;
|
178
180
|
});
|
179
181
|
};
|
180
|
-
var
|
181
|
-
return
|
182
|
-
|
183
|
-
|
184
|
-
|
182
|
+
var getResultsFromHtmlRunner = function() {
|
183
|
+
return evaluate(page, function(){
|
184
|
+
var resultElem = document.querySelector(".html-reporter .alert .bar");
|
185
|
+
if (!resultElem) {
|
186
|
+
resultElem = document.querySelector(".jasmine_html-reporter .alert .bar");
|
187
|
+
}
|
188
|
+
return resultElem && resultElem.textContent &&
|
189
|
+
resultElem.textContent.match(/(\d+) spec.* (\d+) failure.*/) ||
|
190
|
+
["Unable to determine success or failure."];
|
185
191
|
});
|
186
192
|
};
|
187
193
|
var timeout = 60000;
|
@@ -199,20 +205,16 @@ function processPage(status, page, resultsKey) {
|
|
199
205
|
}
|
200
206
|
|
201
207
|
// print out a success / failure message of the results
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
// clearInterval(ival);
|
213
|
-
// }
|
214
|
-
|
215
|
-
page.__exit_code = 0;
|
208
|
+
var results = getResultsFromHtmlRunner();
|
209
|
+
var failures = Number(results[2]);
|
210
|
+
if (failures > 0) {
|
211
|
+
page.__exit_code = 1;
|
212
|
+
clearInterval(ival);
|
213
|
+
}
|
214
|
+
else {
|
215
|
+
page.__exit_code = 0;
|
216
|
+
clearInterval(ival);
|
217
|
+
}
|
216
218
|
}
|
217
219
|
else {
|
218
220
|
timeout -= loopInterval;
|
@@ -225,4 +227,3 @@ function processPage(status, page, resultsKey) {
|
|
225
227
|
}, loopInterval);
|
226
228
|
}
|
227
229
|
}
|
228
|
-
|
data/lib/learn_test/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: learn-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flatiron School
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -197,7 +197,7 @@ files:
|
|
197
197
|
- spec/fixtures/rspec-unit-spec/spec/spec_helper.rb
|
198
198
|
- spec/repo_parser_spec.rb
|
199
199
|
- spec/spec_helper.rb
|
200
|
-
homepage: https://learn
|
200
|
+
homepage: https://github.com/learn-co/learn-test
|
201
201
|
licenses:
|
202
202
|
- MIT
|
203
203
|
metadata: {}
|
@@ -218,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
218
|
version: '0'
|
219
219
|
requirements: []
|
220
220
|
rubyforge_project:
|
221
|
-
rubygems_version: 2.
|
221
|
+
rubygems_version: 2.5.1
|
222
222
|
signing_key:
|
223
223
|
specification_version: 4
|
224
224
|
summary: Runs RSpec, Jasmine, and Python Unit Test builds and pushes JSON output to
|