learn-test 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -20
  3. data/README.md +2 -2
  4. data/learn-test.gemspec +6 -9
  5. data/lib/learn_test.rb +0 -1
  6. data/lib/learn_test/runner.rb +0 -1
  7. data/lib/learn_test/version.rb +1 -1
  8. metadata +10 -106
  9. data/lib/learn_test/strategies/jasmine.rb +0 -181
  10. data/lib/learn_test/strategies/jasmine/boot.js +0 -184
  11. data/lib/learn_test/strategies/jasmine/console.js +0 -161
  12. data/lib/learn_test/strategies/jasmine/formatters/jasmine2-junit.js +0 -199
  13. data/lib/learn_test/strategies/jasmine/helpers/ConsoleHelper.js +0 -12
  14. data/lib/learn_test/strategies/jasmine/helpers/ConsoleHelperNoColor.js +0 -12
  15. data/lib/learn_test/strategies/jasmine/initializer.rb +0 -27
  16. data/lib/learn_test/strategies/jasmine/jasmine-html.js +0 -360
  17. data/lib/learn_test/strategies/jasmine/jasmine-jquery.js +0 -813
  18. data/lib/learn_test/strategies/jasmine/jasmine.css +0 -56
  19. data/lib/learn_test/strategies/jasmine/jasmine.js +0 -2403
  20. data/lib/learn_test/strategies/jasmine/jasmine_favicon.png +0 -0
  21. data/lib/learn_test/strategies/jasmine/jquery-1.8.0.min.js +0 -2
  22. data/lib/learn_test/strategies/jasmine/jquery-ui-1.8.23.custom.min.js +0 -125
  23. data/lib/learn_test/strategies/jasmine/runners/SpecRunner.html +0 -35
  24. data/lib/learn_test/strategies/jasmine/runners/run-jasmine.js +0 -229
  25. data/lib/learn_test/strategies/jasmine/templates/SpecRunnerTemplate.html.erb +0 -35
  26. data/lib/learn_test/strategies/jasmine/templates/SpecRunnerTemplateNoColor.html.erb +0 -35
  27. data/lib/learn_test/strategies/jasmine/templates/requires.yml.example +0 -7
  28. data/lib/learn_test/strategies/jasmine/vendor/require.js +0 -2077
  29. data/spec/features/jasmine_jquery_fixtures_spec.rb +0 -10
  30. data/spec/fixtures/jasmine-jquery-fixtures/index.html +0 -10
  31. data/spec/fixtures/jasmine-jquery-fixtures/requires.yml +0 -4
  32. data/spec/fixtures/jasmine-jquery-fixtures/spec/jasmine-jquery-fixtures-spec.js +0 -11
