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
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2010, 2011, 2012 Wojciech Zawistowski, Travis Jeffery
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,659 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
Jasmine-jQuery: a set of jQuery helpers for Jasmine tests.
|
3
|
-
|
4
|
-
Version 1.5.2
|
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
|
-
var readFixtures = function() {
|
30
|
-
return jasmine.getFixtures().proxyCallTo_('read', arguments)
|
31
|
-
}
|
32
|
-
|
33
|
-
var preloadFixtures = function() {
|
34
|
-
jasmine.getFixtures().proxyCallTo_('preload', arguments)
|
35
|
-
}
|
36
|
-
|
37
|
-
var loadFixtures = function() {
|
38
|
-
jasmine.getFixtures().proxyCallTo_('load', arguments)
|
39
|
-
}
|
40
|
-
|
41
|
-
var appendLoadFixtures = function() {
|
42
|
-
jasmine.getFixtures().proxyCallTo_('appendLoad', arguments)
|
43
|
-
}
|
44
|
-
|
45
|
-
var setFixtures = function(html) {
|
46
|
-
jasmine.getFixtures().proxyCallTo_('set', arguments)
|
47
|
-
}
|
48
|
-
|
49
|
-
var appendSetFixtures = function() {
|
50
|
-
jasmine.getFixtures().proxyCallTo_('appendSet', arguments)
|
51
|
-
}
|
52
|
-
|
53
|
-
var sandbox = function(attributes) {
|
54
|
-
return jasmine.getFixtures().sandbox(attributes)
|
55
|
-
}
|
56
|
-
|
57
|
-
var spyOnEvent = function(selector, eventName) {
|
58
|
-
return jasmine.JQuery.events.spyOn(selector, eventName)
|
59
|
-
}
|
60
|
-
|
61
|
-
var preloadStyleFixtures = function() {
|
62
|
-
jasmine.getStyleFixtures().proxyCallTo_('preload', arguments)
|
63
|
-
}
|
64
|
-
|
65
|
-
var loadStyleFixtures = function() {
|
66
|
-
jasmine.getStyleFixtures().proxyCallTo_('load', arguments)
|
67
|
-
}
|
68
|
-
|
69
|
-
var appendLoadStyleFixtures = function() {
|
70
|
-
jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments)
|
71
|
-
}
|
72
|
-
|
73
|
-
var setStyleFixtures = function(html) {
|
74
|
-
jasmine.getStyleFixtures().proxyCallTo_('set', arguments)
|
75
|
-
}
|
76
|
-
|
77
|
-
var appendSetStyleFixtures = function(html) {
|
78
|
-
jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments)
|
79
|
-
}
|
80
|
-
|
81
|
-
var loadJSONFixtures = function() {
|
82
|
-
return jasmine.getJSONFixtures().proxyCallTo_('load', arguments)
|
83
|
-
}
|
84
|
-
|
85
|
-
var getJSONFixture = function(url) {
|
86
|
-
return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url]
|
87
|
-
}
|
88
|
-
|
89
|
-
jasmine.spiedEventsKey = function (selector, eventName) {
|
90
|
-
return [$(selector).selector, eventName].toString()
|
91
|
-
}
|
92
|
-
|
93
|
-
jasmine.getFixtures = function() {
|
94
|
-
return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures()
|
95
|
-
}
|
96
|
-
|
97
|
-
jasmine.getStyleFixtures = function() {
|
98
|
-
return jasmine.currentStyleFixtures_ = jasmine.currentStyleFixtures_ || new jasmine.StyleFixtures()
|
99
|
-
}
|
100
|
-
|
101
|
-
jasmine.Fixtures = function() {
|
102
|
-
this.containerId = 'jasmine-fixtures'
|
103
|
-
this.fixturesCache_ = {}
|
104
|
-
this.fixturesPath = 'spec/javascripts/fixtures'
|
105
|
-
}
|
106
|
-
|
107
|
-
jasmine.Fixtures.prototype.set = function(html) {
|
108
|
-
this.cleanUp()
|
109
|
-
this.createContainer_(html)
|
110
|
-
}
|
111
|
-
|
112
|
-
jasmine.Fixtures.prototype.appendSet= function(html) {
|
113
|
-
this.addToContainer_(html)
|
114
|
-
}
|
115
|
-
|
116
|
-
jasmine.Fixtures.prototype.preload = function() {
|
117
|
-
this.read.apply(this, arguments)
|
118
|
-
}
|
119
|
-
|
120
|
-
jasmine.Fixtures.prototype.load = function() {
|
121
|
-
this.cleanUp()
|
122
|
-
this.createContainer_(this.read.apply(this, arguments))
|
123
|
-
}
|
124
|
-
|
125
|
-
jasmine.Fixtures.prototype.appendLoad = function() {
|
126
|
-
this.addToContainer_(this.read.apply(this, arguments))
|
127
|
-
}
|
128
|
-
|
129
|
-
jasmine.Fixtures.prototype.read = function() {
|
130
|
-
var htmlChunks = []
|
131
|
-
|
132
|
-
var fixtureUrls = arguments
|
133
|
-
for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
|
134
|
-
htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex]))
|
135
|
-
}
|
136
|
-
|
137
|
-
return htmlChunks.join('')
|
138
|
-
}
|
139
|
-
|
140
|
-
jasmine.Fixtures.prototype.clearCache = function() {
|
141
|
-
this.fixturesCache_ = {}
|
142
|
-
}
|
143
|
-
|
144
|
-
jasmine.Fixtures.prototype.cleanUp = function() {
|
145
|
-
$('#' + this.containerId).remove()
|
146
|
-
}
|
147
|
-
|
148
|
-
jasmine.Fixtures.prototype.sandbox = function(attributes) {
|
149
|
-
var attributesToSet = attributes || {}
|
150
|
-
return $('<div id="sandbox" />').attr(attributesToSet)
|
151
|
-
}
|
152
|
-
|
153
|
-
jasmine.Fixtures.prototype.createContainer_ = function(html) {
|
154
|
-
var container
|
155
|
-
if(html instanceof $) {
|
156
|
-
container = $('<div id="' + this.containerId + '" />')
|
157
|
-
container.html(html)
|
158
|
-
} else {
|
159
|
-
container = '<div id="' + this.containerId + '">' + html + '</div>'
|
160
|
-
}
|
161
|
-
$(document.body).append(container)
|
162
|
-
}
|
163
|
-
|
164
|
-
jasmine.Fixtures.prototype.addToContainer_ = function(html){
|
165
|
-
var container = $(document.body).find('#'+this.containerId).append(html)
|
166
|
-
if(!container.length){
|
167
|
-
this.createContainer_(html)
|
168
|
-
}
|
169
|
-
}
|
170
|
-
|
171
|
-
jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) {
|
172
|
-
if (typeof this.fixturesCache_[url] === 'undefined') {
|
173
|
-
this.loadFixtureIntoCache_(url)
|
174
|
-
}
|
175
|
-
return this.fixturesCache_[url]
|
176
|
-
}
|
177
|
-
|
178
|
-
jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
|
179
|
-
var url = this.makeFixtureUrl_(relativeUrl)
|
180
|
-
var request = $.ajax({
|
181
|
-
type: "GET",
|
182
|
-
url: url + "?" + new Date().getTime(),
|
183
|
-
async: false
|
184
|
-
})
|
185
|
-
this.fixturesCache_[relativeUrl] = request.responseText
|
186
|
-
}
|
187
|
-
|
188
|
-
jasmine.Fixtures.prototype.makeFixtureUrl_ = function(relativeUrl){
|
189
|
-
return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
|
190
|
-
}
|
191
|
-
|
192
|
-
jasmine.Fixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) {
|
193
|
-
return this[methodName].apply(this, passedArguments)
|
194
|
-
}
|
195
|
-
|
196
|
-
|
197
|
-
jasmine.StyleFixtures = function() {
|
198
|
-
this.fixturesCache_ = {}
|
199
|
-
this.fixturesNodes_ = []
|
200
|
-
this.fixturesPath = 'spec/javascripts/fixtures'
|
201
|
-
}
|
202
|
-
|
203
|
-
jasmine.StyleFixtures.prototype.set = function(css) {
|
204
|
-
this.cleanUp()
|
205
|
-
this.createStyle_(css)
|
206
|
-
}
|
207
|
-
|
208
|
-
jasmine.StyleFixtures.prototype.appendSet = function(css) {
|
209
|
-
this.createStyle_(css)
|
210
|
-
}
|
211
|
-
|
212
|
-
jasmine.StyleFixtures.prototype.preload = function() {
|
213
|
-
this.read_.apply(this, arguments)
|
214
|
-
}
|
215
|
-
|
216
|
-
jasmine.StyleFixtures.prototype.load = function() {
|
217
|
-
this.cleanUp()
|
218
|
-
this.createStyle_(this.read_.apply(this, arguments))
|
219
|
-
}
|
220
|
-
|
221
|
-
jasmine.StyleFixtures.prototype.appendLoad = function() {
|
222
|
-
this.createStyle_(this.read_.apply(this, arguments))
|
223
|
-
}
|
224
|
-
|
225
|
-
jasmine.StyleFixtures.prototype.cleanUp = function() {
|
226
|
-
while(this.fixturesNodes_.length) {
|
227
|
-
this.fixturesNodes_.pop().remove()
|
228
|
-
}
|
229
|
-
}
|
230
|
-
|
231
|
-
jasmine.StyleFixtures.prototype.createStyle_ = function(html) {
|
232
|
-
var styleText = $('<div></div>').html(html).text(),
|
233
|
-
style = $('<style>' + styleText + '</style>')
|
234
|
-
|
235
|
-
this.fixturesNodes_.push(style)
|
236
|
-
|
237
|
-
$('head').append(style)
|
238
|
-
}
|
239
|
-
|
240
|
-
jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache
|
241
|
-
|
242
|
-
jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read
|
243
|
-
|
244
|
-
jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_
|
245
|
-
|
246
|
-
jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_
|
247
|
-
|
248
|
-
jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_
|
249
|
-
|
250
|
-
jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_
|
251
|
-
|
252
|
-
jasmine.getJSONFixtures = function() {
|
253
|
-
return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures()
|
254
|
-
}
|
255
|
-
|
256
|
-
jasmine.JSONFixtures = function() {
|
257
|
-
this.fixturesCache_ = {}
|
258
|
-
this.fixturesPath = 'spec/javascripts/fixtures/json'
|
259
|
-
}
|
260
|
-
|
261
|
-
jasmine.JSONFixtures.prototype.load = function() {
|
262
|
-
this.read.apply(this, arguments)
|
263
|
-
return this.fixturesCache_
|
264
|
-
}
|
265
|
-
|
266
|
-
jasmine.JSONFixtures.prototype.read = function() {
|
267
|
-
var fixtureUrls = arguments
|
268
|
-
for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
|
269
|
-
this.getFixtureData_(fixtureUrls[urlIndex])
|
270
|
-
}
|
271
|
-
return this.fixturesCache_
|
272
|
-
}
|
273
|
-
|
274
|
-
jasmine.JSONFixtures.prototype.clearCache = function() {
|
275
|
-
this.fixturesCache_ = {}
|
276
|
-
}
|
277
|
-
|
278
|
-
jasmine.JSONFixtures.prototype.getFixtureData_ = function(url) {
|
279
|
-
this.loadFixtureIntoCache_(url)
|
280
|
-
return this.fixturesCache_[url]
|
281
|
-
}
|
282
|
-
|
283
|
-
jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
|
284
|
-
var self = this
|
285
|
-
var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
|
286
|
-
$.ajax({
|
287
|
-
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
|
288
|
-
cache: false,
|
289
|
-
dataType: 'json',
|
290
|
-
url: url,
|
291
|
-
success: function(data) {
|
292
|
-
self.fixturesCache_[relativeUrl] = data
|
293
|
-
},
|
294
|
-
error: function(jqXHR, status, errorThrown) {
|
295
|
-
throw Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')')
|
296
|
-
}
|
297
|
-
})
|
298
|
-
}
|
299
|
-
|
300
|
-
jasmine.JSONFixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) {
|
301
|
-
return this[methodName].apply(this, passedArguments)
|
302
|
-
}
|
303
|
-
|
304
|
-
jasmine.JQuery = function() {}
|
305
|
-
|
306
|
-
jasmine.JQuery.browserTagCaseIndependentHtml = function(html) {
|
307
|
-
return $('<div/>').append(html).html()
|
308
|
-
}
|
309
|
-
|
310
|
-
jasmine.JQuery.elementToString = function(element) {
|
311
|
-
var domEl = $(element).get(0)
|
312
|
-
if (domEl == undefined || domEl.cloneNode)
|
313
|
-
return $('<div />').append($(element).clone()).html()
|
314
|
-
else
|
315
|
-
return element.toString()
|
316
|
-
}
|
317
|
-
|
318
|
-
jasmine.JQuery.matchersClass = {}
|
319
|
-
|
320
|
-
!function(namespace) {
|
321
|
-
var data = {
|
322
|
-
spiedEvents: {},
|
323
|
-
handlers: []
|
324
|
-
}
|
325
|
-
|
326
|
-
namespace.events = {
|
327
|
-
spyOn: function(selector, eventName) {
|
328
|
-
var handler = function(e) {
|
329
|
-
data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments)
|
330
|
-
}
|
331
|
-
$(selector).on(eventName, handler)
|
332
|
-
data.handlers.push(handler)
|
333
|
-
return {
|
334
|
-
selector: selector,
|
335
|
-
eventName: eventName,
|
336
|
-
handler: handler,
|
337
|
-
reset: function(){
|
338
|
-
delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
|
339
|
-
}
|
340
|
-
}
|
341
|
-
},
|
342
|
-
|
343
|
-
args: function(selector, eventName) {
|
344
|
-
var actualArgs = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)];
|
345
|
-
|
346
|
-
if (!actualArgs) {
|
347
|
-
throw "There is no spy for " + eventName + " on " + selector.toString() + ". Make sure to create a spy using spyOnEvent.";
|
348
|
-
}
|
349
|
-
|
350
|
-
return actualArgs;
|
351
|
-
},
|
352
|
-
|
353
|
-
wasTriggered: function(selector, eventName) {
|
354
|
-
return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)])
|
355
|
-
},
|
356
|
-
|
357
|
-
wasTriggeredWith: function(selector, eventName, expectedArgs, env) {
|
358
|
-
var actualArgs = jasmine.JQuery.events.args(selector, eventName).slice(1);
|
359
|
-
if (Object.prototype.toString.call(expectedArgs) !== '[object Array]') {
|
360
|
-
actualArgs = actualArgs[0];
|
361
|
-
}
|
362
|
-
return env.equals_(expectedArgs, actualArgs);
|
363
|
-
},
|
364
|
-
|
365
|
-
wasPrevented: function(selector, eventName) {
|
366
|
-
var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)],
|
367
|
-
e = args ? args[0] : undefined;
|
368
|
-
return e && e.isDefaultPrevented()
|
369
|
-
},
|
370
|
-
|
371
|
-
wasStopped: function(selector, eventName) {
|
372
|
-
var args = data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)],
|
373
|
-
e = args ? args[0] : undefined;
|
374
|
-
return e && e.isPropagationStopped()
|
375
|
-
},
|
376
|
-
|
377
|
-
cleanUp: function() {
|
378
|
-
data.spiedEvents = {}
|
379
|
-
data.handlers = []
|
380
|
-
}
|
381
|
-
}
|
382
|
-
}(jasmine.JQuery)
|
383
|
-
|
384
|
-
!function(){
|
385
|
-
var jQueryMatchers = {
|
386
|
-
toHaveClass: function(className) {
|
387
|
-
return this.actual.hasClass(className)
|
388
|
-
},
|
389
|
-
|
390
|
-
toHaveCss: function(css){
|
391
|
-
for (var prop in css){
|
392
|
-
if (this.actual.css(prop) !== css[prop]) return false
|
393
|
-
}
|
394
|
-
return true
|
395
|
-
},
|
396
|
-
|
397
|
-
toBeVisible: function() {
|
398
|
-
return this.actual.is(':visible')
|
399
|
-
},
|
400
|
-
|
401
|
-
toBeHidden: function() {
|
402
|
-
return this.actual.is(':hidden')
|
403
|
-
},
|
404
|
-
|
405
|
-
toBeSelected: function() {
|
406
|
-
return this.actual.is(':selected')
|
407
|
-
},
|
408
|
-
|
409
|
-
toBeChecked: function() {
|
410
|
-
return this.actual.is(':checked')
|
411
|
-
},
|
412
|
-
|
413
|
-
toBeEmpty: function() {
|
414
|
-
return this.actual.is(':empty')
|
415
|
-
},
|
416
|
-
|
417
|
-
toExist: function() {
|
418
|
-
return $(document).find(this.actual).length
|
419
|
-
},
|
420
|
-
|
421
|
-
toHaveLength: function(length) {
|
422
|
-
return this.actual.length === length
|
423
|
-
},
|
424
|
-
|
425
|
-
toHaveAttr: function(attributeName, expectedAttributeValue) {
|
426
|
-
return hasProperty(this.actual.attr(attributeName), expectedAttributeValue)
|
427
|
-
},
|
428
|
-
|
429
|
-
toHaveProp: function(propertyName, expectedPropertyValue) {
|
430
|
-
return hasProperty(this.actual.prop(propertyName), expectedPropertyValue)
|
431
|
-
},
|
432
|
-
|
433
|
-
toHaveId: function(id) {
|
434
|
-
return this.actual.attr('id') == id
|
435
|
-
},
|
436
|
-
|
437
|
-
toHaveHtml: function(html) {
|
438
|
-
return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html)
|
439
|
-
},
|
440
|
-
|
441
|
-
toContainHtml: function(html){
|
442
|
-
var actualHtml = this.actual.html()
|
443
|
-
var expectedHtml = jasmine.JQuery.browserTagCaseIndependentHtml(html)
|
444
|
-
return (actualHtml.indexOf(expectedHtml) >= 0)
|
445
|
-
},
|
446
|
-
|
447
|
-
toHaveText: function(text) {
|
448
|
-
var trimmedText = $.trim(this.actual.text())
|
449
|
-
if (text && $.isFunction(text.test)) {
|
450
|
-
return text.test(trimmedText)
|
451
|
-
} else {
|
452
|
-
return trimmedText == text
|
453
|
-
}
|
454
|
-
},
|
455
|
-
|
456
|
-
toContainText: function(text) {
|
457
|
-
var trimmedText = $.trim(this.actual.text())
|
458
|
-
if (text && $.isFunction(text.test)) {
|
459
|
-
return text.test(trimmedText)
|
460
|
-
} else {
|
461
|
-
return trimmedText.indexOf(text) != -1;
|
462
|
-
}
|
463
|
-
},
|
464
|
-
|
465
|
-
toHaveValue: function(value) {
|
466
|
-
return this.actual.val() === value
|
467
|
-
},
|
468
|
-
|
469
|
-
toHaveData: function(key, expectedValue) {
|
470
|
-
return hasProperty(this.actual.data(key), expectedValue)
|
471
|
-
},
|
472
|
-
|
473
|
-
toBe: function(selector) {
|
474
|
-
return this.actual.is(selector)
|
475
|
-
},
|
476
|
-
|
477
|
-
toContain: function(selector) {
|
478
|
-
return this.actual.find(selector).length
|
479
|
-
},
|
480
|
-
|
481
|
-
toBeDisabled: function(selector){
|
482
|
-
return this.actual.is(':disabled')
|
483
|
-
},
|
484
|
-
|
485
|
-
toBeFocused: function(selector) {
|
486
|
-
return this.actual[0] === this.actual[0].ownerDocument.activeElement
|
487
|
-
},
|
488
|
-
|
489
|
-
toHandle: function(event) {
|
490
|
-
|
491
|
-
var events = $._data(this.actual.get(0), "events")
|
492
|
-
|
493
|
-
if(!events || !event || typeof event !== "string") {
|
494
|
-
return false
|
495
|
-
}
|
496
|
-
|
497
|
-
var namespaces = event.split(".")
|
498
|
-
var eventType = namespaces.shift()
|
499
|
-
var sortedNamespaces = namespaces.slice(0).sort()
|
500
|
-
var namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)")
|
501
|
-
|
502
|
-
if(events[eventType] && namespaces.length) {
|
503
|
-
for(var i = 0; i < events[eventType].length; i++) {
|
504
|
-
var namespace = events[eventType][i].namespace
|
505
|
-
if(namespaceRegExp.test(namespace)) {
|
506
|
-
return true
|
507
|
-
}
|
508
|
-
}
|
509
|
-
} else {
|
510
|
-
return events[eventType] && events[eventType].length > 0
|
511
|
-
}
|
512
|
-
},
|
513
|
-
|
514
|
-
// tests the existence of a specific event binding + handler
|
515
|
-
toHandleWith: function(eventName, eventHandler) {
|
516
|
-
var stack = $._data(this.actual.get(0), "events")[eventName]
|
517
|
-
for (var i = 0; i < stack.length; i++) {
|
518
|
-
if (stack[i].handler == eventHandler) return true
|
519
|
-
}
|
520
|
-
return false
|
521
|
-
}
|
522
|
-
}
|
523
|
-
|
524
|
-
var hasProperty = function(actualValue, expectedValue) {
|
525
|
-
if (expectedValue === undefined) return actualValue !== undefined
|
526
|
-
return actualValue == expectedValue
|
527
|
-
}
|
528
|
-
|
529
|
-
var bindMatcher = function(methodName) {
|
530
|
-
var builtInMatcher = jasmine.Matchers.prototype[methodName]
|
531
|
-
|
532
|
-
jasmine.JQuery.matchersClass[methodName] = function() {
|
533
|
-
if (this.actual
|
534
|
-
&& (this.actual instanceof $
|
535
|
-
|| jasmine.isDomNode(this.actual))) {
|
536
|
-
this.actual = $(this.actual)
|
537
|
-
var result = jQueryMatchers[methodName].apply(this, arguments)
|
538
|
-
var element
|
539
|
-
if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML")
|
540
|
-
this.actual = jasmine.JQuery.elementToString(this.actual)
|
541
|
-
return result
|
542
|
-
}
|
543
|
-
|
544
|
-
if (builtInMatcher) {
|
545
|
-
return builtInMatcher.apply(this, arguments)
|
546
|
-
}
|
547
|
-
|
548
|
-
return false
|
549
|
-
}
|
550
|
-
}
|
551
|
-
|
552
|
-
for(var methodName in jQueryMatchers) {
|
553
|
-
bindMatcher(methodName)
|
554
|
-
}
|
555
|
-
}()
|
556
|
-
|
557
|
-
beforeEach(function() {
|
558
|
-
this.addMatchers(jasmine.JQuery.matchersClass)
|
559
|
-
this.addMatchers({
|
560
|
-
toHaveBeenTriggeredOn: function(selector) {
|
561
|
-
this.message = function() {
|
562
|
-
return [
|
563
|
-
"Expected event " + this.actual + " to have been triggered on " + selector,
|
564
|
-
"Expected event " + this.actual + " not to have been triggered on " + selector
|
565
|
-
]
|
566
|
-
}
|
567
|
-
return jasmine.JQuery.events.wasTriggered(selector, this.actual)
|
568
|
-
}
|
569
|
-
})
|
570
|
-
this.addMatchers({
|
571
|
-
toHaveBeenTriggered: function(){
|
572
|
-
var eventName = this.actual.eventName,
|
573
|
-
selector = this.actual.selector
|
574
|
-
this.message = function() {
|
575
|
-
return [
|
576
|
-
"Expected event " + eventName + " to have been triggered on " + selector,
|
577
|
-
"Expected event " + eventName + " not to have been triggered on " + selector
|
578
|
-
]
|
579
|
-
}
|
580
|
-
return jasmine.JQuery.events.wasTriggered(selector, eventName)
|
581
|
-
}
|
582
|
-
})
|
583
|
-
this.addMatchers({
|
584
|
-
toHaveBeenTriggeredOnAndWith: function() {
|
585
|
-
var selector = arguments[0],
|
586
|
-
expectedArgs = arguments[1],
|
587
|
-
wasTriggered = jasmine.JQuery.events.wasTriggered(selector, this.actual);
|
588
|
-
this.message = function() {
|
589
|
-
if (wasTriggered) {
|
590
|
-
var actualArgs = jasmine.JQuery.events.args(selector, this.actual, expectedArgs)[1];
|
591
|
-
return [
|
592
|
-
"Expected event " + this.actual + " to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs),
|
593
|
-
"Expected event " + this.actual + " not to have been triggered with " + jasmine.pp(expectedArgs) + " but it was triggered with " + jasmine.pp(actualArgs)
|
594
|
-
]
|
595
|
-
} else {
|
596
|
-
return [
|
597
|
-
"Expected event " + this.actual + " to have been triggered on " + selector,
|
598
|
-
"Expected event " + this.actual + " not to have been triggered on " + selector
|
599
|
-
]
|
600
|
-
}
|
601
|
-
}
|
602
|
-
return wasTriggered && jasmine.JQuery.events.wasTriggeredWith(selector, this.actual, expectedArgs, this.env);
|
603
|
-
}
|
604
|
-
})
|
605
|
-
this.addMatchers({
|
606
|
-
toHaveBeenPreventedOn: function(selector) {
|
607
|
-
this.message = function() {
|
608
|
-
return [
|
609
|
-
"Expected event " + this.actual + " to have been prevented on " + selector,
|
610
|
-
"Expected event " + this.actual + " not to have been prevented on " + selector
|
611
|
-
]
|
612
|
-
}
|
613
|
-
return jasmine.JQuery.events.wasPrevented(selector, this.actual)
|
614
|
-
}
|
615
|
-
})
|
616
|
-
this.addMatchers({
|
617
|
-
toHaveBeenPrevented: function() {
|
618
|
-
var eventName = this.actual.eventName,
|
619
|
-
selector = this.actual.selector
|
620
|
-
this.message = function() {
|
621
|
-
return [
|
622
|
-
"Expected event " + eventName + " to have been prevented on " + selector,
|
623
|
-
"Expected event " + eventName + " not to have been prevented on " + selector
|
624
|
-
]
|
625
|
-
}
|
626
|
-
return jasmine.JQuery.events.wasPrevented(selector, eventName)
|
627
|
-
}
|
628
|
-
})
|
629
|
-
this.addMatchers({
|
630
|
-
toHaveBeenStoppedOn: function(selector) {
|
631
|
-
this.message = function() {
|
632
|
-
return [
|
633
|
-
"Expected event " + this.actual + " to have been stopped on " + selector,
|
634
|
-
"Expected event " + this.actual + " not to have been stopped on " + selector
|
635
|
-
]
|
636
|
-
}
|
637
|
-
return jasmine.JQuery.events.wasStopped(selector, this.actual)
|
638
|
-
}
|
639
|
-
})
|
640
|
-
this.addMatchers({
|
641
|
-
toHaveBeenStopped: function() {
|
642
|
-
var eventName = this.actual.eventName,
|
643
|
-
selector = this.actual.selector
|
644
|
-
this.message = function() {
|
645
|
-
return [
|
646
|
-
"Expected event " + eventName + " to have been stopped on " + selector,
|
647
|
-
"Expected event " + eventName + " not to have been stopped on " + selector
|
648
|
-
]
|
649
|
-
}
|
650
|
-
return jasmine.JQuery.events.wasStopped(selector, eventName)
|
651
|
-
}
|
652
|
-
})
|
653
|
-
})
|
654
|
-
|
655
|
-
afterEach(function() {
|
656
|
-
jasmine.getFixtures().cleanUp()
|
657
|
-
jasmine.getStyleFixtures().cleanUp()
|
658
|
-
jasmine.JQuery.events.cleanUp()
|
659
|
-
})
|