visionmedia-jspec 2.8.2 → 2.8.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +9 -0
- data/Manifest +1 -0
- data/bin/jspec +1 -1
- data/jspec.gemspec +3 -3
- data/lib/jspec.js +36 -4
- data/lib/jspec.xhr.js +157 -105
- data/spec/modules.js +9 -7
- data/spec/spec.dom.html +1 -0
- data/spec/spec.fixtures.js +18 -0
- data/spec/spec.modules.js +21 -24
- data/spec/spec.node.js +4 -2
- data/spec/spec.rhino.js +1 -0
- data/spec/spec.server.html +1 -0
- data/spec/spec.utils.js +13 -11
- data/spec/spec.xhr.js +21 -5
- metadata +3 -2
data/History.rdoc
CHANGED
@@ -1,4 +1,13 @@
|
|
1
1
|
|
2
|
+
=== 2.8.3 / 2009-07-30
|
3
|
+
|
4
|
+
* Added JSpec.evalHook()
|
5
|
+
* Added JSpec.paramsFor()
|
6
|
+
* Refactored jspec.xhr.js
|
7
|
+
* Fixed mock xhr HEAD method
|
8
|
+
* Fixed node.js print() newline issue
|
9
|
+
* Fixed specs preventing spec/spec.node.js from running
|
10
|
+
|
2
11
|
=== 2.8.2 / 2009-07-29
|
3
12
|
|
4
13
|
* Added JSpec.tryLoading()
|
data/Manifest
CHANGED
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.8.
|
5
|
+
s.version = "2.8.3"
|
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-07-
|
9
|
+
s.date = %q{2009-07-30}
|
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
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/server.rb", "spec/async", "spec/env.js", "spec/fixtures/test.html", "spec/fixtures/test.json", "spec/fixtures/test.xml", "spec/modules.js", "spec/spec.dom.html", "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/spec.core.js", "templates/default/spec/spec.dom.html", "templates/default/spec/spec.rhino.js", "templates/default/spec/spec.server.html", "templates/rails/spec.application.js", "templates/rails/spec.dom.html", "templates/rails/spec.rhino.js", "templates/rails/spec.server.html"]
|
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/server.rb", "spec/async", "spec/env.js", "spec/fixtures/test.html", "spec/fixtures/test.json", "spec/fixtures/test.xml", "spec/modules.js", "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/spec.core.js", "templates/default/spec/spec.dom.html", "templates/default/spec/spec.rhino.js", "templates/default/spec/spec.server.html", "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.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
JSpec = {
|
7
7
|
|
8
|
-
version : '2.8.
|
8
|
+
version : '2.8.3',
|
9
9
|
cache : {},
|
10
10
|
suites : [],
|
11
11
|
modules : [],
|
@@ -646,10 +646,31 @@
|
|
646
646
|
args = argumentsToArray(arguments, 1)
|
647
647
|
return inject(JSpec.modules, [], function(results, module){
|
648
648
|
if (typeof module[name] == 'function')
|
649
|
-
results.push(
|
649
|
+
results.push(JSpec.evalHook(module, name, args))
|
650
650
|
})
|
651
651
|
},
|
652
652
|
|
653
|
+
/**
|
654
|
+
* Eval _module_ hook _name_ with _args_. Evaluates in context
|
655
|
+
* to the module itself, JSpec, and JSpec.context.
|
656
|
+
*
|
657
|
+
* @param {Module} module
|
658
|
+
* @param {string} name
|
659
|
+
* @param {array} args
|
660
|
+
* @return {mixed}
|
661
|
+
* @api private
|
662
|
+
*/
|
663
|
+
|
664
|
+
evalHook : function(module, name, args) {
|
665
|
+
var context = this.context || this.defaultContext
|
666
|
+
var contents = this.contentsOf(module[name])
|
667
|
+
var params = this.paramsFor(module[name])
|
668
|
+
params.unshift('context'); args.unshift(context)
|
669
|
+
hook('evaluatingHookBody', module, name, context)
|
670
|
+
try { return new Function(params.join(), 'with (this.utilities) { with (context) { with (JSpec) { ' + contents + ' }}}').apply(module, args) }
|
671
|
+
catch(e) { error('Error in hook ' + module.name + "." + name + ': ', e) }
|
672
|
+
},
|
673
|
+
|
653
674
|
/**
|
654
675
|
* Same as hook() however accepts only one _arg_ which is
|
655
676
|
* considered immutable. This function passes the arg
|
@@ -665,7 +686,7 @@
|
|
665
686
|
hookImmutable : function(name, arg) {
|
666
687
|
return inject(JSpec.modules, arg, function(result, module){
|
667
688
|
if (typeof module[name] == 'function')
|
668
|
-
return
|
689
|
+
return JSpec.evalHook(module, name, [result])
|
669
690
|
})
|
670
691
|
},
|
671
692
|
|
@@ -1225,6 +1246,18 @@
|
|
1225
1246
|
contentsOf : function(body) {
|
1226
1247
|
return body.toString().match(/^[^\{]*{((.*\n*)*)}/m)[1]
|
1227
1248
|
},
|
1249
|
+
|
1250
|
+
/**
|
1251
|
+
* Return param names for a function body.
|
1252
|
+
*
|
1253
|
+
* @param {function} body
|
1254
|
+
* @return {array}
|
1255
|
+
* @api public
|
1256
|
+
*/
|
1257
|
+
|
1258
|
+
paramsFor : function(body) {
|
1259
|
+
return body.toString().match(/\((.*?)\)/)[1].match(/[\w]+/g) || []
|
1260
|
+
},
|
1228
1261
|
|
1229
1262
|
/**
|
1230
1263
|
* Evaluate a JSpec capture body.
|
@@ -1353,7 +1386,6 @@
|
|
1353
1386
|
JSpec.currentSpec.fail(message)
|
1354
1387
|
},
|
1355
1388
|
|
1356
|
-
|
1357
1389
|
/**
|
1358
1390
|
* Report a passing assertion for the current spec.
|
1359
1391
|
*
|
data/lib/jspec.xhr.js
CHANGED
@@ -1,121 +1,173 @@
|
|
1
1
|
|
2
2
|
// JSpec - XHR - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
204 : 'No Content',
|
14
|
-
205 : 'Reset Content',
|
15
|
-
206 : 'Partial Content',
|
16
|
-
300 : 'Multiple Choice',
|
17
|
-
301 : 'Moved Permanently',
|
18
|
-
302 : 'Found',
|
19
|
-
303 : 'See Other',
|
20
|
-
304 : 'Not Modified',
|
21
|
-
305 : 'Use Proxy',
|
22
|
-
307 : 'Temporary Redirect',
|
23
|
-
400 : 'Bad Request',
|
24
|
-
401 : 'Unauthorized',
|
25
|
-
402 : 'Payment Required',
|
26
|
-
403 : 'Forbidden',
|
27
|
-
404 : 'Not Found',
|
28
|
-
405 : 'Method Not Allowed',
|
29
|
-
406 : 'Not Acceptable',
|
30
|
-
407 : 'Proxy Authentication Required',
|
31
|
-
408 : 'Request Timeout',
|
32
|
-
409 : 'Conflict',
|
33
|
-
410 : 'Gone',
|
34
|
-
411 : 'Length Required',
|
35
|
-
412 : 'Precondition Failed',
|
36
|
-
413 : 'Request Entity Too Large',
|
37
|
-
414 : 'Request-URI Too Long',
|
38
|
-
415 : 'Unsupported Media Type',
|
39
|
-
416 : 'Requested Range Not Satisfiable',
|
40
|
-
417 : 'Expectation Failed',
|
41
|
-
422 : 'Unprocessable Entity',
|
42
|
-
500 : 'Internal Server Error',
|
43
|
-
501 : 'Not Implemented',
|
44
|
-
502 : 'Bad Gateway',
|
45
|
-
503 : 'Service Unavailable',
|
46
|
-
504 : 'Gateway Timeout',
|
47
|
-
505 : 'HTTP Version Not Supported'
|
48
|
-
}
|
4
|
+
(function(){
|
5
|
+
|
6
|
+
// --- Original XMLHttpRequest
|
7
|
+
|
8
|
+
var OriginalXMLHttpRequest = 'XMLHttpRequest' in this ?
|
9
|
+
XMLHttpRequest :
|
10
|
+
function(){}
|
11
|
+
|
12
|
+
// --- MockXMLHttpRequest
|
49
13
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
readyState : 0,
|
54
|
-
responseText : '',
|
55
|
-
abort : function(){},
|
56
|
-
onreadystatechange : function(){},
|
14
|
+
var MockXMLHttpRequest = function() {
|
15
|
+
this.requestHeaders = {}
|
16
|
+
}
|
57
17
|
|
58
|
-
|
59
|
-
|
60
|
-
|
18
|
+
MockXMLHttpRequest.prototype = {
|
19
|
+
status : 0,
|
20
|
+
async : true,
|
21
|
+
readyState : 0,
|
22
|
+
responseText : '',
|
23
|
+
abort : function(){},
|
24
|
+
onreadystatechange : function(){},
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Return response headers hash.
|
28
|
+
*/
|
29
|
+
|
30
|
+
getAllResponseHeaders : function(){
|
31
|
+
return this.responseHeaders
|
32
|
+
},
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Return case-insensitive value for header _name_.
|
36
|
+
*/
|
37
|
+
|
38
|
+
getResponseHeader : function(name) {
|
39
|
+
return this.responseHeaders[name.toLowerCase()]
|
40
|
+
},
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Set case-insensitive _value_ for header _name_.
|
44
|
+
*/
|
45
|
+
|
46
|
+
setRequestHeader : function(name, value) {
|
47
|
+
this.requestHeaders[name.toLowerCase()] = value
|
48
|
+
},
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Open mock request.
|
52
|
+
*/
|
53
|
+
|
54
|
+
open : function(method, url, async, user, password) {
|
55
|
+
this.user = user
|
56
|
+
this.password = password
|
57
|
+
this.url = url
|
58
|
+
this.readyState = 1
|
59
|
+
this.method = method.toUpperCase()
|
60
|
+
if (async != undefined) this.async = async
|
61
|
+
if (this.async) this.onreadystatechange()
|
62
|
+
},
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Send request _data_.
|
66
|
+
*/
|
67
|
+
|
68
|
+
send : function(data) {
|
69
|
+
this.data = data
|
70
|
+
this.readyState = 4
|
71
|
+
if (this.method == 'HEAD') this.responseText = null
|
72
|
+
this.responseHeaders['content-length'] = (this.responseText || '').length
|
73
|
+
if(this.async) this.onreadystatechange()
|
74
|
+
}
|
75
|
+
}
|
61
76
|
|
62
|
-
|
63
|
-
return this.responseHeaders[name.toLowerCase()]
|
64
|
-
},
|
77
|
+
// --- Response status codes
|
65
78
|
|
66
|
-
|
67
|
-
|
68
|
-
|
79
|
+
JSpec.statusCodes = {
|
80
|
+
100 : 'Continue',
|
81
|
+
101 : 'Switching Protocols',
|
82
|
+
200 : 'OK',
|
83
|
+
201 : 'Created',
|
84
|
+
202 : 'Accepted',
|
85
|
+
203 : 'Non-Authoritative Information',
|
86
|
+
204 : 'No Content',
|
87
|
+
205 : 'Reset Content',
|
88
|
+
206 : 'Partial Content',
|
89
|
+
300 : 'Multiple Choice',
|
90
|
+
301 : 'Moved Permanently',
|
91
|
+
302 : 'Found',
|
92
|
+
303 : 'See Other',
|
93
|
+
304 : 'Not Modified',
|
94
|
+
305 : 'Use Proxy',
|
95
|
+
307 : 'Temporary Redirect',
|
96
|
+
400 : 'Bad Request',
|
97
|
+
401 : 'Unauthorized',
|
98
|
+
402 : 'Payment Required',
|
99
|
+
403 : 'Forbidden',
|
100
|
+
404 : 'Not Found',
|
101
|
+
405 : 'Method Not Allowed',
|
102
|
+
406 : 'Not Acceptable',
|
103
|
+
407 : 'Proxy Authentication Required',
|
104
|
+
408 : 'Request Timeout',
|
105
|
+
409 : 'Conflict',
|
106
|
+
410 : 'Gone',
|
107
|
+
411 : 'Length Required',
|
108
|
+
412 : 'Precondition Failed',
|
109
|
+
413 : 'Request Entity Too Large',
|
110
|
+
414 : 'Request-URI Too Long',
|
111
|
+
415 : 'Unsupported Media Type',
|
112
|
+
416 : 'Requested Range Not Satisfiable',
|
113
|
+
417 : 'Expectation Failed',
|
114
|
+
422 : 'Unprocessable Entity',
|
115
|
+
500 : 'Internal Server Error',
|
116
|
+
501 : 'Not Implemented',
|
117
|
+
502 : 'Bad Gateway',
|
118
|
+
503 : 'Service Unavailable',
|
119
|
+
504 : 'Gateway Timeout',
|
120
|
+
505 : 'HTTP Version Not Supported'
|
121
|
+
}
|
69
122
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
},
|
123
|
+
/**
|
124
|
+
* Mock XMLHttpRequest requests.
|
125
|
+
*
|
126
|
+
* mockRequest().and_return('some data', 'text/plain', 200, { 'X-SomeHeader' : 'somevalue' })
|
127
|
+
*
|
128
|
+
* @return {hash}
|
129
|
+
* @api public
|
130
|
+
*/
|
79
131
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
132
|
+
function mockRequest() {
|
133
|
+
return { and_return : function(body, type, status, headers) {
|
134
|
+
XMLHttpRequest = MockXMLHttpRequest
|
135
|
+
status = status || 200
|
136
|
+
headers = headers || {}
|
137
|
+
headers['content-type'] = type
|
138
|
+
JSpec.extend(XMLHttpRequest.prototype, {
|
139
|
+
responseText : body,
|
140
|
+
responseHeaders : headers,
|
141
|
+
status : status,
|
142
|
+
statusText : JSpec.statusCodes[status]
|
143
|
+
})
|
144
|
+
}}
|
86
145
|
}
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Unmock XMLHttpRequest requests.
|
149
|
+
*
|
150
|
+
* @api public
|
151
|
+
*/
|
152
|
+
|
153
|
+
function unmockRequest() {
|
154
|
+
XMLHttpRequest = OriginalXMLHttpRequest
|
155
|
+
}
|
156
|
+
|
157
|
+
JSpec.include({
|
94
158
|
|
95
|
-
|
159
|
+
// --- Utilities
|
96
160
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
XMLHttpRequest = JSpec.XMLHttpRequest
|
101
|
-
status = status || 200
|
102
|
-
headers = headers || {}
|
103
|
-
headers['content-type'] = type
|
104
|
-
JSpec.extend(XMLHttpRequest.prototype, {
|
105
|
-
responseText : body,
|
106
|
-
responseHeaders : headers,
|
107
|
-
status : status,
|
108
|
-
statusText : XMLHttpRequest.status[status]
|
109
|
-
})
|
110
|
-
}}
|
161
|
+
utilities : {
|
162
|
+
mockRequest : mockRequest,
|
163
|
+
unmockRequest : unmockRequest
|
111
164
|
},
|
112
|
-
unmockRequest : unmockRequest
|
113
|
-
},
|
114
165
|
|
115
|
-
|
166
|
+
// --- Hooks
|
116
167
|
|
117
|
-
|
118
|
-
|
119
|
-
|
168
|
+
afterSpec : function() {
|
169
|
+
this.utilities.unmockRequest()
|
170
|
+
}
|
120
171
|
|
121
|
-
})
|
172
|
+
})
|
173
|
+
})()
|
data/spec/modules.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
|
2
2
|
ExampleModule = {
|
3
|
+
name : 'ExampleModule',
|
3
4
|
utilities : {
|
4
5
|
doFoo : function(){ return 'foo' },
|
5
6
|
doBar : function(){ return 'bar' }
|
@@ -7,13 +8,14 @@ ExampleModule = {
|
|
7
8
|
randomHook : function(a, b) {
|
8
9
|
return [a, b]
|
9
10
|
},
|
10
|
-
beforeSpec : function() { addedBeforeSpec
|
11
|
-
afterSpec : function() { addedAfterSpec
|
12
|
-
beforeSuite : function() { addedBeforeSuite = true
|
13
|
-
afterSuite : function() {
|
14
|
-
|
15
|
-
|
16
|
-
},
|
11
|
+
beforeSpec : function() { addedBeforeSpec = true; doFoo() },
|
12
|
+
afterSpec : function() { addedAfterSpec = true },
|
13
|
+
beforeSuite : function() { addedBeforeSuite = true },
|
14
|
+
afterSuite : function() { addedAfterSuite = true },
|
15
|
+
checkJSpecContext : function(){ return each },
|
16
|
+
checkContext : function() { return fixture('test') },
|
17
|
+
checkModuleContext : function() { return this.name },
|
18
|
+
checkUtilityContext : function() { return doFoo() },
|
17
19
|
matchers : {
|
18
20
|
be_foo_bar : function() {
|
19
21
|
return true
|
data/spec/spec.dom.html
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
describe 'Utility'
|
3
|
+
describe 'fixture()'
|
4
|
+
it 'should return a files contents'
|
5
|
+
fixture('fixtures/test.html').should.eql '<p>test</p>'
|
6
|
+
fixture('test.html').should.eql '<p>test</p>'
|
7
|
+
fixture('test').should.eql '<p>test</p>'
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should cache contents'
|
11
|
+
contents = fixture('test')
|
12
|
+
JSpec.cache['test'].should.eql contents
|
13
|
+
JSpec.cache['test'] = 'foo'
|
14
|
+
fixture('test').should.eql 'foo'
|
15
|
+
delete JSpec.cache['test']
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec.modules.js
CHANGED
@@ -2,41 +2,38 @@
|
|
2
2
|
describe 'JSpec'
|
3
3
|
describe 'module'
|
4
4
|
describe 'hooks'
|
5
|
-
|
6
|
-
|
5
|
+
it 'should run beforeSpec'
|
6
|
+
addedBeforeSpec.should.be_true
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
it 'should run afterSpec'
|
10
|
+
addedAfterSpec.should.be_true
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
describe 'with suites'
|
14
|
+
it 'should run beforeSuite'
|
15
|
+
addedBeforeSuite.should.be_true
|
16
|
+
end
|
17
17
|
end
|
18
18
|
|
19
|
-
it 'should run
|
20
|
-
|
19
|
+
it 'should run afterSuite'
|
20
|
+
addedAfterSuite.should.be_true
|
21
21
|
end
|
22
|
-
|
23
|
-
it 'should run in context with
|
24
|
-
|
25
|
-
addedAfterSpec.should.be_true
|
22
|
+
|
23
|
+
it 'should run in context with JSpec'
|
24
|
+
hook('checkJSpecContext')[0].should.equal JSpec.each
|
26
25
|
end
|
27
26
|
|
28
|
-
it 'should run
|
29
|
-
|
27
|
+
it 'should run in context to JSpecs default context'
|
28
|
+
hook('checkContext')[0].should.eql fixture('test')
|
30
29
|
end
|
31
|
-
|
32
|
-
it 'should run in context
|
33
|
-
|
30
|
+
|
31
|
+
it 'should run in context to the module itself'
|
32
|
+
hook('checkModuleContext')[0].should.eql 'ExampleModule'
|
34
33
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
addedAfterSuite.should.be_true
|
39
|
-
end
|
34
|
+
|
35
|
+
it 'should run in context to the modules utilities'
|
36
|
+
hook('checkUtilityContext')[0].should.eql 'foo'
|
40
37
|
end
|
41
38
|
end
|
42
39
|
|
data/spec/spec.node.js
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
__loading__ = []
|
3
3
|
__loadDelay__ = 1000
|
4
4
|
|
5
|
+
originalPrint = print
|
6
|
+
print = puts
|
7
|
+
|
5
8
|
readFile = function(path, callback) {
|
6
9
|
__loading__.push(path)
|
7
10
|
var promise = node.fs.cat(path, "utf8")
|
@@ -33,9 +36,8 @@ setTimeout(function(){
|
|
33
36
|
.exec('spec/spec.matchers.js')
|
34
37
|
.exec('spec/spec.utils.js')
|
35
38
|
.exec('spec/spec.shared-behaviors.js')
|
36
|
-
.exec('spec/spec.modules.js')
|
37
39
|
setTimeout(function(){
|
38
|
-
JSpec.run({ formatter : JSpec.formatters.Terminal, failuresOnly :
|
40
|
+
JSpec.run({ formatter : JSpec.formatters.Terminal, failuresOnly : false })
|
39
41
|
setTimeout(function() {
|
40
42
|
JSpec.report()
|
41
43
|
}, __loadDelay__ / 3)
|
data/spec/spec.rhino.js
CHANGED
data/spec/spec.server.html
CHANGED
data/spec/spec.utils.js
CHANGED
@@ -256,19 +256,21 @@ describe 'Utility'
|
|
256
256
|
end
|
257
257
|
end
|
258
258
|
|
259
|
-
describe '
|
260
|
-
it 'should return
|
261
|
-
|
262
|
-
fixture('test.html').should.eql '<p>test</p>'
|
263
|
-
fixture('test').should.eql '<p>test</p>'
|
259
|
+
describe 'paramsFor()'
|
260
|
+
it 'should return an array of function parameter names'
|
261
|
+
JSpec.paramsFor(function(foo, bar){}).should.eql ['foo', 'bar']
|
264
262
|
end
|
265
263
|
|
266
|
-
it 'should
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
264
|
+
it 'should return only the params for the root function'
|
265
|
+
foo = function(bar){
|
266
|
+
function baz(test) {}
|
267
|
+
var something = function(foo, bar){}
|
268
|
+
}
|
269
|
+
JSpec.paramsFor(foo).should.eql ['bar']
|
270
|
+
end
|
271
|
+
|
272
|
+
it 'should return empty array when no params are present'
|
273
|
+
JSpec.paramsFor(function(){}).should.eql []
|
272
274
|
end
|
273
275
|
end
|
274
276
|
end
|
data/spec/spec.xhr.js
CHANGED
@@ -1,15 +1,24 @@
|
|
1
1
|
|
2
2
|
describe 'JSpec'
|
3
3
|
describe '.mockRequest'
|
4
|
+
before
|
5
|
+
responseFrom = function(path) {
|
6
|
+
request = new XMLHttpRequest
|
7
|
+
request.open('POST', path, false)
|
8
|
+
request.send(null)
|
9
|
+
return request.responseText
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
4
13
|
it 'should mock XMLHttpRequests if unmockRequest() is called or the spec block has finished'
|
14
|
+
original = XMLHttpRequest
|
5
15
|
mockRequest().and_return('test')
|
6
|
-
XMLHttpRequest.should.
|
16
|
+
XMLHttpRequest.should.not.equal original
|
7
17
|
unmockRequest()
|
8
|
-
XMLHttpRequest.should.
|
18
|
+
XMLHttpRequest.should.equal original
|
9
19
|
end
|
10
20
|
|
11
21
|
it 'should restore original XMLHttpRequest constructor after each spec'
|
12
|
-
XMLHttpRequest.should.eql JSpec.defaultXMLHttpRequest
|
13
22
|
XMLHttpRequest.should.not.eql JSpec.XMLHttpRequest
|
14
23
|
end
|
15
24
|
|
@@ -21,7 +30,7 @@ describe 'JSpec'
|
|
21
30
|
request.send('foo=bar')
|
22
31
|
end
|
23
32
|
|
24
|
-
it 'should allow setting
|
33
|
+
it 'should allow setting response status'
|
25
34
|
mockRequest().and_return('bar', 'text/plain', 404)
|
26
35
|
request = new XMLHttpRequest
|
27
36
|
request.open('GET', 'path', false)
|
@@ -127,7 +136,14 @@ describe 'JSpec'
|
|
127
136
|
mockRequest().and_return('bar', 'text/plain', 200)
|
128
137
|
request.open('HEAD', 'path', false)
|
129
138
|
request.send(null)
|
130
|
-
request.
|
139
|
+
request.responseText.should.be_null
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe 'with uri'
|
144
|
+
it 'should mock only the uri specified'
|
145
|
+
mockRequest('ilike').and_return('cookies')
|
146
|
+
responseFrom('async').should.eql 'cookies'
|
131
147
|
end
|
132
148
|
end
|
133
149
|
end
|
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.8.
|
4
|
+
version: 2.8.3
|
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-07-
|
12
|
+
date: 2009-07-30 00:00:00 -07:00
|
13
13
|
default_executable: jspec
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- spec/fixtures/test.xml
|
78
78
|
- spec/modules.js
|
79
79
|
- spec/spec.dom.html
|
80
|
+
- spec/spec.fixtures.js
|
80
81
|
- spec/spec.grammar-less.js
|
81
82
|
- spec/spec.grammar.js
|
82
83
|
- spec/spec.jquery.js
|