@@ -1,184 +0,0 @@
1
- /**
2
- Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
3
-
4
- If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
5
-
6
- The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
7
-
8
- [jasmine-gem]: http://github.com/pivotal/jasmine-gem
9
- */
10
-
11
- (function() {
12
-
13
- /**
14
- * ## Require & Instantiate
15
- *
16
- * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
17
- */
18
- window.jasmine = jasmineRequire.core(jasmineRequire);
19
-
20
- /**
21
- * Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
22
- */
23
- jasmineRequire.html(jasmine);
24
-
25
- /**
26
- * Create the Jasmine environment. This is used to run all specs in a project.
27
- */
28
- var env = jasmine.getEnv();
29
-
30
- /**
31
- * ## The Global Interface
32
- *
33
- * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
34
- */
35
- var jasmineInterface = {
36
- describe: function(description, specDefinitions) {
37
- return env.describe(description, specDefinitions);
38
- },
39
-
40
- xdescribe: function(description, specDefinitions) {
41
- return env.xdescribe(description, specDefinitions);
42
- },
43
-
44
- it: function(desc, func) {
45
- return env.it(desc, func);
46
- },
47
-
48
- xit: function(desc, func) {
49
- return env.xit(desc, func);
50
- },
51
-
52
- beforeEach: function(beforeEachFunction) {
53
- return env.beforeEach(beforeEachFunction);
54
- },
55
-
56
- afterEach: function(afterEachFunction) {
57
- return env.afterEach(afterEachFunction);
58
- },
59
-
60
- expect: function(actual) {
61
- return env.expect(actual);
62
- },
63
-
64
- pending: function() {
65
- return env.pending();
66
- },
67
-
68
- spyOn: function(obj, methodName) {
69
- return env.spyOn(obj, methodName);
70
- },
71
-
72
- jsApiReporter: new jasmine.JsApiReporter({
73
- timer: new jasmine.Timer()
74
- })
75
- };
76
-
77
- /**
78
- * Add all of the Jasmine global/public interface to the proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
79
- */
80
- if (typeof window == "undefined" && typeof exports == "object") {
81
- extend(exports, jasmineInterface);
82
- } else {
83
- extend(window, jasmineInterface);
84
- }
85
-
86
- /**
87
- * Expose the interface for adding custom equality testers.
88
- */
89
- jasmine.addCustomEqualityTester = function(tester) {
90
- env.addCustomEqualityTester(tester);
91
- };
92
-
93
- /**
94
- * Expose the interface for adding custom expectation matchers
95
- */
96
- jasmine.addMatchers = function(matchers) {
97
- return env.addMatchers(matchers);
98
- };
99
-
100
- /**
101
- * Expose the mock interface for the JavaScript timeout functions
102
- */
103
- jasmine.clock = function() {
104
- return env.clock;
105
- };
106
-
107
- /**
108
- * ## Runner Parameters
109
- *
110
- * More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
111
- */
112
-
113
- var queryString = new jasmine.QueryString({
114
- getWindowLocation: function() { return window.location; }
115
- });
116
-
117
- var catchingExceptions = queryString.getParam("catch");
118
- env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
119
-
120
- /**
121
- * ## Reporters
122
- * The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
123
- */
124
- var htmlReporter = new jasmine.HtmlReporter({
125
- env: env,
126
- onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
127
- getContainer: function() { return document.body; },
128
- createElement: function() { return document.createElement.apply(document, arguments); },
129
- createTextNode: function() { return document.createTextNode.apply(document, arguments); },
130
- timer: new jasmine.Timer()
131
- });
132
-
133
- /**
134
- * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
135
- */
136
- env.addReporter(jasmineInterface.jsApiReporter);
137
- var JUnitXmlReporter = jasmineRequire.JUnitXmlReporter()
138
- env.addReporter(new JUnitXmlReporter());
139
- env.addReporter(htmlReporter);
140
-
141
- /**
142
- * Filter which specs will be run by matching the start of the full name against the `spec` query param.
143
- */
144
- var specFilter = new jasmine.HtmlSpecFilter({
145
- filterString: function() { return queryString.getParam("spec"); }
146
- });
147
-
148
- env.specFilter = function(spec) {
149
- return specFilter.matches(spec.getFullName());
150
- };
151
-
152
- /**
153
- * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
154
- */
155
- window.setTimeout = window.setTimeout;
156
- window.setInterval = window.setInterval;
157
- window.clearTimeout = window.clearTimeout;
158
- window.clearInterval = window.clearInterval;
159
-
160
- /**
161
- * ## Execution
162
- *
163
- * Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
164
- */
165
- var currentWindowOnload = window.onload;
166
-
167
- window.onload = function() {
168
- if (currentWindowOnload) {
169
- currentWindowOnload();
170
- }
171
- htmlReporter.initialize();
172
- env.execute();
173
- };
174
-
175
- /**
176
- * Helper function for readability above.
177
- */
178
- function extend(destination, source) {
179
- for (var property in source) destination[property] = source[property];
180
- return destination;
181
- }
182
-
183
- }());
184
-
@@ -1,161 +0,0 @@
1
- /*
2
- Copyright (c) 2008-2013 Pivotal Labs
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining
5
- a copy of this software and associated documentation files (the
6
- "Software"), to deal in the Software without restriction, including
7
- without limitation the rights to use, copy, modify, merge, publish,
8
- distribute, sublicense, and/or sell copies of the Software, and to
9
- permit persons to whom the Software is furnished to do so, subject to
10
- the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- */
23
- function getJasmineRequireObj() {
24
- if (typeof module !== "undefined" && module.exports) {
25
- return exports;
26
- } else {
27
- window.jasmineRequire = window.jasmineRequire || {};
28
- return window.jasmineRequire;
29
- }
30
- }
31
-
32
- getJasmineRequireObj().console = function(jRequire, j$) {
33
- j$.ConsoleReporter = jRequire.ConsoleReporter();
34
- };
35
-
36
- getJasmineRequireObj().ConsoleReporter = function() {
37
-
38
- var noopTimer = {
39
- start: function(){},
40
- elapsed: function(){ return 0; }
41
- };
42
-
43
- function ConsoleReporter(options) {
44
- var print = options.print,
45
- showColors = options.showColors || false,
46
- onComplete = options.onComplete || function() {},
47
- timer = options.timer || noopTimer,
48
- specCount,
49
- failureCount,
50
- failedSpecs = [],
51
- pendingCount,
52
- ansi = {
53
- green: '\x1B[32m',
54
- red: '\x1B[31m',
55
- yellow: '\x1B[33m',
56
- none: '\x1B[0m'
57
- };
58
-
59
- this.jasmineStarted = function() {
60
- specCount = 0;
61
- failureCount = 0;
62
- pendingCount = 0;
63
- print("Started");
64
- printNewline();
65
- timer.start();
66
- };
67
-
68
- this.jasmineDone = function() {
69
- printNewline();
70
- for (var i = 0; i < failedSpecs.length; i++) {
71
- specFailureDetails(failedSpecs[i]);
72
- }
73
-
74
- printNewline();
75
- var specCounts = specCount + " " + plural("spec", specCount) + ", " +
76
- failureCount + " " + plural("failure", failureCount);
77
-
78
- if (pendingCount) {
79
- specCounts += ", " + pendingCount + " pending " + plural("spec", pendingCount);
80
- }
81
-
82
- print(specCounts);
83
-
84
- printNewline();
85
- var seconds = timer.elapsed() / 1000;
86
- print("Finished in " + seconds + " " + plural("second", seconds));
87
-
88
- printNewline();
89
-
90
- onComplete(failureCount === 0);
91
- };
92
-
93
- this.specDone = function(result) {
94
- specCount++;
95
-
96
- if (result.status == "pending") {
97
- pendingCount++;
98
- print(colored("yellow", "*"));
99
- return;
100
- }
101
-
102
- if (result.status == "passed") {
103
- print(colored("green", '.'));
104
- return;
105
- }
106
-
107
- if (result.status == "failed") {
108
- failureCount++;
109
- failedSpecs.push(result);
110
- print(colored("red", 'F'));
111
- }
112
- };
113
-
114
- return this;
115
-
116
- function printNewline() {
117
- print("\n");
118
- }
119
-
120
- function colored(color, str) {
121
- return showColors ? (ansi[color] + str + ansi.none) : str;
122
- }
123
-
124
- function plural(str, count) {
125
- return count == 1 ? str : str + "s";
126
- }
127
-
128
- function repeat(thing, times) {
129
- var arr = [];
130
- for (var i = 0; i < times; i++) {
131
- arr.push(thing);
132
- }
133
- return arr;
134
- }
135
-
136
- function indent(str, spaces) {
137
- var lines = (str || '').split("\n");
138
- var newArr = [];
139
- for (var i = 0; i < lines.length; i++) {
140
- newArr.push(repeat(" ", spaces).join("") + lines[i]);
141
- }
142
- return newArr.join("\n");
143
- }
144
-
145
- function specFailureDetails(result) {
146
- printNewline();
147
- print(result.fullName);
148
-
149
- for (var i = 0; i < result.failedExpectations.length; i++) {
150
- var failedExpectation = result.failedExpectations[i];
151
- printNewline();
152
- print(indent(failedExpectation.stack, 2));
153
- }
154
-
155
- printNewline();
156
- }
157
- }
158
-
159
- return ConsoleReporter;
160
- };
161
-
@@ -1,199 +0,0 @@
1
- (function() {
2
- "use strict";
3
-
4
- function getJasmineRequireObj() {
5
- if (typeof module !== "undefined" && module.exports) {
6
- return exports;
7
- } else {
8
- window.jasmineRequire = window.jasmineRequire || {};
9
- return window.jasmineRequire;
10
- }
11
- }
12
-
13
- if (typeof getJasmineRequireObj() == 'undefined') {
14
- throw new Error("jasmine 2.0 must be loaded before jasmine-junit");
15
- }
16
-
17
- getJasmineRequireObj().JUnitXmlReporter = function() {
18
-
19
-
20
- function JUnitXmlReporter(options) {
21
- var runStartTime;
22
- var specStartTime;
23
- var suiteLevel = -1;
24
- var suites = []
25
- var currentSuite;
26
- var totalNumberOfSpecs;
27
- var totalNumberOfFailures;
28
-
29
- this.jasmineStarted = function(started) {
30
- totalNumberOfSpecs = started.totalSpecsDefined;
31
- runStartTime = new Date();
32
- };
33
-
34
- this.jasmineDone = function() {
35
- // console.log('Jasmine ran in ', elapsed(runStartTime, new Date()), ' seconds')
36
- window.done = true
37
- };
38
-
39
- this.suiteStarted = function(result) {
40
- suiteLevel++;
41
- if (suiteLevel == 0) {
42
- totalNumberOfSpecs = 0;
43
- totalNumberOfFailures = 0;
44
- suites.push(result);
45
- currentSuite = result;
46
- currentSuite.startTime = new Date();
47
- currentSuite.noOfSpecs = 0;
48
- currentSuite.noOfFails = 0;
49
- currentSuite.specs = [];
50
- }
51
- };
52
-
53
- this.suiteDone = function(result) {
54
- if (suiteLevel == 0) {
55
- currentSuite.endTime = new Date();
56
- writeFile('.', descToFilename(result.description), suiteToJUnitXml(currentSuite))
57
- }
58
- suiteLevel--;
59
- };
60
-
61
- this.specStarted = function(result) {
62
- specStartTime = new Date();
63
- };
64
-
65
- this.specDone = function(result) {
66
- totalNumberOfSpecs++;
67
-
68
- if (isFailed(result)) {
69
- currentSuite.noOfFails++;
70
- }
71
- result.startTime = specStartTime;
72
- result.endTime = new Date();
73
- currentSuite.specs.push(result);
74
- currentSuite.noOfSpecs++;
75
- };
76
-
77
- return this;
78
-
79
- }
80
-
81
- return JUnitXmlReporter;
82
- };
83
-
84
- function isFailed(result) {
85
- return result.status === 'failed'
86
- }
87
-
88
- function isSkipped(result) {
89
- return result.status === 'pending'
90
- }
91
-
92
- function suiteToJUnitXml(suite) {
93
- var resultXml = '<?xml version="1.0" encoding="UTF-8"?>\n';
94
- resultXml += '<testsuites>\n';
95
- resultXml += '\t<testsuite tests="' + suite.noOfSpecs + '" errors="0" failures="' + suite.noOfFails + '" time="' + elapsed(suite.startTime, suite.endTime) + '" timestamp="' + ISODateString(suite.startTime) + '">\n'
96
- for (var i = 0; i < suite.specs.length; i++) {
97
- resultXml += specToJUnitXml(suite.specs[i], suite.description);
98
- }
99
- resultXml += '\t</testsuite>\n</testsuites>\n\n'
100
- return resultXml;
101
- }
102
-
103
- function specToJUnitXml(spec, suiteId) {
104
- var xml = '\t\t<testcase classname="' + suiteId +
105
- '" name="' + escapeInvalidXmlChars(spec.fullName.replace(suiteId+" ", "")) + '" time="' + elapsed(spec.startTime, spec.endTime) + '">\n';
106
- if (isSkipped(spec)) {
107
- xml += '\t\t\t<skipped />\n';
108
- }
109
- if (isFailed(spec)) {
110
- xml += failedToJUnitXml(spec.failedExpectations)
111
- }
112
- xml += '\t\t</testcase>\n'
113
- return xml;
114
- }
115
-
116
- function failedToJUnitXml(failedExpectations) {
117
- var failure;
118
- var failureXml = ""
119
- for (var i = 0; i < failedExpectations.length; i++) {
120
- failure = failedExpectations[i];
121
- failureXml += '\t\t\t<failure type="' + failure.matcherName + '" message="' + trim(escapeInvalidXmlChars(failure.message)) + '">\n';
122
- failureXml += escapeInvalidXmlChars(failure.stack || failure.message);
123
- failureXml += "\t\t\t</failure>\n";
124
- }
125
-
126
- return failureXml;
127
- }
128
-
129
- function descToFilename(desc) {
130
- return 'TEST-' + desc + '.xml';
131
- }
132
-
133
- function ISODateString(d) {
134
- function pad(n) {
135
- return n < 10 ? '0' + n : n;
136
- }
137
-
138
- return d.getFullYear() + '-' +
139
- pad(d.getMonth() + 1) + '-' +
140
- pad(d.getDate()) + 'T' +
141
- pad(d.getHours()) + ':' +
142
- pad(d.getMinutes()) + ':' +
143
- pad(d.getSeconds());
144
- }
145
-
146
- function elapsed(startTime, endTime) {
147
- return (endTime - startTime) / 1000;
148
- }
149
-
150
- function trim(str) {
151
- return str.replace(/^\s+/, "").replace(/\s+$/, "");
152
- }
153
-
154
- function escapeInvalidXmlChars(str) {
155
- return str.replace(/</g, "&lt;")
156
- .replace(/\>/g, "&gt;")
157
- .replace(/\"/g, "&quot;")
158
- .replace(/\'/g, "&apos;")
159
- .replace(/\&/g, "&amp;");
160
- }
161
-
162
- function writeFile(path, filename, text) {
163
- function getQualifiedFilename(separator) {
164
- if (path && path.substr(-1) !== separator && filename.substr(0) !== separator) {
165
- path += separator;
166
- }
167
- return path + filename;
168
- }
169
-
170
- // PhantomJS
171
- if(typeof(__phantom_writeFile) !== 'undefined') {
172
- try {
173
- // turn filename into a qualified path
174
- filename = getQualifiedFilename(window.fs_path_separator);
175
- // function injected by jasmine-runner.js
176
- __phantom_writeFile(filename, text);
177
- return;
178
- } catch (error) {
179
- console.log('Error writing file', error)
180
- }
181
- }
182
-
183
- // Node.js
184
- if(typeof(global) !== 'undefined') {
185
- try {
186
- var fs = require("fs");
187
- var nodejs_path = require("path");
188
- var fd = fs.openSync(nodejs_path.join(path, filename), "w");
189
- fs.writeSync(fd, text, 0);
190
- fs.closeSync(fd);
191
- return;
192
- } catch (error) {
193
- console.log('Error writing file', error)
194
- }
195
- }
196
- }
197
-
198
- })()
199
-