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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fef75741704908c87c1de0eddf32855448529a0
4
- data.tar.gz: c4643a237fd652d42adf2672116c8bf18c903d17
3
+ metadata.gz: 34bfbc3b76dddc66031d2b5cd1219a412f490354
4
+ data.tar.gz: d5a26157552218763f27cdee4d12dac7e38e7dd8
5
5
  SHA512:
6
- metadata.gz: f5e43c02992dcd9ca1f91a1c5b93e6231fcd4368720cc36f7141e6e91ac8c715bb2ae1f3673045ca60ee721ddfde8318354dad10e9c03ccf68eedaabef1db852
7
- data.tar.gz: 6617c5d9e46ca66f61bc75c2a176c90e52747a389101227fd66ac5a1f7ec32883a2d35f78c6c0db3a477b46291a7b7264d227297ba0d50bdbe663b55d6070454
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.co"
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 jasmine, phantom */
2
-
3
- // assign args based on phantomjs version
4
- if ( phantom.version.major === 2 ) {
5
- // NOTE phantom has depricated phantom.args in 2.0
6
- // use system.args instead
7
- var system = require('system');
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
- var system = null;
11
- var args = phantom.args;
9
+ args = system.args.slice(1);//use system args for phantom 2.0+
12
10
  }
13
11
 
14
- // Verify arguments
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.TrivialReporter being used\non the page, for the DOM elements it creates.\n");
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
- * Replaces the "evaluate" method with one we can easily do substitution with.
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 overloadPageEvaluate(page) {
117
- page._evaluate = page.evaluate;
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
- page.evaluate(function(){
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 page.evaluate(function(){
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 page.evaluate(function(){
169
+ return evaluate(page, function(){
172
170
  // if there's a JUnitXmlReporter, return a boolean indicating if it is finished
173
- if (window.done) {
174
- return window.done
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
- // otherwise, see if there is anything in a "finished-at" element
177
- return false;
179
+ return durElem && durElem.textContent && durElem.textContent.toLowerCase().indexOf("finished in") === 0;
178
180
  });
179
181
  };
180
- var getResults = function() {
181
- return page.evaluate(function(){
182
- return document.getElementsByClassName("bar").length &&
183
- document.getElementsByClassName("bar")[0].innerHTML.match(/(\d+) spec.* (\d+) failure.*/) ||
184
- ["Unable to determine success or failure."];
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
- // var results = getResults();
203
- // var failures = Number(results[2]);
204
- // if (failures > 0) {
205
- // console.error(results[0])
206
- // page.__exit_code = 1;
207
- // clearInterval(ival);
208
- // }
209
- // else {
210
- // console.log(results[0]);
211
- // page.__exit_code = 0;
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
-
@@ -1,3 +1,3 @@
1
1
  module LearnTest
2
- VERSION = '1.2.25'
2
+ VERSION = '1.2.26'
3
3
  end
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.25
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: 2015-10-29 00:00:00.000000000 Z
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.co
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.4.8
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