jasmine-jquery-rails 1.4.2 → 1.5.3

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e8b3556accc34ab3a94e5ab912d878adbef78e6e
4
+ data.tar.gz: 58ab7da7878cbe9ce2ea0c575b4bdde770890baf
5
+ SHA512:
6
+ metadata.gz: 06a87ba4c95ee47b4824f0d0da470246785a2b00cfe61d47ff36cd85cb11687a08c9458967a46d79c54b30ef08217a62360500c7cdc5ac0d4667e3569bcaf588
7
+ data.tar.gz: 230360dbbe128625f002ca040b4d148108c9bab61e1f1092502b23cacd70c5e648c59823a3465f9f2c1681b534918b968534838054a960087421a4b8ceba0545
@@ -1,7 +1,7 @@
1
1
  module Jasmine
2
2
  module Jquery
3
3
  module Rails
4
- VERSION = "1.4.2"
4
+ VERSION = "1.5.3"
5
5
  end
6
6
  end
7
7
  end
@@ -1,3 +1,31 @@
1
+ /*!
2
+ Jasmine-jQuery: a set of jQuery helpers for Jasmine tests.
3
+
4
+ Version 1.5.3
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
+ */
1
29
  var readFixtures = function() {
2
30
  return jasmine.getFixtures().proxyCallTo_('read', arguments)
3
31
  }
@@ -114,27 +142,27 @@ jasmine.Fixtures.prototype.clearCache = function() {
114
142
  }
115
143
 
116
144
  jasmine.Fixtures.prototype.cleanUp = function() {
117
- jQuery('#' + this.containerId).remove()
145
+ $('#' + this.containerId).remove()
118
146
  }
119
147
 
120
148
  jasmine.Fixtures.prototype.sandbox = function(attributes) {
121
149
  var attributesToSet = attributes || {}
122
- return jQuery('<div id="sandbox" />').attr(attributesToSet)
150
+ return $('<div id="sandbox" />').attr(attributesToSet)
123
151
  }
124
152
 
