visionmedia-jspec 2.7.2 → 2.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,4 +1,20 @@
1
1
 
2
+ === 2.8.1 / 2009-07-27
3
+
4
+ * Added Lawrence Pit as a contributor
5
+ * Fixed object hash equality [#146]
6
+ { a : '1', b : '2' } is now the same as:
7
+ { b : '2', a : '1' }
8
+
9
+ === 2.8.0 / 2009-07-27
10
+
11
+ * Give readFile precendence over xhr so that fixtures work with mockRequest when using Rhino
12
+ * Give XMLHttpRequest precedence over microsoft crap
13
+ * Added Mock Ajax Support
14
+ * Added mockRequest(), unmockRequest() utilities
15
+ * Added jspec.xhr.js
16
+ * Fixed be_visible, and be_hidden. Now implement the jQuery <= 1.3.1 method
17
+
2
18
  === 2.7.2 / 2009-07-24
3
19
 
4
20
  * Fixed "end" in spec bodies when using the grammar
data/Manifest CHANGED
@@ -10,6 +10,7 @@ lib/images/vr.png
10
10
  lib/jspec.css
11
11
  lib/jspec.jquery.js
12
12
  lib/jspec.js
13
+ lib/jspec.xhr.js
13
14
  Manifest
14
15
  Rakefile
15
16
  README.rdoc
@@ -25,6 +26,7 @@ spec/spec.dom.html
25
26
  spec/spec.grammar-less.js
26
27
  spec/spec.grammar.js
27
28
  spec/spec.jquery.js
29
+ spec/spec.jquery.xhr.js
28
30
  spec/spec.js
29
31
  spec/spec.matchers.js
30
32
  spec/spec.modules.js
@@ -33,6 +35,7 @@ spec/spec.rhino.js
33
35
  spec/spec.server.html
34
36
  spec/spec.shared-behaviors.js
35
37
  spec/spec.utils.js
38
+ spec/spec.xhr.js
36
39
  templates/default/History.rdoc
37
40
  templates/default/lib/yourlib.core.js
38
41
  templates/default/README.rdoc
data/README.rdoc CHANGED
@@ -11,6 +11,7 @@ and much more.
11
11
  * Highly readable
12
12
  * Framework / DOM independent
13
13
  * Modular via JSpec Module's and hooks
14
+ * Mock Ajax Requests
14
15
  * Rhino support
15
16
  * Node.js support
16
17
  * Async support
@@ -242,6 +243,8 @@ on any object when using the JSpec grammar:
242
243
  * Core
243
244
 
244
245
  - an_instance_of used in conjunction with the 'receive' matcher
246
+ - mockRequest mock a request (requires jspec.xhr.js)
247
+ - unmockRequest unmock requests (requests jspec.xhr.js)
245
248
 
246
249
  * jQuery
247
250
 
@@ -281,6 +284,29 @@ common functionality. For example an Admin, would inherit all specs of User:
281
284
 
282
285
  NOTE: both User and Administrator's before hooks implement the 'user' variable
283
286
 
287
+ == Mock Ajax Requests
288
+
289
+ JSpec supports generic Ajax mocking which is usable with any JavaScript framework via 'jspec.xhr.js'. The
290
+ API is comprised of two functions, mockRequest() and unmockRequest(). unmockRequest() is
291
+ automatically called after each specification to restore the default functionality of XMLHttpRequest,
292
+ so it is uncommon to call unmockRequest() directly. Below is a jQuery example:
293
+
294
+ it 'should mock requests'
295
+ mockRequest().and_return('{ foo : "bar" }', 'application/json')
296
+ $.getJSON('foo', function(response, statusText){
297
+ response.foo.should.eql 'bar'
298
+ })
299
+ end
300
+
301
+ The mockRequest().and_return signature is as follows:
302
+
303
+ mockRequest().and_return(<data>, [content-type], [response-status-code], [headers-hash])
304
+
305
+ At the moment mockRequest() itself does not accept any arguments, however in the future
306
+ this will be used to target specific uris for mocking.
307
+
308
+ NOTE: works with Rhino as well
309
+
284
310
  == Hooks
285
311
 
286
312
  Currently the following hooks are supported, and may be utilized any number of times as they
@@ -397,6 +423,39 @@ where as 'spec/fixtures/xml/data.xml' must be specified with fixture('xml/data.x
397
423
  If you prefer not to store fixtures in the 'fixtures' directory you must be more specific
398
424
  with the path supplied.
399
425
 
426
+ == Testing DOM Elements
427
+
428
+ When using jQuery testing DOM elements is very easy. Many may think they require specific
429
+ sandbox divs in their html, however you do not. Using the fixture support mentioned above
430
+ you may simply load some HTML, and use the 'elements()' utility which is an alias of jQuery:
431
+
432
+ describe 'JSpec DOM testing'
433
+ describe 'is so easy'
434
+ before_each
435
+ list = elements(fixture('users-list'))
436
+ // or list = jQuery(fixture('users-list'))
437
+ // or list = $(fixture('users-list'))
438
+ end
439
+
440
+ it 'should have users'
441
+ list.should.have_tag 'ul'
442
+ end
443
+ end
444
+ end
445
+
446
+ You may also use simple strings, since jQuery's constructor will convert them to DOM elements:
447
+
448
+ describe 'Something'
449
+ before_each
450
+ html = elements('<p>Foo</p>')
451
+ // or html = $('<p>Foo</p>') ...
452
+ end
453
+
454
+ it 'should do something'
455
+ html.should.have_text 'Foo'
456
+ end
457
+ end
458
+
400
459
  == Custom Matchers
401
460
 
402
461
  First lets create a simple equality matcher. In the case below JSpec is smart enough to realize
@@ -632,6 +691,7 @@ Many ideas and bug reports were contributed by
632
691
  the following developers, thankyou for making
633
692
  JSpec more enjoyable, and bug free ;)
634
693
 
694
+ * Lawrence Pit
635
695
  * mpd@jesters-court.ne
636
696
  * kevin.gisi@gmail.com
637
697
  * enno84@gmx.net
data/bin/jspec CHANGED
@@ -11,7 +11,7 @@ require 'fileutils'
11
11
  RHINO = 'java org.mozilla.javascript.tools.shell.Main'
12
12
 
13
13
  program :name, 'JSpec'
14
- program :version, '2.7.2'
14
+ program :version, '2.8.1'
15
15
  program :description, 'JavaScript BDD Testing Framework'
16
16
  default_command :bind
17
17
 
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.7.2"
5
+ s.version = "2.8.1"
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-24}
9
+ s.date = %q{2009-07-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", "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", "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.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", "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"]
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"]
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
@@ -32,10 +32,18 @@ JSpec
32
32
  have_children : "jQuery(actual).children(expected).length > 1",
33
33
  have_text : "jQuery(actual).text() == expected",
34
34
  have_value : "jQuery(actual).val() == expected",
35
- be_visible : "!jQuery(actual).is(':hidden')",
36
- be_hidden : "jQuery(actual).is(':hidden')",
37
35
  be_enabled : "!jQuery(actual).attr('disabled')",
38
36
  have_class : "jQuery(actual).hasClass(expected)",
37
+
38
+ be_visible : function(actual) {
39
+ return jQuery(actual).css('display') != 'none' &&
40
+ jQuery(actual).css('visibility') != 'hidden' &&
41
+ jQuery(actual).attr('type') != 'hidden'
42
+ },
43
+
44
+ be_hidden : function(actual) {
45
+ return !JSpec.does(actual, 'be_visible')
46
+ },
39
47
 
40
48
  have_classes : function(actual) {
41
49
  return !JSpec.any(JSpec.argumentsToArray(arguments, 1), function(arg){
data/lib/jspec.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  JSpec = {
7
7
 
8
- version : '2.7.2',
8
+ version : '2.8.1',
9
9
  cache : {},
10
10
  suites : [],
11
11
  modules : [],
@@ -844,10 +844,12 @@
844
844
  }
845
845
  switch (object.constructor) {
846
846
  case Array : return serialize('a')
847
- case Object: return serialize('o')
848
847
  case RegExp: return 'r:' + object.toString()
849
848
  case Number: return 'n:' + object.toString()
850
849
  case String: return 's:' + object.toString()
850
+ case Object: return 'o:' + inject(object, [], function(array, key, value){
851
+ array.push([key, hash(value)])
852
+ }).sort()
851
853
  default: return object.toString()
852
854
  }
853
855
  },
@@ -1469,9 +1471,9 @@
1469
1471
  */
1470
1472
 
1471
1473
  xhr : function() {
1472
- return 'ActiveXObject' in main ?
1473
- new ActiveXObject("Microsoft.XMLHTTP"):
1474
- new XMLHttpRequest()
1474
+ return 'XMLHttpRequest' in main ?
1475
+ new XMLHttpRequest:
1476
+ new ActiveXObject("Microsoft.XMLHTTP")
1475
1477
  },
1476
1478
 
1477
1479
  /**
@@ -1496,14 +1498,14 @@
1496
1498
 
1497
1499
  load : function(file, callback) {
1498
1500
  if (any(hook('loading', file), haveStopped)) return
1499
- if (this.hasXhr()) {
1501
+ if ('readFile' in main)
1502
+ return callback ? readFile(file, callback) : readFile(file)
1503
+ else if (this.hasXhr()) {
1500
1504
  var request = this.xhr()
1501
1505
  request.open('GET', file, false)
1502
1506
  request.send(null)
1503
1507
  if (request.readyState == 4) return request.responseText
1504
1508
  }
1505
- else if ('readFile' in main)
1506
- return callback ? readFile(file, callback) : readFile(file)
1507
1509
  else
1508
1510
  error("failed to load `" + file + "'")
1509
1511
  },
data/lib/jspec.xhr.js ADDED
@@ -0,0 +1,121 @@
1
+
2
+ // JSpec - XHR - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
3
+
4
+ JSpec.defaultXMLHttpRequest = 'XMLHttpRequest' in this ? XMLHttpRequest : function(){}
5
+ JSpec.XMLHttpRequest = function(){ this.requestHeaders = {} }
6
+ JSpec.XMLHttpRequest.status = {
7
+ 100 : 'Continue',
8
+ 101 : 'Switching Protocols',
9
+ 200 : 'OK',
10
+ 201 : 'Created',
11
+ 202 : 'Accepted',
12
+ 203 : 'Non-Authoritative Information',
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
+ }
49
+
50
+ JSpec.XMLHttpRequest.prototype = {
51
+ status : 0,
52
+ async : true,
53
+ readyState : 0,
54
+ responseText : '',
55
+ abort : function(){},
56
+ onreadystatechange : function(){},
57
+
58
+ getAllResponseHeaders : function(){
59
+ return this.responseHeaders
60
+ },
61
+
62
+ getResponseHeader : function(name) {
63
+ return this.responseHeaders[name.toLowerCase()]
64
+ },
65
+
66
+ setRequestHeader : function(name, value) {
67
+ this.requestHeaders[name.toLowerCase()] = value
68
+ },
69
+
70
+ open : function(method, url, async, user, password) {
71
+ this.user = user
72
+ this.password = password
73
+ this.url = url
74
+ this.readyState = 1
75
+ this.method = method.toUpperCase()
76
+ if (async != undefined) this.async = async
77
+ if (this.async) this.onreadystatechange()
78
+ },
79
+
80
+ send : function(data) {
81
+ this.data = data
82
+ this.readyState = 4
83
+ if (this.method == 'HEAD') this.body = null
84
+ this.responseHeaders['content-length'] = (this.responseText || '').length
85
+ if(this.async) this.onreadystatechange()
86
+ }
87
+ }
88
+
89
+ function unmockRequest() {
90
+ XMLHttpRequest = JSpec.defaultXMLHttpRequest
91
+ }
92
+
93
+ JSpec.include({
94
+
95
+ // --- Utilities
96
+
97
+ utilities : {
98
+ mockRequest : function(){
99
+ return { and_return : function(body, type, status, headers) {
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
+ }}
111
+ },
112
+ unmockRequest : unmockRequest
113
+ },
114
+
115
+ // --- Hooks
116
+
117
+ afterSpec : function() {
118
+ unmockRequest()
119
+ }
120
+
121
+ })
data/spec/spec.dom.html CHANGED
@@ -1,9 +1,10 @@
1
1
  <html>
2
2
  <head>
3
3
  <link type="text/css" rel="stylesheet" href="../lib/jspec.css" />
4
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
4
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
5
5
  <script src="../lib/jspec.js"></script>
6
6
  <script src="../lib/jspec.jquery.js"></script>
7
+ <script src="../lib/jspec.xhr.js"></script>
7
8
  <script src="modules.js"></script>
8
9
  <script src="spec.grammar-less.js"></script>
9
10
  <script>
@@ -16,6 +17,8 @@
16
17
  .exec('spec.shared-behaviors.js')
17
18
  .exec('spec.jquery.js')
18
19
  .exec('spec.modules.js')
20
+ .exec('spec.xhr.js')
21
+ .exec('spec.jquery.xhr.js')
19
22
  .run()
20
23
  .report()
21
24
  }
@@ -0,0 +1,28 @@
1
+
2
+ describe 'jQuery'
3
+ describe '.getJSON()'
4
+ it 'should work with mockRequest'
5
+ mockRequest().and_return('{ foo : "bar" }')
6
+ $.getJSON('foo', function(response, statusText){
7
+ response.foo.should.eql 'bar'
8
+ statusText.should.eql 'success'
9
+ })
10
+ end
11
+
12
+ it 'should not invoke callback when response status is 4xx'
13
+ mockRequest().and_return('foo', 'text/plain', 404)
14
+ $.getJSON('foo', function(){
15
+ fail('callback was invoked')
16
+ })
17
+ end
18
+ end
19
+
20
+ describe '.post()'
21
+ it 'should work with mockRequest'
22
+ mockRequest().and_return('<p></p>', 'text/html')
23
+ $.post('foo', function(response){
24
+ response.should.eql '<p></p>'
25
+ })
26
+ end
27
+ end
28
+ end
@@ -27,6 +27,12 @@ describe 'Matchers'
27
27
  { foo : 'bar' }.should.eql { foo : 'bar' }
28
28
  end
29
29
 
30
+ it 'should hash compare objects with different orders'
31
+ a = { one : 'two', three : 'four' }
32
+ b = { three : 'four', one : 'two' }
33
+ a.should.eql b
34
+ end
35
+
30
36
  it 'should hash compare arbitrary objects'
31
37
  Foo = function(){}, Bar = function(){}
32
38
  Bar.prototype = { doSomething : function(){ }}
data/spec/spec.rhino.js CHANGED
@@ -1,5 +1,6 @@
1
1
 
2
2
  load('lib/jspec.js')
3
+ load('lib/jspec.xhr.js')
3
4
  load('spec/modules.js')
4
5
  load('spec/spec.grammar-less.js')
5
6
 
@@ -10,5 +11,6 @@ JSpec
10
11
  .exec('spec/spec.utils.js')
11
12
  .exec('spec/spec.shared-behaviors.js')
12
13
  .exec('spec/spec.modules.js')
14
+ .exec('spec/spec.xhr.js')
13
15
  .run({ formatter : JSpec.formatters.Terminal, failuresOnly : false })
14
16
  .report()
@@ -3,6 +3,7 @@
3
3
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
4
4
  <script src="jspec.js"></script>
5
5
  <script src="jspec.jquery.js"></script>
6
+ <script src="jspec.xhr.js"></script>
6
7
  <script src="modules.js"></script>
7
8
  <script src="spec.grammar-less.js"></script>
8
9
  <script>
@@ -15,6 +16,8 @@
15
16
  .exec('spec.shared-behaviors.js')
16
17
  .exec('spec.jquery.js')
17
18
  .exec('spec.modules.js')
19
+ .exec('spec.xhr.js')
20
+ .exec('spec.jquery.xhr.js')
18
21
  .run()
19
22
  .reportToServer()
20
23
  }
data/spec/spec.xhr.js ADDED
@@ -0,0 +1,128 @@
1
+
2
+ describe 'JSpec'
3
+ describe '.mockRequest'
4
+ it 'should mock XMLHttpRequests if unmockRequest() is called or the spec block has finished'
5
+ mockRequest().and_return('test')
6
+ XMLHttpRequest.should.eql JSpec.XMLHttpRequest
7
+ unmockRequest()
8
+ XMLHttpRequest.should.not.eql JSpec.XMLHttpRequest
9
+ end
10
+
11
+ it 'should restore original XMLHttpRequest constructor after each spec'
12
+ XMLHttpRequest.should.eql JSpec.defaultXMLHttpRequest
13
+ XMLHttpRequest.should.not.eql JSpec.XMLHttpRequest
14
+ end
15
+
16
+ describe 'mock response'
17
+ before_each
18
+ mockRequest().and_return('bar', 'text/plain', 200, { 'x-foo' : 'bar' })
19
+ request = JSpec.xhr()
20
+ request.open('GET', 'path', false, 'foo', 'bar')
21
+ request.send('foo=bar')
22
+ end
23
+
24
+ it 'should allow setting respose status'
25
+ mockRequest().and_return('bar', 'text/plain', 404)
26
+ request = JSpec.xhr()
27
+ request.open('GET', 'path', false)
28
+ request.send(null)
29
+ request.status.should.eql 404
30
+ request.statusText.should.eql 'Not Found'
31
+ end
32
+
33
+ it 'should default readyState to 0'
34
+ request = JSpec.xhr()
35
+ request.readyState.should.eql 0
36
+ end
37
+
38
+ it 'should populate user'
39
+ request.user.should.eql 'foo'
40
+ end
41
+
42
+ it 'should populate password'
43
+ request.password.should.eql 'bar'
44
+ end
45
+
46
+ it 'should populate method'
47
+ request.method.should.eql 'GET'
48
+ end
49
+
50
+ it 'should populate readyState'
51
+ request.readyState.should.eql 4
52
+ end
53
+
54
+ it 'should populate url'
55
+ request.url.should.eql 'path'
56
+ end
57
+
58
+ it 'should populate status'
59
+ request.status.should.eql 200
60
+ end
61
+
62
+ it 'should populate statusText'
63
+ request.statusText.should.eql 'OK'
64
+ end
65
+
66
+ it 'should populate content type response header'
67
+ request.getResponseHeader('Content-Type').should.eql 'text/plain'
68
+ end
69
+
70
+ it 'should populate Content-Length response header'
71
+ request.getResponseHeader('Content-Length').should.eql 3
72
+ end
73
+
74
+ it 'should populate data'
75
+ request.data.should.eql 'foo=bar'
76
+ end
77
+
78
+ it 'should populate responseText'
79
+ request.responseText.should.eql 'bar'
80
+ end
81
+
82
+ it 'should populate headers'
83
+ request.getResponseHeader('X-Foo').should.eql 'bar'
84
+ end
85
+
86
+ describe '.onreadystatechange()'
87
+ before_each
88
+ mockRequest().and_return('bar', 'text/plain', 200)
89
+ request = JSpec.xhr()
90
+ end
91
+
92
+ it 'should be called when opening request in context to the request'
93
+ request.onreadystatechange = function(){
94
+ this.readyState.should.eql 1
95
+ }
96
+ request.open('GET', 'path')
97
+ end
98
+
99
+ it 'should be called when sending request'
100
+ request.open('GET', 'path')
101
+ request.onreadystatechange = function(){
102
+ this.readyState.should.eql 4
103
+ }
104
+ request.send(null)
105
+ end
106
+ end
107
+
108
+ describe '.setRequestHeader()'
109
+ it 'should set request headers'
110
+ mockRequest().and_return('bar', 'text/plain', 200)
111
+ request.open('GET', 'path', false, 'foo', 'bar')
112
+ request.setRequestHeader('Accept', 'foo')
113
+ request.send(null)
114
+ request.requestHeaders['accept'].should.eql 'foo'
115
+ end
116
+ end
117
+
118
+ describe 'HEAD'
119
+ it 'should respond with headers only'
120
+ mockRequest().and_return('bar', 'text/plain', 200)
121
+ request.open('HEAD', 'path', false)
122
+ request.send(null)
123
+ request.body.should.be_null
124
+ end
125
+ end
126
+ end
127
+ end
128
+ 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.7.2
4
+ version: 2.8.1
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-24 00:00:00 -07:00
12
+ date: 2009-07-27 00:00:00 -07:00
13
13
  default_executable: jspec
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -49,6 +49,7 @@ extra_rdoc_files:
49
49
  - lib/jspec.css
50
50
  - lib/jspec.jquery.js
51
51
  - lib/jspec.js
52
+ - lib/jspec.xhr.js
52
53
  - README.rdoc
53
54
  files:
54
55
  - bin/jspec
@@ -63,6 +64,7 @@ files:
63
64
  - lib/jspec.css
64
65
  - lib/jspec.jquery.js
65
66
  - lib/jspec.js
67
+ - lib/jspec.xhr.js
66
68
  - Manifest
67
69
  - Rakefile
68
70
  - README.rdoc
@@ -78,6 +80,7 @@ files:
78
80
  - spec/spec.grammar-less.js
79
81
  - spec/spec.grammar.js
80
82
  - spec/spec.jquery.js
83
+ - spec/spec.jquery.xhr.js
81
84
  - spec/spec.js
82
85
  - spec/spec.matchers.js
83
86
  - spec/spec.modules.js
@@ -86,6 +89,7 @@ files:
86
89
  - spec/spec.server.html
87
90
  - spec/spec.shared-behaviors.js
88
91
  - spec/spec.utils.js
92
+ - spec/spec.xhr.js
89
93
  - templates/default/History.rdoc
90
94
  - templates/default/lib/yourlib.core.js
91
95
  - templates/default/README.rdoc
@@ -99,6 +103,7 @@ files:
99
103
  - templates/rails/spec.server.html
100
104
  has_rdoc: false
101
105
  homepage: http://visionmedia.github.com/jspec
106
+ licenses:
102
107
  post_install_message:
103
108
  rdoc_options:
104
109
  - --line-numbers
@@ -124,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
129
  requirements: []
125
130
 
126
131
  rubyforge_project: jspec
127
- rubygems_version: 1.2.0
132
+ rubygems_version: 1.3.5
128
133
  signing_key:
129
134
  specification_version: 3
130
135
  summary: JavaScript BDD Testing Framework