teaspoon 0.7.9 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +382 -260
- data/app/assets/javascripts/teaspoon-angular.js +108 -26241
- data/app/assets/javascripts/teaspoon-jasmine.js +103 -2642
- data/app/assets/javascripts/teaspoon-mocha.js +109 -5416
- data/app/assets/javascripts/teaspoon-qunit.js +107 -2255
- data/app/assets/javascripts/teaspoon-teaspoon.js +0 -1
- data/app/assets/javascripts/teaspoon/angular.coffee +3 -1
- data/app/assets/javascripts/teaspoon/base/hook.coffee +21 -0
- data/app/assets/javascripts/teaspoon/base/reporters/html.coffee +26 -14
- data/app/assets/javascripts/teaspoon/base/reporters/html/progress_view.coffee +1 -1
- data/app/assets/javascripts/teaspoon/base/reporters/html/template.coffee +3 -3
- data/app/assets/javascripts/teaspoon/base/teaspoon.coffee +10 -1
- data/app/assets/javascripts/teaspoon/jasmine.coffee +3 -1
- data/app/assets/javascripts/teaspoon/mocha.coffee +3 -1
- data/app/assets/javascripts/teaspoon/mocha/reporters/html.coffee +1 -1
- data/app/assets/javascripts/teaspoon/qunit.coffee +3 -1
- data/app/assets/javascripts/teaspoon/qunit/reporters/html.coffee +1 -1
- data/app/assets/javascripts/teaspoon/teaspoon.coffee +0 -1
- data/app/assets/stylesheets/teaspoon.css +12 -8
- data/app/controllers/teaspoon/suite_controller.rb +32 -0
- data/app/views/teaspoon/suite/_body.html.erb +0 -0
- data/app/views/teaspoon/suite/_boot.html.erb +4 -0
- data/app/views/teaspoon/suite/_boot_require_js.html.erb +19 -0
- data/app/views/teaspoon/{spec/suites.html.erb → suite/index.html.erb} +6 -7
- data/app/views/teaspoon/suite/show.html.erb +19 -0
- data/bin/teaspoon +1 -1
- data/config/routes.rb +14 -4
- data/lib/generators/teaspoon/install/POST_INSTALL +2 -2
- data/lib/generators/teaspoon/install/install_generator.rb +22 -11
- data/lib/generators/teaspoon/install/templates/_body.html.erb +0 -0
- data/lib/generators/teaspoon/install/templates/_boot.html.erb +4 -0
- data/lib/generators/teaspoon/install/templates/jasmine/env.rb +11 -0
- data/lib/generators/teaspoon/install/templates/jasmine/env_comments.rb +182 -0
- data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.coffee +8 -6
- data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.js +8 -7
- data/lib/generators/teaspoon/install/templates/mocha/env.rb +11 -0
- data/lib/generators/teaspoon/install/templates/mocha/env_comments.rb +182 -0
- data/lib/generators/teaspoon/install/templates/mocha/spec_helper.coffee +13 -13
- data/lib/generators/teaspoon/install/templates/mocha/spec_helper.js +13 -13
- data/lib/generators/teaspoon/install/templates/qunit/env.rb +11 -0
- data/lib/generators/teaspoon/install/templates/qunit/env_comments.rb +182 -0
- data/lib/generators/teaspoon/install/templates/qunit/test_helper.coffee +6 -5
- data/lib/generators/teaspoon/install/templates/qunit/test_helper.js +6 -5
- data/lib/tasks/teaspoon.rake +9 -2
- data/lib/teaspoon.rb +4 -6
- data/lib/teaspoon/command_line.rb +116 -134
- data/lib/teaspoon/configuration.rb +144 -66
- data/lib/teaspoon/console.rb +70 -37
- data/lib/teaspoon/coverage.rb +42 -15
- data/lib/teaspoon/deprecated.rb +65 -0
- data/lib/teaspoon/drivers/base.rb +10 -0
- data/lib/teaspoon/drivers/phantomjs/runner.js +9 -11
- data/lib/teaspoon/drivers/phantomjs_driver.rb +21 -21
- data/lib/teaspoon/drivers/selenium_driver.rb +32 -13
- data/lib/teaspoon/engine.rb +32 -12
- data/lib/teaspoon/environment.rb +16 -12
- data/lib/teaspoon/exceptions.rb +41 -5
- data/lib/teaspoon/exporter.rb +52 -0
- data/lib/teaspoon/formatters/base.rb +171 -0
- data/lib/teaspoon/formatters/clean_formatter.rb +2 -4
- data/lib/teaspoon/formatters/documentation_formatter.rb +60 -0
- data/lib/teaspoon/formatters/dot_formatter.rb +12 -90
- data/lib/teaspoon/formatters/json_formatter.rb +36 -0
- data/lib/teaspoon/formatters/junit_formatter.rb +51 -32
- data/lib/teaspoon/formatters/modules/report_module.rb +76 -0
- data/lib/teaspoon/formatters/pride_formatter.rb +23 -27
- data/lib/teaspoon/formatters/snowday_formatter.rb +7 -11
- data/lib/teaspoon/formatters/swayze_or_oprah_formatter.rb +88 -64
- data/lib/teaspoon/formatters/tap_formatter.rb +18 -27
- data/lib/teaspoon/formatters/tap_y_formatter.rb +35 -45
- data/lib/teaspoon/formatters/teamcity_formatter.rb +69 -31
- data/lib/teaspoon/instrumentation.rb +33 -33
- data/lib/teaspoon/result.rb +2 -1
- data/lib/teaspoon/runner.rb +40 -28
- data/lib/teaspoon/server.rb +23 -25
- data/lib/teaspoon/suite.rb +52 -72
- data/lib/teaspoon/utility.rb +3 -14
- data/lib/teaspoon/version.rb +1 -1
- data/spec/dummy/app/assets/javascripts/integration/integration_spec.coffee +3 -0
- data/spec/dummy/app/assets/javascripts/integration/spec_helper.coffee +2 -0
- data/spec/dummy/config/application.rb +3 -0
- data/spec/features/console_reporter_spec.rb +48 -18
- data/spec/features/hooks_spec.rb +23 -41
- data/spec/features/html_reporter_spec.rb +38 -21
- data/spec/features/install_generator_spec.rb +34 -20
- data/spec/features/instrumentation_spec.rb +3 -2
- data/spec/fixtures/coverage.json +243 -0
- data/spec/javascripts/fixtures/_body.html.erb +1 -0
- data/spec/javascripts/jasmine_helper.coffee +1 -1
- data/spec/javascripts/teaspoon/base/fixture_spec.coffee +4 -4
- data/spec/javascripts/teaspoon/base/reporters/html_spec.coffee +9 -10
- data/spec/javascripts/teaspoon/mocha/reporters/html_mspec.coffee +0 -6
- data/spec/javascripts/teaspoon/phantomjs/runner_spec.coffee +5 -6
- data/spec/javascripts/turbolinks_helper.coffee +1 -1
- data/spec/spec_helper.rb +3 -4
- data/spec/teaspoon/command_line_spec.rb +139 -23
- data/spec/teaspoon/configuration_spec.rb +164 -46
- data/spec/teaspoon/console_spec.rb +142 -47
- data/spec/teaspoon/coverage_spec.rb +98 -28
- data/spec/teaspoon/drivers/base_spec.rb +5 -0
- data/spec/teaspoon/drivers/phantomjs_driver_spec.rb +32 -14
- data/spec/teaspoon/drivers/selenium_driver_spec.rb +32 -24
- data/spec/teaspoon/engine_spec.rb +8 -5
- data/spec/teaspoon/environment_spec.rb +56 -33
- data/spec/teaspoon/exceptions_spec.rb +57 -0
- data/spec/teaspoon/exporter_spec.rb +96 -0
- data/spec/teaspoon/formatters/base_spec.rb +259 -0
- data/spec/teaspoon/formatters/clean_formatter_spec.rb +37 -0
- data/spec/teaspoon/formatters/documentation_formatter_spec.rb +127 -0
- data/spec/teaspoon/formatters/dot_formatter_spec.rb +52 -56
- data/spec/teaspoon/formatters/json_formatter_spec.rb +77 -0
- data/spec/teaspoon/formatters/junit_formatter_spec.rb +72 -35
- data/spec/teaspoon/formatters/pride_formatter_spec.rb +37 -0
- data/spec/teaspoon/formatters/snowday_formatter_spec.rb +35 -0
- data/spec/teaspoon/formatters/tap_formatter_spec.rb +29 -81
- data/spec/teaspoon/formatters/tap_y_formatter_spec.rb +31 -141
- data/spec/teaspoon/formatters/teamcity_formatter_spec.rb +99 -42
- data/spec/teaspoon/instrumentation_spec.rb +44 -44
- data/spec/teaspoon/result_spec.rb +37 -0
- data/spec/teaspoon/runner_spec.rb +70 -59
- data/spec/teaspoon/server_spec.rb +34 -52
- data/spec/teaspoon/suite_spec.rb +42 -188
- data/spec/teaspoon_env.rb +39 -28
- data/vendor/assets/javascripts/{angular-scenario-1.0.5.js → angular/1.0.5.js} +0 -0
- data/vendor/assets/javascripts/{angular-scenario-1.0.5.MIT-LICENSE → angular/MIT-LICENSE} +0 -0
- data/vendor/assets/javascripts/{jasmine-1.3.1.js → jasmine/1.3.1.js} +0 -0
- data/vendor/assets/javascripts/jasmine/2.0.0.js +2412 -0
- data/vendor/assets/javascripts/{jasmine-1.3.1.MIT.LICENSE → jasmine/MIT.LICENSE} +0 -0
- data/vendor/assets/javascripts/{mocha-1.10.0.js → mocha/1.10.0.js} +1 -0
- data/vendor/assets/javascripts/mocha/1.17.1.js +5813 -0
- data/vendor/assets/javascripts/{mocha-1.10.1.MIT.LICENSE → mocha/MIT.LICENSE} +0 -0
- data/vendor/assets/javascripts/{qunit-1.12.0.js → qunit/1.12.0.js} +1 -1
- data/vendor/assets/javascripts/qunit/1.14.0.js +2288 -0
- data/vendor/assets/javascripts/{qunit-1.12.0.MIT.LICENSE → qunit/MIT.LICENSE} +0 -0
- data/vendor/assets/javascripts/support/chai.js +827 -385
- data/vendor/assets/javascripts/support/jasmine-jquery-1.7.0.js +720 -0
- data/vendor/assets/javascripts/support/jasmine-jquery-2.0.0.js +812 -0
- data/vendor/assets/javascripts/support/sinon-chai.js +17 -0
- data/vendor/assets/javascripts/support/sinon.js +1138 -643
- metadata +57 -36
- data/app/controllers/teaspoon/spec_controller.rb +0 -38
- data/app/helpers/teaspoon/spec_helper.rb +0 -36
- data/app/views/teaspoon/spec/_require_js.html.erb +0 -21
- data/app/views/teaspoon/spec/_standard.html.erb +0 -4
- data/app/views/teaspoon/spec/runner.html.erb +0 -19
- data/lib/generators/teaspoon/install/templates/env.rb +0 -38
- data/lib/generators/teaspoon/install/templates/jasmine/initializer.rb +0 -64
- data/lib/generators/teaspoon/install/templates/mocha/initializer.rb +0 -64
- data/lib/generators/teaspoon/install/templates/qunit/initializer.rb +0 -64
- data/lib/teaspoon/check_coverage.rb +0 -33
- data/lib/teaspoon/drivers/base_driver.rb +0 -10
- data/lib/teaspoon/exception_handling.rb +0 -18
- data/lib/teaspoon/formatters/base_formatter.rb +0 -63
- data/spec/dummy/config/initializers/teaspoon.rb +0 -41
- data/spec/teaspoon/check_coverage_spec.rb +0 -50
- data/spec/teaspoon/formatters/base_formatter_spec.rb +0 -45
- data/vendor/assets/javascripts/support/chai.MIT.LICENSE +0 -22
- data/vendor/assets/javascripts/support/expect.MIT.LICENSE +0 -22
- data/vendor/assets/javascripts/support/jasmine-jquery.MIT.LICENSE +0 -20
- data/vendor/assets/javascripts/support/jasmine-jquery.js +0 -659
- data/vendor/assets/javascripts/support/sinon-chai.MIT-ISH.LICENSE +0 -13
- data/vendor/assets/javascripts/support/sinon.BSD.LICENSE +0 -27
@@ -0,0 +1,720 @@
|
|
1
|
+
/*!
|
2
|
+
Jasmine-jQuery: a set of jQuery helpers for Jasmine tests.
|
3
|
+
|
4
|
+
Version 1.7.0
|
5
|
+
|
6
|
+
https://github.com/velesin/jasmine-jquery
|
7
|
+
|
8
|
+
Copyright (c) 2010-2013 Wojciech Zawistowski, Travis Jeffery
|
9
|
+
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
11
|
+
a copy of this software and associated documentation files (the
|
12
|
+
"Software"), to deal in the Software without restriction, including
|
13
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
14
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
15
|
+
permit persons to whom the Software is furnished to do so, subject to
|
16
|
+
the following conditions:
|
17
|
+
|
18
|
+
The above copyright notice and this permission notice shall be
|
19
|
+
included in all copies or substantial portions of the Software.
|
20
|
+
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
22
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
23
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
24
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
25
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
26
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
27
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
28
|
+
*/
|
29
|
+
|
30
|
+
+function (window, jasmine, $) { "use strict";
|
31
|
+
|
32
|
+
jasmine.spiedEventsKey = function (selector, eventName) {
|
33
|
+
return [$(selector).selector, eventName].toString()
|
34
|
+
}
|
35
|
+
|
36
|
+
jasmine.getFixtures = function () {
|
37
|
+
return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures()
|
38
|
+
}
|
39
|
+
|
40
|
+
jasmine.getStyleFixtures = function () {
|
41
|
+
return jasmine.currentStyleFixtures_ = jasmine.currentStyleFixtures_ || new jasmine.StyleFixtures()
|
42
|
+
}
|
43
|
+
|
44
|
+
jasmine.Fixtures = function () {
|
45
|
+
this.containerId = 'jasmine-fixtures'
|
46
|
+
this.fixturesCache_ = {}
|
47
|
+
this.fixturesPath = 'spec/javascripts/fixtures'
|
48
|
+
}
|
49
|
+
|
50
|
+
jasmine.Fixtures.prototype.set = function (html) {
|
51
|
+
this.cleanUp()
|
52
|
+
return this.createContainer_(html)
|
53
|
+
}
|
54
|
+
|
55
|
+
jasmine.Fixtures.prototype.appendSet= function (html) {
|
56
|
+
this.addToContainer_(html)
|
57
|
+
}
|
58
|
+
|
59
|
+
jasmine.Fixtures.prototype.preload = function () {
|
60
|
+
this.read.apply(this, arguments)
|
61
|
+
}
|
62
|
+
|
63
|
+
jasmine.Fixtures.prototype.load = function () {
|
64
|
+
this.cleanUp()
|
65
|
+
this.createContainer_(this.read.apply(this, arguments))
|
66
|
+
}
|
67
|
+
|
68
|
+
jasmine.Fixtures.prototype.appendLoad = function () {
|
69
|
+
this.addToContainer_(this.read.apply(this, arguments))
|
70
|
+
}
|
71
|
+
|
72
|
+
jasmine.Fixtures.prototype.read = function () {
|
73
|
+
var htmlChunks = []
|
74
|
+
, fixtureUrls = arguments
|
75
|
+
|
76
|
+
for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
|
77
|
+
htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex]))
|
78
|
+
}
|
79
|
+
|
80
|
+
return htmlChunks.join('')
|
81
|
+
}
|
82
|
+
|
83
|
+
jasmine.Fixtures.prototype.clearCache = function () {
|
84
|
+
this.fixturesCache_ = {}
|
85
|
+
}
|
86
|
+
|
87
|
+
jasmine.Fixtures.prototype.cleanUp = function () {
|
88
|
+
$('#' + this.containerId).remove()
|
89
|
+
}
|
90
|
+
|
91
|
+
jasmine.Fixtures.prototype.sandbox = function (attributes) {
|
92
|
+
var attributesToSet = attributes || {}
|
93
|
+
return $('<div id="sandbox" />').attr(attributesToSet)
|
94
|
+
}
|
95
|
+
|
96
|
+
jasmine.Fixtures.prototype.createContainer_ = function (html) {
|
97
|
+
var container = $('<div>')
|
98
|
+
.attr('id', this.containerId)
|
99
|
+
.html(html)
|
100
|
+
|
101
|
+
$(document.body).append(container)
|
102
|
+
return container
|
103
|
+
}
|
104
|
+
|
105
|
+
jasmine.Fixtures.prototype.addToContainer_ = function (html){
|
106
|
+
var container = $(document.body).find('#'+this.containerId).append(html)
|
107
|
+
if(!container.length){
|
108
|
+
this.createContainer_(html)
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
jasmine.Fixtures.prototype.getFixtureHtml_ = function (url) {
|
113
|
+
if (typeof this.fixturesCache_[url] === 'undefined') {
|
114
|
+
this.loadFixtureIntoCache_(url)
|
115
|
+
}
|
116
|
+
return this.fixturesCache_[url]
|
117
|
+
}
|
118
|
+
|
119
|
+
jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) {
|
120
|
+
var self = this
|
121
|
+
, url = this.makeFixtureUrl_(relativeUrl)
|
122
|
+
, htmlText = ''
|
123
|
+
, request = $.ajax({
|
124
|
+
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
|
125
|
+
cache: false,
|
126
|
+
url: url,
|
127
|
+
success: function (data, status, $xhr) {
|
128
|
+
htmlText = $xhr.responseText
|
129
|
+
},
|
130
|
+
error: function (jqXHR, status, errorThrown) {
|
131
|
+
throw new Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')')
|
132
|
+
}
|
133
|
+
})
|
134
|
+
var scripts = $($.parseHTML(htmlText, true)).find('script') || [];
|
135
|
+
scripts.each(function(){
|
136
|
+
$.ajax({
|
137
|
+
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
|
138
|
+
cache: false,
|
139
|
+
url: $(this).attr('src'),
|
140
|
+
success: function (data, status, $xhr) {
|
141
|
+
htmlText += '<script>' + $xhr.responseText + '</script>'
|
142
|
+
},
|
143
|
+
error: function (jqXHR, status, errorThrown) {
|
144
|
+
throw new Error('Script could not be loaded: ' + scriptSrc + ' (status: ' + status + ', message: ' + errorThrown.message + ')')
|
145
|
+
}
|
146
|
+
});
|
147
|
+
})
|
148
|
+
self.fixturesCache_[relativeUrl] = htmlText;
|
149
|
+
}
|
150
|
+
|
151
|
+
jasmine.Fixtures.prototype.makeFixtureUrl_ = function (relativeUrl){
|
152
|
+
return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
|
153
|
+
}
|
154
|
+
|
155
|
+
jasmine.Fixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) {
|
156
|
+
return this[methodName].apply(this, passedArguments)
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
jasmine.StyleFixtures = function () {
|
161
|
+
this.fixturesCache_ = {}
|
162
|
+
this.fixturesNodes_ = []
|
163
|
+
this.fixturesPath = 'spec/javascripts/fixtures'
|
164
|
+
}
|
165
|
+
|
166
|
+
jasmine.StyleFixtures.prototype.set = function (css) {
|
167
|
+
this.cleanUp()
|
168
|
+
this.createStyle_(css)
|
169
|
+
}
|
170
|
+
|
171
|
+
jasmine.StyleFixtures.prototype.appendSet = function (css) {
|
172
|
+
this.createStyle_(css)
|
173
|
+
}
|
174
|
+
|
175
|
+
jasmine.StyleFixtures.prototype.preload = function () {
|
176
|
+
this.read_.apply(this, arguments)
|
177
|
+
}
|
178
|
+
|
179
|
+
jasmine.StyleFixtures.prototype.load = function () {
|
180
|
+
this.cleanUp()
|
181
|
+
this.createStyle_(this.read_.apply(this, arguments))
|
182
|
+
}
|
183
|
+
|
184
|
+
jasmine.StyleFixtures.prototype.appendLoad = function () {
|
185
|
+
this.createStyle_(this.read_.apply(this, arguments))
|
186
|
+
}
|
187
|
+
|
188
|
+
jasmine.StyleFixtures.prototype.cleanUp = function () {
|
189
|
+
while(this.fixturesNodes_.length) {
|
190
|
+
this.fixturesNodes_.pop().remove()
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
jasmine.StyleFixtures.prototype.createStyle_ = function (html) {
|
195
|
+
var styleText = $('<div></div>').html(html).text()
|
196
|
+
, style = $('<style>' + styleText + '</style>')
|
197
|
+
|
198
|
+
this.fixturesNodes_.push(style)
|
199
|
+
$('head').append(style)
|
200
|
+
}
|
201
|
+
|
202
|
+
jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache
|
203
|
+
jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read
|
204
|
+
jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_
|
205
|
+
jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_
|
206
|
+
jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_
|
207
|
+
jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_
|
208
|
+
|
209
|
+
jasmine.getJSONFixtures = function () {
|
210
|
+
return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures()
|
211
|
+
}
|
212
|
+
|
213
|
+
jasmine.JSONFixtures = function () {
|
214
|
+
this.fixturesCache_ = {}
|
215
|
+
this.fixturesPath = 'spec/javascripts/fixtures/json'
|
216
|
+
}
|
217
|
+
|
218
|
+
jasmine.JSONFixtures.prototype.load = function () {
|
219
|
+
this.read.apply(this, arguments)
|
220
|
+
return this.fixturesCache_
|
221
|
+
}
|
222
|
+
|
223
|
+
jasmine.JSONFixtures.prototype.read = function () {
|
224
|
+
var fixtureUrls = arguments
|
225
|
+
|
226
|
+
for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
|
227
|
+
this.getFixtureData_(fixtureUrls[urlIndex])
|
228
|
+
}
|
229
|
+
|
230
|
+
return this.fixturesCache_
|
231
|
+
}
|
232
|
+
|
233
|
+
jasmine.JSONFixtures.prototype.clearCache = function () {
|
234
|
+
this.fixturesCache_ = {}
|
235
|
+
}
|
236
|
+
|
237
|
+
jasmine.JSONFixtures.prototype.getFixtureData_ = function (url) {
|
238
|
+
if (!this.fixturesCache_[url]) this.loadFixtureIntoCache_(url)
|
239
|
+
return this.fixturesCache_[url]
|
240
|
+
}
|
241
|
+
|
242
|
+
jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function (relativeUrl) {
|
243
|
+
var self = this
|
244
|
+
, url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
|
245
|
+
|
246
|
+
$.ajax({
|
247
|
+
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
|
248
|
+
cache: false,
|
249
|
+
dataType: 'json',
|
250
|
+
url: url,
|
251
|
+
success: function (data) {
|
252
|
+
self.fixturesCache_[relativeUrl] = data
|
253
|
+
},
|
254
|
+
error: function (jqXHR, status, errorThrown) {
|
255
|
+
throw new Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')')
|
256
|
+
}
|
257
|
+
})
|
258
|
+
}
|
259
|
+
|
260
|
+
jasmine.JSONFixtures.prototype.proxyCallTo_ = function (methodName, passedArguments) {
|
261
|
+
return this[methodName].apply(this, passedArguments)
|
262
|
+
}
|
263
|
+
|
264
|
+
jasmine.jQuery = function () {}
|
265
|
+
|
266
|
+
jasmine.jQuery.browserTagCaseIndependentHtml = function (html) {
|
267
|
+
return $('<div/>').append(html).html()
|
268
|
+
}
|
269
|
+
|
270
|
+
jasmine.jQuery.elementToString = function (element) {
|
271
|
+
return $(element).map(function () { return this.outerHTML; }).toArray().join(', ')
|
272
|
+
}
|
273
|
+
|
274
|
+
jasmine.jQuery.matchersClass = {}
|
275
|
+
|
276
|
+
var data = {
|
277
|
+
spiedEvents: {}
|
278
|
+
, handlers: []
|
279
|
+
}
|
280
|
+
|
281
|
+
jasmine.jQuery.events = {
|
282
|
+
spyOn: function (selector, eventName) {
|
283
|
+
var handler = function (e) {
|
284
|
+
data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments)
|
285
|
+
}
|
286
|
+
|
287
|
+
$(selector).on(eventName, handler)
|
288
|
+
data.handlers.push(handler)
|
289
|
+
|
290
|
+
return {
|
291
|
+
selector: selector,
|
292
|
+
eventName: eventName,
|
293
|
+
handler: handler,
|
294
|
+
reset: function (){
|
295
|
+
delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
|
296
|
+
}
|
297
|
+
}
|
298
|
+
},
|
299
|
+
|
300
|
+
args: function (selector, eventName) {
|
301
|
+
var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
|
302
|
+
|
303
|
+
if (!actualArgs) {
|
304
|
+
throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent."
|
305
|
+
}
|
306
|
+
|
307
|
+
return actualArgs
|
308
|
+
},
|
309
|
+
|
310
|
+
wasTriggered: function (selector, eventName) {
|
311
|
+
return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)])
|
312
|
+
},
|
313
|
+
|
314
|
+
wasTriggeredWith: function (selector, eventName, expectedArgs, env) {
|
315
|
+
var actualArgs = jasmine.jQuery.events.args(selector, eventName).slice(1)
|
316
|
+
if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') {
|
317
|
+
actualArgs = actualArgs[0]
|
318
|
+
}
|
319
|
+
return env.equals_(expectedArgs, actualArgs)
|
320
|
+
},
|
321
|
+
|
322
|
+
wasPrevented: function (selector, eventName) {
|
323
|
+
var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
|
324
|
+
, e = args ? args[0] : undefined
|
325
|
+
|
326
|
+
return e && e.isDefaultPrevented()
|
327
|
+
},
|
328
|
+
|
329
|
+
wasStopped: function (selector, eventName) {
|
330
|
+
var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
|
331
|
+
, e = args ? args[0] : undefined
|
332
|
+
return e && e.isPropagationStopped()
|
333
|
+
},
|
334
|
+
|
335
|
+
cleanUp: function () {
|
336
|
+
data.spiedEvents = {}
|
337
|
+
data.handlers = []
|
338
|
+
}
|
339
|
+
}
|
340
|
+
|
341
|
+
var jQueryMatchers = {
|
342
|
+
toHaveClass: function (className) {
|
343
|
+
return this.actual.hasClass(className)
|
344
|
+
},
|
345
|
+
|
346
|
+
toHaveCss: function (css){
|
347
|
+
for (var prop in css){
|
348
|
+
var value = css[prop]
|
349
|
+
// see issue #147 on gh
|
350
|
+
;if (value === 'auto' && this.actual.get(0).style[prop] === 'auto') continue
|
351
|
+
if (this.actual.css(prop) !== value) return false
|
352
|
+
}
|
353
|
+
return true
|
354
|
+
},
|
355
|
+
|
356
|
+
toBeVisible: function () {
|
357
|
+
return this.actual.is(':visible')
|
358
|
+
},
|
359
|
+
|
360
|
+
toBeHidden: function () {
|
361
|
+
return this.actual.is(':hidden')
|
362
|
+
},
|
363
|
+
|
364
|
+
toBeSelected: function () {
|
365
|
+
return this.actual.is(':selected')
|
366
|
+
},
|
367
|
+
|
368
|
+
toBeChecked: function () {
|
369
|
+
return this.actual.is(':checked')
|
370
|
+
},
|
371
|
+
|
372
|
+
toBeEmpty: function () {
|
373
|
+
return this.actual.is(':empty')
|
374
|
+
},
|
375
|
+
|
376
|
+
toBeInDOM: function () {
|
377
|
+
return $.contains(document.documentElement, this.actual[0])
|
378
|
+
},
|
379
|
+
|
380
|
+
toExist: function () {
|
381
|
+
return this.actual.length
|
382
|
+
},
|
383
|
+
|
384
|
+
toHaveLength: function (length) {
|
385
|
+
return this.actual.length === length
|
386
|
+
},
|
387
|
+
|
388
|
+
toHaveAttr: function (attributeName, expectedAttributeValue) {
|
389
|
+
return hasProperty(this.actual.attr(attributeName), expectedAttributeValue)
|
390
|
+
},
|
391
|
+
|
392
|
+
toHaveProp: function (propertyName, expectedPropertyValue) {
|
393
|
+
return hasProperty(this.actual.prop(propertyName), expectedPropertyValue)
|
394
|
+
},
|
395
|
+
|
396
|
+
toHaveId: function (id) {
|
397
|
+
return this.actual.attr('id') == id
|
398
|
+
},
|
399
|
+
|
400
|
+
toHaveHtml: function (html) {
|
401
|
+
return this.actual.html() == jasmine.jQuery.browserTagCaseIndependentHtml(html)
|
402
|
+
},
|
403
|
+
|
404
|
+
toContainHtml: function (html){
|
405
|
+
var actualHtml = this.actual.html()
|
406
|
+
, expectedHtml = jasmine.jQuery.browserTagCaseIndependentHtml(html)
|
407
|
+
|
408
|
+
return (actualHtml.indexOf(expectedHtml) >= 0)
|
409
|
+
},
|
410
|
+
|
411
|
+
toHaveText: function (text) {
|
412
|
+
var trimmedText = $.trim(this.actual.text())
|
413
|
+
|
414
|
+
if (text && $.isFunction(text.test)) {
|
415
|
+
return text.test(trimmedText)
|
416
|
+
} else {
|
417
|
+
return trimmedText == text
|
418
|
+
}
|
419
|
+
},
|
420
|
+
|
421
|
+
toContainText: function (text) {
|
422
|
+
var trimmedText = $.trim(this.actual.text())
|
423
|
+
|
424
|
+
if (text && $.isFunction(text.test)) {
|
425
|
+
return text.test(trimmedText)
|
426
|
+
} else {
|
427
|
+
return trimmedText.indexOf(text) != -1
|
428
|
+
}
|
429
|
+
},
|
430
|
+
|
431
|
+
toHaveValue: function (value) {
|
432
|
+
return this.actual.val() === value
|
433
|
+
},
|
434
|
+
|
435
|
+
toHaveData: function (key, expectedValue) {
|
436
|
+
return hasProperty(this.actual.data(key), expectedValue)
|
437
|
+
},
|
438
|
+
|
439
|
+
toBe: function (selector) {
|
440
|
+
return this.actual.is(selector)
|
441
|
+
},
|
442
|
+
|
443
|
+
toContain: function (selector) {
|
444
|
+
return this.actual.find(selector).length
|
445
|
+
},
|
446
|
+
|
447
|
+
toBeMatchedBy: function (selector) {
|
448
|
+
return this.actual.filter(selector).length
|
449
|
+
},
|
450
|
+
|
451
|
+
toBeDisabled: function (selector){
|
452
|
+
return this.actual.is(':disabled')
|
453
|
+
},
|
454
|
+
|
455
|
+
toBeFocused: function (selector) {
|
456
|
+
return this.actual[0] === this.actual[0].ownerDocument.activeElement
|
457
|
+
},
|
458
|
+
|
459
|
+
toHandle: function (event) {
|
460
|
+
var events = $._data(this.actual.get(0), "events")
|
461
|
+
|
462
|
+
if(!events || !event || typeof event !== "string") {
|
463
|
+
return false
|
464
|
+
}
|
465
|
+
|
466
|
+
var namespaces = event.split(".")
|
467
|
+
, eventType = namespaces.shift()
|
468
|
+
, sortedNamespaces = namespaces.slice(0).sort()
|
469
|
+
, namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)")
|
470
|
+
|
471
|
+
if(events[eventType] && namespaces.length) {
|
472
|
+
for(var i = 0; i < events[eventType].length; i++) {
|
473
|
+
var namespace = events[eventType][i].namespace
|
474
|
+
|
475
|
+
if(namespaceRegExp.test(namespace)) {
|
476
|
+
return true
|
477
|
+
}
|
478
|
+
}
|
479
|
+
} else {
|
480
|
+
return events[eventType] && events[eventType].length > 0
|
481
|
+
}
|
482
|
+
},
|
483
|
+
|
484
|
+
toHandleWith: function (eventName, eventHandler) {
|
485
|
+
var normalizedEventName = eventName.split('.')[0]
|
486
|
+
, stack = $._data(this.actual.get(0), "events")[normalizedEventName]
|
487
|
+
|
488
|
+
for (var i = 0; i < stack.length; i++) {
|
489
|
+
if (stack[i].handler == eventHandler) return true
|
490
|
+
}
|
491
|
+
|
492
|
+
return false
|
493
|
+
}
|
494
|
+
}
|
495
|
+
|
496
|
+
var hasProperty = function (actualValue, expectedValue) {
|
497
|
+
if (expectedValue === undefined) return actualValue !== undefined
|
498
|
+
|
499
|
+
return actualValue === expectedValue
|
500
|
+
}
|
501
|
+
|
502
|
+
var bindMatcher = function (methodName) {
|
503
|
+
var builtInMatcher = jasmine.Matchers.prototype[methodName]
|
504
|
+
|
505
|
+
jasmine.jQuery.matchersClass[methodName] = function () {
|
506
|
+
if (this.actual
|
507
|
+
&& (this.actual instanceof $
|
508
|
+
|| jasmine.isDomNode(this.actual))) {
|
509
|
+
this.actual = $(this.actual)
|
510
|
+
var result = jQueryMatchers[methodName].apply(this, arguments)
|
511
|
+
, element
|
512
|
+
|
513
|
+
if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML")
|
514
|
+
this.actual = jasmine.jQuery.elementToString(this.actual)
|
515
|
+
|
516
|
+
return result
|
517
|
+
}
|
518
|
+
|
519
|
+
if (builtInMatcher) {
|
520
|
+
return builtInMatcher.apply(this, arguments)
|
521
|
+
}
|
522
|
+
|
523
|
+
return false
|
524
|
+
}
|
525
|
+
}
|
526
|
+
|
527
|
+
for(var methodName in jQueryMatchers) {
|
528
|
+
bindMatcher(methodName)
|
529
|
+
}
|
530
|
+
|
531
|
+
beforeEach(function () {
|
532
|
+
this.addMatchers(jasmine.jQuery.matchersClass)
|
533
|
+
this.addMatchers({
|
534
|
+
toHaveBeenTriggeredOn: function (selector) {
|
535
|
+
this.message = function () {
|
536
|
+
return [
|
537
|
+
"Expected event " + this.actual + " to have been triggered on " + selector,
|
538
|
+
"Expected event " + this.actual + " not to have been triggered on " + selector
|
539
|
+
]
|
540
|
+
}
|
541
|
+
return jasmine.jQuery.events.wasTriggered(selector, this.actual)
|
542
|
+
}
|
543
|
+
})
|
544
|
+
|
545
|
+
this.addMatchers({
|
546
|
+
toHaveBeenTriggered: function (){
|
547
|
+
var eventName = this.actual.eventName
|
548
|
+
, selector = this.actual.selector
|
549
|
+
|
550
|
+
this.message = function () {
|
551
|
+
return [
|
552
|
+
"Expected event " + eventName + " to have been triggered on " + selector,
|
553
|
+
"Expected event " + eventName + " not to have been triggered on " + selector
|
554
|
+
]
|
555
|
+
}
|
556
|
+
|
557
|
+
return jasmine.jQuery.events.wasTriggered(selector, eventName)
|
558
|
+
}
|
559
|
+
})
|
560
|
+
|
561
|
+
this.addMatchers({
|
562
|
+
toHaveBeenTriggeredOnAndWith: function () {
|
563
|
+
var selector = arguments[0]
|
564
|
+
, expectedArgs = arguments[1]
|
565
|
+
, wasTriggered = jasmine.jQuery.events.wasTriggered(selector, this.actual)
|
566
|
+
|
567
|
+
this.message = function () {
|
568
|
+
if (wasTriggered) {
|
569
|
+
var actualArgs = jasmine.jQuery.events.args(selector, this.actual, expectedArgs)[1]
|
570
|
+
return [
|
571
|
+
"Expected event " + this.actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs),
|
572
|
+
"Expected event " + this.actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs)
|
573
|
+
]
|
574
|
+
} else {
|
575
|
+
return [
|
576
|
+
"Expected event " + this.actual + " to have been triggered on " + selector,
|
577
|
+
"Expected event " + this.actual + " not to have been triggered on " + selector
|
578
|
+
]
|
579
|
+
}
|
580
|
+
}
|
581
|
+
|
582
|
+
return wasTriggered && jasmine.jQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env)
|
583
|
+
}
|
584
|
+
})
|
585
|
+
|
586
|
+
this.addMatchers({
|
587
|
+
toHaveBeenPreventedOn: function (selector) {
|
588
|
+
this.message = function () {
|
589
|
+
return [
|
590
|
+
"Expected event " + this.actual + " to have been prevented on " + selector,
|
591
|
+
"Expected event " + this.actual + " not to have been prevented on " + selector
|
592
|
+
]
|
593
|
+
}
|
594
|
+
|
595
|
+
return jasmine.jQuery.events.wasPrevented(selector, this.actual)
|
596
|
+
}
|
597
|
+
})
|
598
|
+
|
599
|
+
this.addMatchers({
|
600
|
+
toHaveBeenPrevented: function () {
|
601
|
+
var eventName = this.actual.eventName
|
602
|
+
, selector = this.actual.selector
|
603
|
+
this.message = function () {
|
604
|
+
return [
|
605
|
+
"Expected event " + eventName + " to have been prevented on " + selector,
|
606
|
+
"Expected event " + eventName + " not to have been prevented on " + selector
|
607
|
+
]
|
608
|
+
}
|
609
|
+
|
610
|
+
return jasmine.jQuery.events.wasPrevented(selector, eventName)
|
611
|
+
}
|
612
|
+
})
|
613
|
+
|
614
|
+
this.addMatchers({
|
615
|
+
toHaveBeenStoppedOn: function (selector) {
|
616
|
+
this.message = function () {
|
617
|
+
return [
|
618
|
+
"Expected event " + this.actual + " to have been stopped on " + selector,
|
619
|
+
"Expected event " + this.actual + " not to have been stopped on " + selector
|
620
|
+
]
|
621
|
+
}
|
622
|
+
|
623
|
+
return jasmine.jQuery.events.wasStopped(selector, this.actual)
|
624
|
+
}
|
625
|
+
})
|
626
|
+
|
627
|
+
this.addMatchers({
|
628
|
+
toHaveBeenStopped: function () {
|
629
|
+
var eventName = this.actual.eventName
|
630
|
+
, selector = this.actual.selector
|
631
|
+
this.message = function () {
|
632
|
+
return [
|
633
|
+
"Expected event " + eventName + " to have been stopped on " + selector,
|
634
|
+
"Expected event " + eventName + " not to have been stopped on " + selector
|
635
|
+
]
|
636
|
+
}
|
637
|
+
return jasmine.jQuery.events.wasStopped(selector, eventName)
|
638
|
+
}
|
639
|
+
})
|
640
|
+
|
641
|
+
jasmine.getEnv().addEqualityTester(function (a, b) {
|
642
|
+
if(a instanceof $ && b instanceof $) {
|
643
|
+
if(a.size() != b.size()) {
|
644
|
+
return jasmine.undefined
|
645
|
+
}
|
646
|
+
else if(a.is(b)) {
|
647
|
+
return true
|
648
|
+
}
|
649
|
+
}
|
650
|
+
|
651
|
+
return jasmine.undefined
|
652
|
+
})
|
653
|
+
})
|
654
|
+
|
655
|
+
afterEach(function () {
|
656
|
+
jasmine.getFixtures().cleanUp()
|
657
|
+
jasmine.getStyleFixtures().cleanUp()
|
658
|
+
jasmine.jQuery.events.cleanUp()
|
659
|
+
})
|
660
|
+
|
661
|
+
window.readFixtures = function () {
|
662
|
+
return jasmine.getFixtures().proxyCallTo_('read', arguments)
|
663
|
+
}
|
664
|
+
|
665
|
+
window.preloadFixtures = function () {
|
666
|
+
jasmine.getFixtures().proxyCallTo_('preload', arguments)
|
667
|
+
}
|
668
|
+
|
669
|
+
window.loadFixtures = function () {
|
670
|
+
jasmine.getFixtures().proxyCallTo_('load', arguments)
|
671
|
+
}
|
672
|
+
|
673
|
+
window.appendLoadFixtures = function () {
|
674
|
+
jasmine.getFixtures().proxyCallTo_('appendLoad', arguments)
|
675
|
+
}
|
676
|
+
|
677
|
+
window.setFixtures = function (html) {
|
678
|
+
return jasmine.getFixtures().proxyCallTo_('set', arguments)
|
679
|
+
}
|
680
|
+
|
681
|
+
window.appendSetFixtures = function () {
|
682
|
+
jasmine.getFixtures().proxyCallTo_('appendSet', arguments)
|
683
|
+
}
|
684
|
+
|
685
|
+
window.sandbox = function (attributes) {
|
686
|
+
return jasmine.getFixtures().sandbox(attributes)
|
687
|
+
}
|
688
|
+
|
689
|
+
window.spyOnEvent = function (selector, eventName) {
|
690
|
+
return jasmine.jQuery.events.spyOn(selector, eventName)
|
691
|
+
}
|
692
|
+
|
693
|
+
window.preloadStyleFixtures = function () {
|
694
|
+
jasmine.getStyleFixtures().proxyCallTo_('preload', arguments)
|
695
|
+
}
|
696
|
+
|
697
|
+
window.loadStyleFixtures = function () {
|
698
|
+
jasmine.getStyleFixtures().proxyCallTo_('load', arguments)
|
699
|
+
}
|
700
|
+
|
701
|
+
window.appendLoadStyleFixtures = function () {
|
702
|
+
jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments)
|
703
|
+
}
|
704
|
+
|
705
|
+
window.setStyleFixtures = function (html) {
|
706
|
+
jasmine.getStyleFixtures().proxyCallTo_('set', arguments)
|
707
|
+
}
|
708
|
+
|
709
|
+
window.appendSetStyleFixtures = function (html) {
|
710
|
+
jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments)
|
711
|
+
}
|
712
|
+
|
713
|
+
window.loadJSONFixtures = function () {
|
714
|
+
return jasmine.getJSONFixtures().proxyCallTo_('load', arguments)
|
715
|
+
}
|
716
|
+
|
717
|
+
window.getJSONFixture = function (url) {
|
718
|
+
return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url]
|
719
|
+
}
|
720
|
+
}(window, window.jasmine, window.jQuery);
|