125
153
  jasmine.Fixtures.prototype.createContainer_ = function(html) {
126
154
  var container
127
- if(html instanceof jQuery) {
128
- container = jQuery('<div id="' + this.containerId + '" />')
155
+ if(html instanceof $) {
156
+ container = $('<div id="' + this.containerId + '" />')
129
157
  container.html(html)
130
158
  } else {
131
159
  container = '<div id="' + this.containerId + '">' + html + '</div>'
132
160
  }
133
- jQuery('body').append(container)
161
+ $(document.body).append(container)
134
162
  }
135
163
 
136
164
  jasmine.Fixtures.prototype.addToContainer_ = function(html){
137
- var container = jQuery('body').find('#'+this.containerId).append(html)
165
+ var container = $(document.body).find('#'+this.containerId).append(html)
138
166
  if(!container.length){
139
167
  this.createContainer_(html)
140
168
  }
@@ -149,7 +177,7 @@ jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) {
149
177
 
150
178
  jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
151
179
  var url = this.makeFixtureUrl_(relativeUrl)
152
- var request = jQuery.ajax({
180
+ var request = $.ajax({
153
181
  type: "GET",
154
182
  url: url + "?" + new Date().getTime(),
155
183
  async: false
@@ -201,11 +229,12 @@ jasmine.StyleFixtures.prototype.cleanUp = function() {
201
229
  }
202
230
 
203
231
  jasmine.StyleFixtures.prototype.createStyle_ = function(html) {
204
- var style = jQuery('<style></style>').text(html)
232
+ var styleText = $('<div></div>').html(html).text(),
233
+ style = $('<style>' + styleText + '</style>')
205
234
 
206
235
  this.fixturesNodes_.push(style)
207
236
 
208
- jQuery('head').append(style)
237
+ $('head').append(style)
209
238
  }
210
239
 
211
240
  jasmine.StyleFixtures.prototype.clearCache = jasmine.Fixtures.prototype.clearCache
@@ -220,8 +249,6 @@ jasmine.StyleFixtures.prototype.makeFixtureUrl_ = jasmine.Fixtures.prototype.mak
220
249
 
221
250
  jasmine.StyleFixtures.prototype.proxyCallTo_ = jasmine.Fixtures.prototype.proxyCallTo_
222
251
 
223
- /** jasmine json fixtures */
224
-
225
252
  jasmine.getJSONFixtures = function() {
226
253
  return jasmine.currentJSONFixtures_ = jasmine.currentJSONFixtures_ || new jasmine.JSONFixtures()
227
254
  }
@@ -248,7 +275,7 @@ jasmine.JSONFixtures.prototype.clearCache = function() {
248
275
  this.fixturesCache_ = {}
249
276
  }
250
277
 
251
- jasmine.JSONFixtures.prototype.getFixtureData_ = function(url) {
278
+ jasmine.JSONFixtures.prototype.getFixtureData_ = function(url) {
252
279
  this.loadFixtureIntoCache_(url)
253
280
  return this.fixturesCache_[url]
254
281
  }
@@ -256,7 +283,7 @@ jasmine.JSONFixtures.prototype.getFixtureData_ = function(url) {
256
283
  jasmine.JSONFixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
257
284
  var self = this
258
285
  var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl
259
- jQuery.ajax({
286
+ $.ajax({
260
287
  async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
261
288
  cache: false,
262
289
  dataType: 'json',
@@ -277,13 +304,13 @@ jasmine.JSONFixtures.prototype.proxyCallTo_ = function(methodName, passedArgumen
277
304
  jasmine.JQuery = function() {}
278
305
 
279
306
  jasmine.JQuery.browserTagCaseIndependentHtml = function(html) {
280
- return jQuery('<div/>').append(html).html()
307
+ return $('<div/>').append(html).html()
281
308
  }
282
309
 
283
310
  jasmine.JQuery.elementToString = function(element) {
284
311
  var domEl = $(element).get(0)
285
312
  if (domEl == undefined || domEl.cloneNode)
286
- return jQuery('<div />').append($(element).clone()).html()
313
+ return $('<div />').append($(element).clone()).html()
287
314
  else
288
315
  return element.toString()
289
316
  }
@@ -299,9 +326,9 @@ jasmine.JQuery.matchersClass = {}
299
326
  namespace.events = {
300
327
  spyOn: function(selector, eventName) {
301
328
  var handler = function(e) {
302
- data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = e
329
+ data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)] = jasmine.util.argsToArray(arguments)
303
330
  }
304
- jQuery(selector).bind(eventName, handler)
331
+ $(selector).on(eventName, handler)
305
332
  data.handlers.push(handler)
306
333
  return {
307
334
  selector: selector,
@@ -313,12 +340,38 @@ jasmine.JQuery.matchersClass = {}
313
340
  }
314
341
  },
315
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
+
316
353
  wasTriggered: function(selector, eventName) {
317
354
  return !!(data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)])
318
355
  },
319
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
+
320
365
  wasPrevented: function(selector, eventName) {
321
- return data.spiedEvents[jasmine.spiedEventsKey(selector, eventName)].isDefaultPrevented()
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()
322
375
  },
323
376
 
324
377
  cleanUp: function() {
@@ -365,6 +418,10 @@ jasmine.JQuery.matchersClass = {}
365
418
  return $(document).find(this.actual).length
366
419
  },
367
420
 
421
+ toHaveLength: function(length) {
422
+ return this.actual.length === length
423
+ },
424
+
368
425
  toHaveAttr: function(attributeName, expectedAttributeValue) {
369
426
  return hasProperty(this.actual.attr(attributeName), expectedAttributeValue)
370
427
  },
@@ -389,15 +446,24 @@ jasmine.JQuery.matchersClass = {}
389
446
 
390
447
  toHaveText: function(text) {
391
448
  var trimmedText = $.trim(this.actual.text())
392
- if (text && jQuery.isFunction(text.test)) {
449
+ if (text && $.isFunction(text.test)) {
393
450
  return text.test(trimmedText)
394
451
  } else {
395
452
  return trimmedText == text
396
453
  }
397
454
  },
398
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
+
399
465
  toHaveValue: function(value) {
400
- return this.actual.val() == value
466
+ return this.actual.val() === value
401
467
  },
402
468
 
403
469
  toHaveData: function(key, expectedValue) {
@@ -417,7 +483,7 @@ jasmine.JQuery.matchersClass = {}
417
483
  },
418
484
 
419
485
  toBeFocused: function(selector) {
420
- return this.actual.is(':focus')
486
+ return this.actual[0] === this.actual[0].ownerDocument.activeElement
421
487
  },
422
488
 
423
489
  toHandle: function(event) {
@@ -465,7 +531,7 @@ jasmine.JQuery.matchersClass = {}
465
531
 
466
532
  jasmine.JQuery.matchersClass[methodName] = function() {
467
533
  if (this.actual
468
- && (this.actual instanceof jQuery
534
+ && (this.actual instanceof $
469
535
  || jasmine.isDomNode(this.actual))) {
470
536
  this.actual = $(this.actual)
471
537
  var result = jQueryMatchers[methodName].apply(this, arguments)
@@ -514,6 +580,28 @@ beforeEach(function() {
514
580
  return jasmine.JQuery.events.wasTriggered(selector, eventName)
515
581
  }
516
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
+ })
517
605
  this.addMatchers({
518
606
  toHaveBeenPreventedOn: function(selector) {
519
607
  this.message = function() {
@@ -538,6 +626,30 @@ beforeEach(function() {
538
626
  return jasmine.JQuery.events.wasPrevented(selector, eventName)
539
627
  }
540
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
+ })
541
653
  })
542
654
 
543
655
  afterEach(function() {
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jasmine-jquery-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
5
- prerelease:
4
+ version: 1.5.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Travis Jeffery
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-09-14 00:00:00.000000000 Z
11
+ date: 2013-07-17 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description:
15
14
  email:
@@ -30,32 +29,25 @@ files:
30
29
  - vendor/assets/javascripts/jasmine-jquery.js
31
30
  homepage: http://github.com/travisjeffery/jasmine-jquery-rails
32
31
  licenses: []
32
+ metadata: {}
33
33
  post_install_message:
34
34
  rdoc_options: []
35
35
  require_paths:
36
36
  - lib
37
37
  required_ruby_version: !ruby/object:Gem::Requirement
38
- none: false
39
38
  requirements:
40
- - - ! '>='
39
+ - - '>='
41
40
  - !ruby/object:Gem::Version
42
41
  version: '0'
43
- segments:
44
- - 0
45
- hash: 270161812332261063
46
42
  required_rubygems_version: !ruby/object:Gem::Requirement
47
- none: false
48
43
  requirements:
49
- - - ! '>='
44
+ - - '>='
50
45
  - !ruby/object:Gem::Version
51
46
  version: '0'
52
- segments:
53
- - 0
54
- hash: 270161812332261063
55
47
  requirements: []
56
48
  rubyforge_project:
57
- rubygems_version: 1.8.23
49
+ rubygems_version: 2.0.3
58
50
  signing_key:
59
- specification_version: 3
51
+ specification_version: 4
60
52
  summary: jasmine-jquery via asset pipeline
61
53
  test_files: []