jasmine-jquery-rails 1.3.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/jasmine-jquery-rails/version.rb +1 -1
- data/vendor/assets/javascripts/jasmine-jquery.js +383 -142
- metadata +9 -3
@@ -1,306 +1,547 @@
|
|
1
1
|
var readFixtures = function() {
|
2
|
-
return jasmine.getFixtures().proxyCallTo_('read', arguments)
|
3
|
-
}
|
2
|
+
return jasmine.getFixtures().proxyCallTo_('read', arguments)
|
3
|
+
}
|
4
4
|
|
5
5
|
var preloadFixtures = function() {
|
6
|
-
jasmine.getFixtures().proxyCallTo_('preload', arguments)
|
7
|
-
}
|
6
|
+
jasmine.getFixtures().proxyCallTo_('preload', arguments)
|
7
|
+
}
|
8
8
|
|
9
9
|
var loadFixtures = function() {
|
10
|
-
jasmine.getFixtures().proxyCallTo_('load', arguments)
|
11
|
-
}
|
10
|
+
jasmine.getFixtures().proxyCallTo_('load', arguments)
|
11
|
+
}
|
12
|
+
|
13
|
+
var appendLoadFixtures = function() {
|
14
|
+
jasmine.getFixtures().proxyCallTo_('appendLoad', arguments)
|
15
|
+
}
|
12
16
|
|
13
17
|
var setFixtures = function(html) {
|
14
|
-
jasmine.getFixtures().set
|
15
|
-
}
|
18
|
+
jasmine.getFixtures().proxyCallTo_('set', arguments)
|
19
|
+
}
|
20
|
+
|
21
|
+
var appendSetFixtures = function() {
|
22
|
+
jasmine.getFixtures().proxyCallTo_('appendSet', arguments)
|
23
|
+
}
|
16
24
|
|
17
25
|
var sandbox = function(attributes) {
|
18
|
-
return jasmine.getFixtures().sandbox(attributes)
|
19
|
-
}
|
26
|
+
return jasmine.getFixtures().sandbox(attributes)
|
27
|
+
}
|
20
28
|
|
21
29
|
var spyOnEvent = function(selector, eventName) {
|
22
|
-
jasmine.JQuery.events.spyOn(selector, eventName)
|
23
|
-
}
|
30
|
+
return jasmine.JQuery.events.spyOn(selector, eventName)
|
31
|
+
}
|
32
|
+
|
33
|
+
var preloadStyleFixtures = function() {
|
34
|
+
jasmine.getStyleFixtures().proxyCallTo_('preload', arguments)
|
35
|
+
}
|
36
|
+
|
37
|
+
var loadStyleFixtures = function() {
|
38
|
+
jasmine.getStyleFixtures().proxyCallTo_('load', arguments)
|
39
|
+
}
|
40
|
+
|
41
|
+
var appendLoadStyleFixtures = function() {
|
42
|
+
jasmine.getStyleFixtures().proxyCallTo_('appendLoad', arguments)
|
43
|
+
}
|
44
|
+
|
45
|
+
var setStyleFixtures = function(html) {
|
46
|
+
jasmine.getStyleFixtures().proxyCallTo_('set', arguments)
|
47
|
+
}
|
48
|
+
|
49
|
+
var appendSetStyleFixtures = function(html) {
|
50
|
+
jasmine.getStyleFixtures().proxyCallTo_('appendSet', arguments)
|
51
|
+
}
|
52
|
+
|
53
|
+
var loadJSONFixtures = function() {
|
54
|
+
return jasmine.getJSONFixtures().proxyCallTo_('load', arguments)
|
55
|
+
}
|
56
|
+
|
57
|
+
var getJSONFixture = function(url) {
|
58
|
+
return jasmine.getJSONFixtures().proxyCallTo_('read', arguments)[url]
|
59
|
+
}
|
60
|
+
|
61
|
+
jasmine.spiedEventsKey = function (selector, eventName) {
|
62
|
+
return [$(selector).selector, eventName].toString()
|
63
|
+
}
|
24
64
|
|
25
65
|
jasmine.getFixtures = function() {
|
26
|
-
return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures()
|
27
|
-
}
|
66
|
+
return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures()
|
67
|
+
}
|
68
|
+
|
69
|
+
jasmine.getStyleFixtures = function() {
|
70
|
+
return jasmine.currentStyleFixtures_ = jasmine.currentStyleFixtures_ || new jasmine.StyleFixtures()
|
71
|
+
}
|
28
72
|
|
29
73
|
jasmine.Fixtures = function() {
|
30
|
-
this.containerId = 'jasmine-fixtures'
|
31
|
-
this.fixturesCache_ = {}
|
32
|
-
this.fixturesPath = 'spec/javascripts/fixtures'
|
33
|
-
}
|
74
|
+
this.containerId = 'jasmine-fixtures'
|
75
|
+
this.fixturesCache_ = {}
|
76
|
+
this.fixturesPath = 'spec/javascripts/fixtures'
|
77
|
+
}
|
34
78
|
|
35
79
|
jasmine.Fixtures.prototype.set = function(html) {
|
36
|
-
this.cleanUp()
|
37
|
-
this.createContainer_(html)
|
38
|
-
}
|
80
|
+
this.cleanUp()
|
81
|
+
this.createContainer_(html)
|
82
|
+
}
|
83
|
+
|
84
|
+
jasmine.Fixtures.prototype.appendSet= function(html) {
|
85
|
+
this.addToContainer_(html)
|
86
|
+
}
|
39
87
|
|
40
88
|
jasmine.Fixtures.prototype.preload = function() {
|
41
|
-
this.read.apply(this, arguments)
|
42
|
-
}
|
89
|
+
this.read.apply(this, arguments)
|
90
|
+
}
|
43
91
|
|
44
92
|
jasmine.Fixtures.prototype.load = function() {
|
45
|
-
this.cleanUp()
|
46
|
-
this.createContainer_(this.read.apply(this, arguments))
|
47
|
-
}
|
93
|
+
this.cleanUp()
|
94
|
+
this.createContainer_(this.read.apply(this, arguments))
|
95
|
+
}
|
96
|
+
|
97
|
+
jasmine.Fixtures.prototype.appendLoad = function() {
|
98
|
+
this.addToContainer_(this.read.apply(this, arguments))
|
99
|
+
}
|
48
100
|
|
49
101
|
jasmine.Fixtures.prototype.read = function() {
|
50
|
-
var htmlChunks = []
|
102
|
+
var htmlChunks = []
|
51
103
|
|
52
|
-
var fixtureUrls = arguments
|
104
|
+
var fixtureUrls = arguments
|
53
105
|
for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
|
54
|
-
htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex]))
|
106
|
+
htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex]))
|
55
107
|
}
|
56
108
|
|
57
|
-
return htmlChunks.join('')
|
58
|
-
}
|
109
|
+
return htmlChunks.join('')
|
110
|
+
}
|
59
111
|
|
60
112
|
jasmine.Fixtures.prototype.clearCache = function() {
|
61
|
-
this.fixturesCache_ = {}
|
62
|
-
}
|
113
|
+
this.fixturesCache_ = {}
|
114
|
+
}
|
63
115
|
|
64
116
|
jasmine.Fixtures.prototype.cleanUp = function() {
|
65
|
-
jQuery('#' + this.containerId).remove()
|
66
|
-
}
|
117
|
+
jQuery('#' + this.containerId).remove()
|
118
|
+
}
|
67
119
|
|
68
120
|
jasmine.Fixtures.prototype.sandbox = function(attributes) {
|
69
|
-
var attributesToSet = attributes || {}
|
70
|
-
return jQuery('<div id="sandbox" />').attr(attributesToSet)
|
71
|
-
}
|
121
|
+
var attributesToSet = attributes || {}
|
122
|
+
return jQuery('<div id="sandbox" />').attr(attributesToSet)
|
123
|
+
}
|
72
124
|
|
73
125
|
jasmine.Fixtures.prototype.createContainer_ = function(html) {
|
74
|
-
var container
|
126
|
+
var container
|
75
127
|
if(html instanceof jQuery) {
|
76
|
-
container = jQuery('<div id="' + this.containerId + '" />')
|
77
|
-
container.html(html)
|
128
|
+
container = jQuery('<div id="' + this.containerId + '" />')
|
129
|
+
container.html(html)
|
78
130
|
} else {
|
79
131
|
container = '<div id="' + this.containerId + '">' + html + '</div>'
|
80
132
|
}
|
81
|
-
jQuery('body').append(container)
|
82
|
-
}
|
133
|
+
jQuery('body').append(container)
|
134
|
+
}
|
135
|
+
|
136
|
+
jasmine.Fixtures.prototype.addToContainer_ = function(html){
|
137
|
+
var container = jQuery('body').find('#'+this.containerId).append(html)
|
138
|
+
if(!container.length){
|
139
|
+
this.createContainer_(html)
|
140
|
+
}
|
141
|
+
}
|
83
142
|
|
84
143
|
jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) {
|
85
|
-
if (typeof this.fixturesCache_[url]
|
86
|
-
this.loadFixtureIntoCache_(url)
|
144
|
+
if (typeof this.fixturesCache_[url] === 'undefined') {
|
145
|
+
this.loadFixtureIntoCache_(url)
|
87
146
|
}
|
88
|
-
return this.fixturesCache_[url]
|
89
|
-
}
|
147
|
+
return this.fixturesCache_[url]
|
148
|
+
}
|
90
149
|
|
91
150
|
jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
|
92
|
-
var url = this.
|
93
|
-
var request =
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
}
|
151
|
+
var url = this.makeFixtureUrl_(relativeUrl)
|
152
|
+
var request = jQuery.ajax({
|
153
|
+
type: "GET",
|
154
|
+
url: url + "?" + new Date().getTime(),
|
155
|
+
async: false
|
156
|
+
})
|
157
|
+
this.fixturesCache_[relativeUrl] = request.responseText
|
158
|
+
}
|
159
|
+
|
160
|
+
jasmine.Fixtures.prototype.makeFixtureUrl_ = function(relativeUrl){
|
161
|
+
return this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
|
162
|
+
}
|
98
163
|
|
99
164
|
jasmine.Fixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) {
|
100
|
-
return this[methodName].apply(this, passedArguments)
|
101
|
-
}
|
165
|
+
return this[methodName].apply(this, passedArguments)
|
166
|
+
}
|
167
|
+
|
168
|
+
|
169
|
+
jasmine.StyleFixtures = function() {
|
170
|
+
this.fixturesCache_ = {}
|
171
|
+
this.fixturesNodes_ = []
|
172
|
+
this.fixturesPath = 'spec/javascripts/fixtures'
|
173
|
+
}
|
174
|
+
|
175
|
+
jasmine.StyleFixtures.prototype.set = function(css) {
|
176
|
+
this.cleanUp()
|
177
|
+
this.createStyle_(css)
|
178
|
+
}
|
179
|
+
|
180
|
+
jasmine.StyleFixtures.prototype.appendSet = function(css) {
|
181
|
+
this.createStyle_(css)
|
182
|
+
}
|
183
|
+
|
184
|
+
jasmine.StyleFixtures.prototype.preload = function() {
|
185
|
+
this.read_.apply(this, arguments)
|
186
|
+
}
|
102
187
|
|
188
|
+
jasmine.StyleFixtures.prototype.load = function() {
|
189
|
+
this.cleanUp()
|
190
|
+
this.createStyle_(this.read_.apply(this, arguments))
|
191
|
+
}
|
103
192
|
|
104
|
-
jasmine.
|
193
|
+
jasmine.StyleFixtures.prototype.appendLoad = function() {
|
194
|
+
this.createStyle_(this.read_.apply(this, arguments))
|
195
|
+
}
|
196
|
+
|
197
|
+
jasmine.StyleFixtures.prototype.cleanUp = function() {
|
198
|
+
while(this.fixturesNodes_.length) {
|
199
|
+
this.fixturesNodes_.pop().remove()
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
jasmine.StyleFixtures.prototype.createStyle_ = function(html) {
|
204
|
+
var style = jQuery('<style></style>').text(html)
|
205
|
+
|
206
|
+
this.fixturesNodes_.push(style)
|
207
|
+
|
208
|
+
jQuery('head').append(style)
|
209
|
+
}
|
210
|
+
|
211
|
+
jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache
|
212
|
+
|
213
|
+
jasmine.StyleFixtures.prototype.read_ = jasmine.Fixtures.prototype.read
|
214
|
+
|
215
|
+
jasmine.StyleFixtures.prototype.getFixtureHtml_ = jasmine.Fixtures.prototype.getFixtureHtml_
|
216
|
+
|
217
|
+
jasmine.StyleFixtures.prototype.loadFixtureIntoCache_ = jasmine.Fixtures.prototype.loadFixtureIntoCache_
|
218
|
+
|
219
|
+
jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.makeFixtureUrl_
|
220
|
+
|
221
|
+
jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_
|
222
|
+
|
223
|
+
/** jasmine json fixtures */
|
224
|
+
|
225
|
+
jasmine.getJSONFixtures = function() {
|
226
|
+
return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures()
|
227
|
+
}
|
228
|
+
|
229
|
+
jasmine.JSONFixtures = function() {
|
230
|
+
this.fixturesCache_ = {}
|
231
|
+
this.fixturesPath = 'spec/javascripts/fixtures/json'
|
232
|
+
}
|
233
|
+
|
234
|
+
jasmine.JSONFixtures.prototype.load = function() {
|
235
|
+
this.read.apply(this, arguments)
|
236
|
+
return this.fixturesCache_
|
237
|
+
}
|
238
|
+
|
239
|
+
jasmine.JSONFixtures.prototype.read = function() {
|
240
|
+
var fixtureUrls = arguments
|
241
|
+
for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
|
242
|
+
this.getFixtureData_(fixtureUrls[urlIndex])
|
243
|
+
}
|
244
|
+
return this.fixturesCache_
|
245
|
+
}
|
246
|
+
|
247
|
+
jasmine.JSONFixtures.prototype.clearCache = function() {
|
248
|
+
this.fixturesCache_ = {}
|
249
|
+
}
|
250
|
+
|
251
|
+
jasmine.JSONFixtures.prototype.getFixtureData_ = function(url) {
|
252
|
+
this.loadFixtureIntoCache_(url)
|
253
|
+
return this.fixturesCache_[url]
|
254
|
+
}
|
255
|
+
|
256
|
+
jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
|
257
|
+
var self = this
|
258
|
+
var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
|
259
|
+
jQuery.ajax({
|
260
|
+
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
|
261
|
+
cache: false,
|
262
|
+
dataType: 'json',
|
263
|
+
url: url,
|
264
|
+
success: function(data) {
|
265
|
+
self.fixturesCache_[relativeUrl] = data
|
266
|
+
},
|
267
|
+
error: function(jqXHR, status, errorThrown) {
|
268
|
+
throw Error('JSONFixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')')
|
269
|
+
}
|
270
|
+
})
|
271
|
+
}
|
272
|
+
|
273
|
+
jasmine.JSONFixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) {
|
274
|
+
return this[methodName].apply(this, passedArguments)
|
275
|
+
}
|
276
|
+
|
277
|
+
jasmine.JQuery = function() {}
|
105
278
|
|
106
279
|
jasmine.JQuery.browserTagCaseIndependentHtml = function(html) {
|
107
|
-
return jQuery('<div/>').append(html).html()
|
108
|
-
}
|
280
|
+
return jQuery('<div/>').append(html).html()
|
281
|
+
}
|
109
282
|
|
110
283
|
jasmine.JQuery.elementToString = function(element) {
|
111
|
-
|
112
|
-
|
284
|
+
var domEl = $(element).get(0)
|
285
|
+
if (domEl == undefined || domEl.cloneNode)
|
286
|
+
return jQuery('<div />').append($(element).clone()).html()
|
287
|
+
else
|
288
|
+
return element.toString()
|
289
|
+
}
|
113
290
|
|
114
|
-
jasmine.JQuery.matchersClass = {}
|
291
|
+
jasmine.JQuery.matchersClass = {}
|
115
292
|
|
116
|
-
|
293
|
+
!function(namespace) {
|
117
294
|
var data = {
|
118
295
|
spiedEvents: {},
|
119
296
|
handlers: []
|
120
|
-
}
|
297
|
+
}
|
121
298
|
|
122
299
|
namespace.events = {
|
123
300
|
spyOn: function(selector, eventName) {
|
124
301
|
var handler = function(e) {
|
125
|
-
data.spiedEvents[
|
126
|
-
}
|
127
|
-
jQuery(selector).bind(eventName, handler)
|
128
|
-
data.handlers.push(handler)
|
302
|
+
data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = e
|
303
|
+
}
|
304
|
+
jQuery(selector).bind(eventName, handler)
|
305
|
+
data.handlers.push(handler)
|
306
|
+
return {
|
307
|
+
selector: selector,
|
308
|
+
eventName: eventName,
|
309
|
+
handler: handler,
|
310
|
+
reset: function(){
|
311
|
+
delete data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)]
|
312
|
+
}
|
313
|
+
}
|
129
314
|
},
|
130
315
|
|
131
316
|
wasTriggered: function(selector, eventName) {
|
132
|
-
return !!(data.spiedEvents[
|
317
|
+
return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)])
|
133
318
|
},
|
134
319
|
|
135
320
|
wasPrevented: function(selector, eventName) {
|
136
|
-
return data.spiedEvents[
|
321
|
+
return data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].isDefaultPrevented()
|
137
322
|
},
|
138
323
|
|
139
324
|
cleanUp: function() {
|
140
|
-
data.spiedEvents = {}
|
141
|
-
data.handlers = []
|
325
|
+
data.spiedEvents = {}
|
326
|
+
data.handlers = []
|
142
327
|
}
|
143
328
|
}
|
144
|
-
}
|
329
|
+
}(jasmine.JQuery)
|
145
330
|
|
146
|
-
|
331
|
+
!function(){
|
147
332
|
var jQueryMatchers = {
|
148
333
|
toHaveClass: function(className) {
|
149
|
-
return this.actual.hasClass(className)
|
334
|
+
return this.actual.hasClass(className)
|
335
|
+
},
|
336
|
+
|
337
|
+
toHaveCss: function(css){
|
338
|
+
for (var prop in css){
|
339
|
+
if (this.actual.css(prop) !== css[prop]) return false
|
340
|
+
}
|
341
|
+
return true
|
150
342
|
},
|
151
343
|
|
152
344
|
toBeVisible: function() {
|
153
|
-
return this.actual.is(':visible')
|
345
|
+
return this.actual.is(':visible')
|
154
346
|
},
|
155
347
|
|
156
348
|
toBeHidden: function() {
|
157
|
-
return this.actual.is(':hidden')
|
349
|
+
return this.actual.is(':hidden')
|
158
350
|
},
|
159
351
|
|
160
352
|
toBeSelected: function() {
|
161
|
-
return this.actual.is(':selected')
|
353
|
+
return this.actual.is(':selected')
|
162
354
|
},
|
163
355
|
|
164
356
|
toBeChecked: function() {
|
165
|
-
return this.actual.is(':checked')
|
357
|
+
return this.actual.is(':checked')
|
166
358
|
},
|
167
359
|
|
168
360
|
toBeEmpty: function() {
|
169
|
-
return this.actual.is(':empty')
|
361
|
+
return this.actual.is(':empty')
|
170
362
|
},
|
171
363
|
|
172
364
|
toExist: function() {
|
173
|
-
return this.actual.
|
365
|
+
return $(document).find(this.actual).length
|
174
366
|
},
|
175
367
|
|
176
368
|
toHaveAttr: function(attributeName, expectedAttributeValue) {
|
177
|
-
return hasProperty(this.actual.attr(attributeName), expectedAttributeValue)
|
369
|
+
return hasProperty(this.actual.attr(attributeName), expectedAttributeValue)
|
178
370
|
},
|
179
371
|
|
180
372
|
toHaveProp: function(propertyName, expectedPropertyValue) {
|
181
|
-
return hasProperty(this.actual.prop(propertyName), expectedPropertyValue)
|
373
|
+
return hasProperty(this.actual.prop(propertyName), expectedPropertyValue)
|
182
374
|
},
|
183
375
|
|
184
376
|
toHaveId: function(id) {
|
185
|
-
return this.actual.attr('id') == id
|
377
|
+
return this.actual.attr('id') == id
|
186
378
|
},
|
187
379
|
|
188
380
|
toHaveHtml: function(html) {
|
189
|
-
return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html)
|
381
|
+
return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html)
|
382
|
+
},
|
383
|
+
|
384
|
+
toContainHtml: function(html){
|
385
|
+
var actualHtml = this.actual.html()
|
386
|
+
var expectedHtml = jasmine.JQuery.browserTagCaseIndependentHtml(html)
|
387
|
+
return (actualHtml.indexOf(expectedHtml) >= 0)
|
190
388
|
},
|
191
389
|
|
192
390
|
toHaveText: function(text) {
|
193
|
-
var trimmedText = $.trim(this.actual.text())
|
391
|
+
var trimmedText = $.trim(this.actual.text())
|
194
392
|
if (text && jQuery.isFunction(text.test)) {
|
195
|
-
return text.test(trimmedText)
|
393
|
+
return text.test(trimmedText)
|
196
394
|
} else {
|
197
|
-
return trimmedText == text
|
395
|
+
return trimmedText == text
|
198
396
|
}
|
199
397
|
},
|
200
398
|
|
201
399
|
toHaveValue: function(value) {
|
202
|
-
return this.actual.val() == value
|
400
|
+
return this.actual.val() == value
|
203
401
|
},
|
204
402
|
|
205
403
|
toHaveData: function(key, expectedValue) {
|
206
|
-
return hasProperty(this.actual.data(key), expectedValue)
|
404
|
+
return hasProperty(this.actual.data(key), expectedValue)
|
207
405
|
},
|
208
406
|
|
209
407
|
toBe: function(selector) {
|
210
|
-
return this.actual.is(selector)
|
408
|
+
return this.actual.is(selector)
|
211
409
|
},
|
212
410
|
|
213
411
|
toContain: function(selector) {
|
214
|
-
return this.actual.find(selector).
|
412
|
+
return this.actual.find(selector).length
|
215
413
|
},
|
216
414
|
|
217
415
|
toBeDisabled: function(selector){
|
218
|
-
return this.actual.is(':disabled')
|
416
|
+
return this.actual.is(':disabled')
|
219
417
|
},
|
220
418
|
|
221
|
-
|
222
|
-
|
419
|
+
toBeFocused: function(selector) {
|
420
|
+
return this.actual.is(':focus')
|
223
421
|
},
|
224
422
|
|
225
|
-
|
226
|
-
|
227
|
-
var events = this.actual.
|
228
|
-
|
423
|
+
toHandle: function(event) {
|
424
|
+
|
425
|
+
var events = $._data(this.actual.get(0), "events")
|
426
|
+
|
427
|
+
if(!events || !event || typeof event !== "string") {
|
428
|
+
return false
|
429
|
+
}
|
430
|
+
|
431
|
+
var namespaces = event.split(".")
|
432
|
+
var eventType = namespaces.shift()
|
433
|
+
var sortedNamespaces = namespaces.slice(0).sort()
|
434
|
+
var namespaceRegExp = new RegExp("(^|\\.)" + sortedNamespaces.join("\\.(?:.*\\.)?") + "(\\.|$)")
|
435
|
+
|
436
|
+
if(events[eventType] && namespaces.length) {
|
437
|
+
for(var i = 0; i < events[eventType].length; i++) {
|
438
|
+
var namespace = events[eventType][i].namespace
|
439
|
+
if(namespaceRegExp.test(namespace)) {
|
440
|
+
return true
|
441
|
+
}
|
442
|
+
}
|
443
|
+
} else {
|
444
|
+
return events[eventType] && events[eventType].length > 0
|
445
|
+
}
|
229
446
|
},
|
230
447
|
|
231
448
|
// tests the existence of a specific event binding + handler
|
232
449
|
toHandleWith: function(eventName, eventHandler) {
|
233
|
-
var stack = this.actual.
|
234
|
-
var i;
|
235
|
-
|
236
|
-
if (stack[i].handler == eventHandler) {
|
237
|
-
return true;
|
238
|
-
}
|
450
|
+
var stack = $._data(this.actual.get(0), "events")[eventName]
|
451
|
+
for (var i = 0; i < stack.length; i++) {
|
452
|
+
if (stack[i].handler == eventHandler) return true
|
239
453
|
}
|
240
|
-
return false
|
454
|
+
return false
|
241
455
|
}
|
242
|
-
}
|
456
|
+
}
|
243
457
|
|
244
458
|
var hasProperty = function(actualValue, expectedValue) {
|
245
|
-
if (expectedValue === undefined)
|
246
|
-
|
247
|
-
|
248
|
-
return actualValue == expectedValue;
|
249
|
-
};
|
459
|
+
if (expectedValue === undefined) return actualValue !== undefined
|
460
|
+
return actualValue == expectedValue
|
461
|
+
}
|
250
462
|
|
251
463
|
var bindMatcher = function(methodName) {
|
252
|
-
var builtInMatcher = jasmine.Matchers.prototype[methodName]
|
464
|
+
var builtInMatcher = jasmine.Matchers.prototype[methodName]
|
253
465
|
|
254
466
|
jasmine.JQuery.matchersClass[methodName] = function() {
|
255
467
|
if (this.actual
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
468
|
+
&& (this.actual instanceof jQuery
|
469
|
+
|| jasmine.isDomNode(this.actual))) {
|
470
|
+
this.actual = $(this.actual)
|
471
|
+
var result = jQueryMatchers[methodName].apply(this, arguments)
|
472
|
+
var element
|
473
|
+
if (this.actual.get && (element = this.actual.get()[0]) && !$.isWindow(element) && element.tagName !== "HTML")
|
474
|
+
this.actual = jasmine.JQuery.elementToString(this.actual)
|
475
|
+
return result
|
476
|
+
}
|
477
|
+
|
478
|
+
if (builtInMatcher) {
|
479
|
+
return builtInMatcher.apply(this, arguments)
|
480
|
+
}
|
481
|
+
|
482
|
+
return false
|
483
|
+
}
|
484
|
+
}
|
271
485
|
|
272
486
|
for(var methodName in jQueryMatchers) {
|
273
|
-
bindMatcher(methodName)
|
487
|
+
bindMatcher(methodName)
|
274
488
|
}
|
275
|
-
}
|
489
|
+
}()
|
276
490
|
|
277
491
|
beforeEach(function() {
|
278
|
-
this.addMatchers(jasmine.JQuery.matchersClass)
|
492
|
+
this.addMatchers(jasmine.JQuery.matchersClass)
|
279
493
|
this.addMatchers({
|
280
494
|
toHaveBeenTriggeredOn: function(selector) {
|
281
495
|
this.message = function() {
|
282
496
|
return [
|
283
497
|
"Expected event " + this.actual + " to have been triggered on " + selector,
|
284
498
|
"Expected event " + this.actual + " not to have been triggered on " + selector
|
285
|
-
]
|
286
|
-
}
|
287
|
-
return jasmine.JQuery.events.wasTriggered(
|
499
|
+
]
|
500
|
+
}
|
501
|
+
return jasmine.JQuery.events.wasTriggered(selector, this.actual)
|
288
502
|
}
|
289
|
-
})
|
503
|
+
})
|
504
|
+
this.addMatchers({
|
505
|
+
toHaveBeenTriggered: function(){
|
506
|
+
var eventName = this.actual.eventName,
|
507
|
+
selector = this.actual.selector
|
508
|
+
this.message = function() {
|
509
|
+
return [
|
510
|
+
"Expected event " + eventName + " to have been triggered on " + selector,
|
511
|
+
"Expected event " + eventName + " not to have been triggered on " + selector
|
512
|
+
]
|
513
|
+
}
|
514
|
+
return jasmine.JQuery.events.wasTriggered(selector, eventName)
|
515
|
+
}
|
516
|
+
})
|
290
517
|
this.addMatchers({
|
291
518
|
toHaveBeenPreventedOn: function(selector) {
|
292
519
|
this.message = function() {
|
293
520
|
return [
|
294
521
|
"Expected event " + this.actual + " to have been prevented on " + selector,
|
295
522
|
"Expected event " + this.actual + " not to have been prevented on " + selector
|
296
|
-
]
|
297
|
-
}
|
298
|
-
return jasmine.JQuery.events.wasPrevented(selector, this.actual)
|
523
|
+
]
|
524
|
+
}
|
525
|
+
return jasmine.JQuery.events.wasPrevented(selector, this.actual)
|
526
|
+
}
|
527
|
+
})
|
528
|
+
this.addMatchers({
|
529
|
+
toHaveBeenPrevented: function() {
|
530
|
+
var eventName = this.actual.eventName,
|
531
|
+
selector = this.actual.selector
|
532
|
+
this.message = function() {
|
533
|
+
return [
|
534
|
+
"Expected event " + eventName + " to have been prevented on " + selector,
|
535
|
+
"Expected event " + eventName + " not to have been prevented on " + selector
|
536
|
+
]
|
537
|
+
}
|
538
|
+
return jasmine.JQuery.events.wasPrevented(selector, eventName)
|
299
539
|
}
|
300
|
-
})
|
301
|
-
})
|
540
|
+
})
|
541
|
+
})
|
302
542
|
|
303
543
|
afterEach(function() {
|
304
|
-
jasmine.getFixtures().cleanUp()
|
305
|
-
jasmine.
|
306
|
-
|
544
|
+
jasmine.getFixtures().cleanUp()
|
545
|
+
jasmine.getStyleFixtures().cleanUp()
|
546
|
+
jasmine.JQuery.events.cleanUp()
|
547
|
+
})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jasmine-jquery-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|
@@ -40,15 +40,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
40
|
- - ! '>='
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '0'
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
hash: 270161812332261063
|
43
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
47
|
none: false
|
45
48
|
requirements:
|
46
49
|
- - ! '>='
|
47
50
|
- !ruby/object:Gem::Version
|
48
51
|
version: '0'
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
hash: 270161812332261063
|
49
55
|
requirements: []
|
50
56
|
rubyforge_project:
|
51
|
-
rubygems_version: 1.8.
|
57
|
+
rubygems_version: 1.8.23
|
52
58
|
signing_key:
|
53
59
|
specification_version: 3
|
54
60
|
summary: jasmine-jquery via asset pipeline
|