visionmedia-jspec 2.9.1 → 2.10.0
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/History.rdoc +5 -0
- data/Manifest +1 -0
- data/README.rdoc +46 -5
- data/bin/jspec +1 -1
- data/jspec.gemspec +4 -4
- data/lib/jspec.jquery.js +1 -0
- data/lib/jspec.js +1 -1
- data/lib/jspec.timers.js +84 -0
- data/lib/jspec.xhr.js +1 -0
- data/spec/spec.dom.html +1 -0
- metadata +4 -2
data/History.rdoc
CHANGED
data/Manifest
CHANGED
data/README.rdoc
CHANGED
@@ -189,6 +189,44 @@ JSpec.options.failuresOnly = true, and ?failuresOnly=1 will both work.
|
|
189
189
|
- be_disabled
|
190
190
|
- be_selected
|
191
191
|
- be_checked
|
192
|
+
|
193
|
+
== Async Support With Mock Timers
|
194
|
+
|
195
|
+
The javascript mock timers library is available at http://github.com/visionmedia/js-mock-timers
|
196
|
+
although it is already bundled with JSpec at lib/jspec.timers.js
|
197
|
+
|
198
|
+
Timers return ids and may be passed to clearInterval(), however
|
199
|
+
they do not execute in threads, they must be manually scheduled and
|
200
|
+
controlled via the tick() function.
|
201
|
+
|
202
|
+
setTimeout(function(){
|
203
|
+
alert('Wahoo!')
|
204
|
+
}, 400)
|
205
|
+
|
206
|
+
tick(200) // Nothing happens
|
207
|
+
tick(400) // Wahoo!
|
208
|
+
|
209
|
+
setInterval() works as expected, although it persists, where as setTimeout()
|
210
|
+
is destroyed after a single call. As conveyed by the last tick() call below,
|
211
|
+
a large increment in milliseconds may cause the callbacks to be called several times
|
212
|
+
to 'catch up'.
|
213
|
+
|
214
|
+
progress = ''
|
215
|
+
var id = setInterval(function(){
|
216
|
+
progress += '.'
|
217
|
+
}, 100)
|
218
|
+
|
219
|
+
tick(50), print(progress) // ''
|
220
|
+
tick(50), print(progress) // '.'
|
221
|
+
tick(100), print(progress) // '..'
|
222
|
+
tick(100), print(progress) // '...'
|
223
|
+
tick(300), print(progress) // '......'
|
224
|
+
|
225
|
+
clearInterval(id)
|
226
|
+
|
227
|
+
tick(800) // Nothing happens
|
228
|
+
|
229
|
+
You may also reset at any time using resetTimers()
|
192
230
|
|
193
231
|
== Proxy Assertions
|
194
232
|
|
@@ -531,11 +569,13 @@ example view lib/jspec.jquery.js.
|
|
531
569
|
|
532
570
|
The following methods or properties are utilized by JSpec:
|
533
571
|
|
534
|
-
-
|
535
|
-
-
|
536
|
-
-
|
537
|
-
-
|
538
|
-
|
572
|
+
- name : module name string
|
573
|
+
- init : called to initialize a module
|
574
|
+
- formatters : hash of formatters merged with JSpec.formatters
|
575
|
+
- utilities : hash of utility functions merged with JSpec.defaultContext
|
576
|
+
- matchers : hash of matchers merged with JSpec's core matchers via JSpec.addMatchers()
|
577
|
+
- DSLs : hash of DSL methods; for example DSLs.snake contains before_each, after_each, etc.
|
578
|
+
Where as DSLs.camel may contain beforeEach, afterEach, etc.
|
539
579
|
|
540
580
|
Below is a list of hooks, descriptions, and valid return values which
|
541
581
|
may simply be implemented as module methods. beforeSuite, afterSuite, beforeSpec, and afterSpec have lower
|
@@ -705,6 +745,7 @@ Or run via the terminal using Rhino:
|
|
705
745
|
|
706
746
|
== More Information
|
707
747
|
|
748
|
+
* IRC Channel irc://irc.freenode.net#jspec
|
708
749
|
* Featured article in JSMag: http://www.jsmag.com/main.issues.description/id=21/
|
709
750
|
* Syntax comparison with other frameworks http://gist.github.com/92283
|
710
751
|
* Get the TextMate bundle at https://github.com/visionmedia/jspec.tmbundle/tree
|
data/bin/jspec
CHANGED
data/jspec.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{jspec}
|
5
|
-
s.version = "2.
|
5
|
+
s.version = "2.10.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["TJ Holowaychuk"]
|
9
|
-
s.date = %q{2009-08-
|
9
|
+
s.date = %q{2009-08-27}
|
10
10
|
s.default_executable = %q{jspec}
|
11
11
|
s.description = %q{JavaScript BDD Testing Framework}
|
12
12
|
s.email = %q{tj@vision-media.ca}
|
13
13
|
s.executables = ["jspec"]
|
14
|
-
s.extra_rdoc_files = ["bin/jspec", "lib/images/bg.png", "lib/images/hr.png", "lib/images/loading.gif", "lib/images/sprites.bg.png", "lib/images/sprites.png", "lib/images/vr.png", "lib/jspec.css", "lib/jspec.jquery.js", "lib/jspec.js", "lib/jspec.xhr.js", "README.rdoc"]
|
15
|
-
s.files = ["bin/jspec", "History.rdoc", "jspec.gemspec", "lib/images/bg.png", "lib/images/hr.png", "lib/images/loading.gif", "lib/images/sprites.bg.png", "lib/images/sprites.png", "lib/images/vr.png", "lib/jspec.css", "lib/jspec.jquery.js", "lib/jspec.js", "lib/jspec.xhr.js", "Manifest", "Rakefile", "README.rdoc", "server/browsers.rb", "server/helpers.rb", "server/routes.rb", "server/server.rb", "spec/async", "spec/env.js", "spec/fixtures/test.html", "spec/fixtures/test.json", "spec/fixtures/test.xml", "spec/modules.js", "spec/server.rb", "spec/spec.dom.html", "spec/spec.fixtures.js", "spec/spec.grammar-less.js", "spec/spec.grammar.js", "spec/spec.jquery.js", "spec/spec.jquery.xhr.js", "spec/spec.js", "spec/spec.matchers.js", "spec/spec.modules.js", "spec/spec.node.js", "spec/spec.rhino.js", "spec/spec.server.html", "spec/spec.shared-behaviors.js", "spec/spec.utils.js", "spec/spec.xhr.js", "templates/default/History.rdoc", "templates/default/lib/yourlib.core.js", "templates/default/README.rdoc", "templates/default/spec/server.rb", "templates/default/spec/spec.core.js", "templates/default/spec/spec.dom.html", "templates/default/spec/spec.rhino.js", "templates/default/spec/spec.server.html", "templates/rails/server.rb", "templates/rails/spec.application.js", "templates/rails/spec.dom.html", "templates/rails/spec.rhino.js", "templates/rails/spec.server.html"]
|
14
|
+
s.extra_rdoc_files = ["bin/jspec", "lib/images/bg.png", "lib/images/hr.png", "lib/images/loading.gif", "lib/images/sprites.bg.png", "lib/images/sprites.png", "lib/images/vr.png", "lib/jspec.css", "lib/jspec.jquery.js", "lib/jspec.js", "lib/jspec.timers.js", "lib/jspec.xhr.js", "README.rdoc"]
|
15
|
+
s.files = ["bin/jspec", "History.rdoc", "jspec.gemspec", "lib/images/bg.png", "lib/images/hr.png", "lib/images/loading.gif", "lib/images/sprites.bg.png", "lib/images/sprites.png", "lib/images/vr.png", "lib/jspec.css", "lib/jspec.jquery.js", "lib/jspec.js", "lib/jspec.timers.js", "lib/jspec.xhr.js", "Manifest", "Rakefile", "README.rdoc", "server/browsers.rb", "server/helpers.rb", "server/routes.rb", "server/server.rb", "spec/async", "spec/env.js", "spec/fixtures/test.html", "spec/fixtures/test.json", "spec/fixtures/test.xml", "spec/modules.js", "spec/server.rb", "spec/spec.dom.html", "spec/spec.fixtures.js", "spec/spec.grammar-less.js", "spec/spec.grammar.js", "spec/spec.jquery.js", "spec/spec.jquery.xhr.js", "spec/spec.js", "spec/spec.matchers.js", "spec/spec.modules.js", "spec/spec.node.js", "spec/spec.rhino.js", "spec/spec.server.html", "spec/spec.shared-behaviors.js", "spec/spec.utils.js", "spec/spec.xhr.js", "templates/default/History.rdoc", "templates/default/lib/yourlib.core.js", "templates/default/README.rdoc", "templates/default/spec/server.rb", "templates/default/spec/spec.core.js", "templates/default/spec/spec.dom.html", "templates/default/spec/spec.rhino.js", "templates/default/spec/spec.server.html", "templates/rails/server.rb", "templates/rails/spec.application.js", "templates/rails/spec.dom.html", "templates/rails/spec.rhino.js", "templates/rails/spec.server.html"]
|
16
16
|
s.homepage = %q{http://visionmedia.github.com/jspec}
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Jspec", "--main", "README.rdoc"]
|
18
18
|
s.require_paths = ["lib"]
|
data/lib/jspec.jquery.js
CHANGED
data/lib/jspec.js
CHANGED
data/lib/jspec.timers.js
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
|
2
|
+
// Mock Timers - 1.0.0 - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
|
3
|
+
|
4
|
+
;(function(){
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Localized timer stack.
|
8
|
+
*/
|
9
|
+
|
10
|
+
var timers = []
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Set mock timeout with _callback_ and timeout of _ms_.
|
14
|
+
*
|
15
|
+
* @param {function} callback
|
16
|
+
* @param {int} ms
|
17
|
+
* @return {int}
|
18
|
+
* @api public
|
19
|
+
*/
|
20
|
+
|
21
|
+
setTimeout = function(callback, ms) {
|
22
|
+
var id
|
23
|
+
return id = setInterval(function(){
|
24
|
+
callback()
|
25
|
+
clearInterval(id)
|
26
|
+
}, ms)
|
27
|
+
}
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Set mock interval with _callback_ and interval of _ms_.
|
31
|
+
*
|
32
|
+
* @param {function} callback
|
33
|
+
* @param {int} ms
|
34
|
+
* @return {int}
|
35
|
+
* @api public
|
36
|
+
*/
|
37
|
+
|
38
|
+
setInterval = function(callback, ms) {
|
39
|
+
callback.step = ms, callback.current = callback.last = 0
|
40
|
+
return timers[timers.length] = callback, timers.length
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Destroy timer with _id_.
|
45
|
+
*
|
46
|
+
* @param {int} id
|
47
|
+
* @return {bool}
|
48
|
+
* @api public
|
49
|
+
*/
|
50
|
+
|
51
|
+
clearInterval = function(id) {
|
52
|
+
return delete timers[--id]
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Reset timers.
|
57
|
+
*
|
58
|
+
* @return {array}
|
59
|
+
* @api public
|
60
|
+
*/
|
61
|
+
|
62
|
+
resetTimers = function() {
|
63
|
+
return timers = []
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Increment each timers internal clock by _ms_.
|
68
|
+
*
|
69
|
+
* @param {int} ms
|
70
|
+
* @api public
|
71
|
+
*/
|
72
|
+
|
73
|
+
tick = function(ms) {
|
74
|
+
for (var i = 0, len = timers.length; i < len; ++i)
|
75
|
+
if (timers[i] && (timers[i].current += ms))
|
76
|
+
if (timers[i].current - timers[i].last >= timers[i].step) {
|
77
|
+
var times = Math.floor((timers[i].current - timers[i].last) / timers[i].step)
|
78
|
+
var remainder = (timers[i].current - timers[i].last) % timers[i].step
|
79
|
+
timers[i].last = timers[i].current - remainder
|
80
|
+
while (times--) timers[i]()
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
})()
|
data/lib/jspec.xhr.js
CHANGED
data/spec/spec.dom.html
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
<script src="../lib/jspec.js"></script>
|
6
6
|
<script src="../lib/jspec.jquery.js"></script>
|
7
7
|
<script src="../lib/jspec.xhr.js"></script>
|
8
|
+
<script src="../lib/jspec.timers.js"></script>
|
8
9
|
<script src="modules.js"></script>
|
9
10
|
<script src="spec.grammar-less.js"></script>
|
10
11
|
<script>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visionmedia-jspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TJ Holowaychuk
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-27 00:00:00 -07:00
|
13
13
|
default_executable: jspec
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -69,6 +69,7 @@ extra_rdoc_files:
|
|
69
69
|
- lib/jspec.css
|
70
70
|
- lib/jspec.jquery.js
|
71
71
|
- lib/jspec.js
|
72
|
+
- lib/jspec.timers.js
|
72
73
|
- lib/jspec.xhr.js
|
73
74
|
- README.rdoc
|
74
75
|
files:
|
@@ -84,6 +85,7 @@ files:
|
|
84
85
|
- lib/jspec.css
|
85
86
|
- lib/jspec.jquery.js
|
86
87
|
- lib/jspec.js
|
88
|
+
- lib/jspec.timers.js
|
87
89
|
- lib/jspec.xhr.js
|
88
90
|
- Manifest
|
89
91
|
- Rakefile
|