mattpuchlerz-jspec 2.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/History.rdoc +513 -0
  2. data/Manifest +57 -0
  3. data/README.rdoc +825 -0
  4. data/Rakefile +75 -0
  5. data/bin/jspec +305 -0
  6. data/jspec.gemspec +44 -0
  7. data/lib/images/bg.png +0 -0
  8. data/lib/images/hr.png +0 -0
  9. data/lib/images/loading.gif +0 -0
  10. data/lib/images/sprites.bg.png +0 -0
  11. data/lib/images/sprites.png +0 -0
  12. data/lib/images/vr.png +0 -0
  13. data/lib/jspec.css +145 -0
  14. data/lib/jspec.jquery.js +71 -0
  15. data/lib/jspec.js +1771 -0
  16. data/lib/jspec.shell.js +36 -0
  17. data/lib/jspec.timers.js +84 -0
  18. data/lib/jspec.xhr.js +183 -0
  19. data/server/browsers.rb +228 -0
  20. data/server/helpers.rb +82 -0
  21. data/server/routes.rb +57 -0
  22. data/server/server.rb +88 -0
  23. data/spec/async +1 -0
  24. data/spec/env.js +695 -0
  25. data/spec/fixtures/test.html +1 -0
  26. data/spec/fixtures/test.json +1 -0
  27. data/spec/fixtures/test.xml +5 -0
  28. data/spec/helpers.js +66 -0
  29. data/spec/server.rb +2 -0
  30. data/spec/spec.dom.html +34 -0
  31. data/spec/spec.fixtures.js +18 -0
  32. data/spec/spec.grammar-less.js +34 -0
  33. data/spec/spec.grammar.js +226 -0
  34. data/spec/spec.jquery.js +176 -0
  35. data/spec/spec.jquery.xhr.js +35 -0
  36. data/spec/spec.js +166 -0
  37. data/spec/spec.matchers.js +493 -0
  38. data/spec/spec.modules.js +67 -0
  39. data/spec/spec.node.js +46 -0
  40. data/spec/spec.rhino.js +17 -0
  41. data/spec/spec.server.html +29 -0
  42. data/spec/spec.shared-behaviors.js +80 -0
  43. data/spec/spec.utils.js +279 -0
  44. data/spec/spec.xhr.js +156 -0
  45. data/templates/default/History.md +4 -0
  46. data/templates/default/README.md +30 -0
  47. data/templates/default/lib/yourlib.js +2 -0
  48. data/templates/default/spec/server.rb +4 -0
  49. data/templates/default/spec/spec.dom.html +20 -0
  50. data/templates/default/spec/spec.rhino.js +9 -0
  51. data/templates/default/spec/spec.server.html +16 -0
  52. data/templates/default/spec/yourlib_spec.js +11 -0
  53. data/templates/rails/server.rb +4 -0
  54. data/templates/rails/spec.application.js +8 -0
  55. data/templates/rails/spec.dom.html +20 -0
  56. data/templates/rails/spec.rhino.js +8 -0
  57. data/templates/rails/spec.server.html +16 -0
  58. metadata +166 -0
@@ -0,0 +1,156 @@
1
+
2
+ describe 'JSpec'
3
+ describe 'Mock XHR'
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
+
13
+ it 'should provide snake DSL methods'
14
+ mock_request.should.equal mockRequest
15
+ unmock_request.should.equal unmockRequest
16
+ end
17
+
18
+ it 'should mock XMLHttpRequests if unmockRequest() is called or the spec block has finished'
19
+ original = XMLHttpRequest
20
+ mockRequest().and_return('test')
21
+ XMLHttpRequest.should.not.equal original
22
+ unmockRequest()
23
+ XMLHttpRequest.should.equal original
24
+ end
25
+
26
+ it 'should restore original XMLHttpRequest constructor after each spec'
27
+ XMLHttpRequest.should.not.eql JSpec.XMLHttpRequest
28
+ end
29
+
30
+ describe 'mock response'
31
+ before_each
32
+ mockRequest().and_return('bar', 'text/plain', 200, { 'x-foo' : 'bar' })
33
+ request = new XMLHttpRequest
34
+ request.open('GET', 'path', false, 'foo', 'bar')
35
+ request.send('foo=bar')
36
+ end
37
+
38
+ it 'should allow setting response status'
39
+ mockRequest().and_return('bar', 'text/plain', 404)
40
+ request = new XMLHttpRequest
41
+ request.open('GET', 'path', false)
42
+ request.send(null)
43
+ request.status.should.eql 404
44
+ request.statusText.should.eql 'Not Found'
45
+ end
46
+
47
+ it 'should default readyState to 0'
48
+ request = new XMLHttpRequest
49
+ request.readyState.should.eql 0
50
+ end
51
+
52
+ it 'should populate user'
53
+ request.user.should.eql 'foo'
54
+ end
55
+
56
+ it 'should populate password'
57
+ request.password.should.eql 'bar'
58
+ end
59
+
60
+ it 'should populate method'
61
+ request.method.should.eql 'GET'
62
+ end
63
+
64
+ it 'should populate readyState'
65
+ request.readyState.should.eql 4
66
+ end
67
+
68
+ it 'should populate url'
69
+ request.url.should.eql 'path'
70
+ end
71
+
72
+ it 'should populate status'
73
+ request.status.should.eql 200
74
+ end
75
+
76
+ it 'should populate statusText'
77
+ request.statusText.should.eql 'OK'
78
+ end
79
+
80
+ it 'should populate content type response header'
81
+ request.getResponseHeader('Content-Type').should.eql 'text/plain'
82
+ end
83
+
84
+ it 'should populate Content-Length response header'
85
+ request.getResponseHeader('Content-Length').should.eql 3
86
+ end
87
+
88
+ it 'should populate data'
89
+ request.data.should.eql 'foo=bar'
90
+ end
91
+
92
+ it 'should populate responseText'
93
+ request.responseText.should.eql 'bar'
94
+ end
95
+
96
+ it 'should populate headers'
97
+ request.getResponseHeader('X-Foo').should.eql 'bar'
98
+ end
99
+
100
+ it 'should not interrupt JSpec request related functionality'
101
+ mockRequest().and_return('fail')
102
+ (JSpec.tryLoading('async') || JSpec.tryLoading('spec/async')).should.eql 'cookies!'
103
+ fixture('test').should.eql '<p>test</p>'
104
+ fixture('test.json').should.include '{ user'
105
+ end
106
+
107
+ describe '.onreadystatechange()'
108
+ before_each
109
+ mockRequest().and_return('bar', 'text/plain', 200)
110
+ request = new XMLHttpRequest
111
+ end
112
+
113
+ it 'should be called when opening request in context to the request'
114
+ request.onreadystatechange = function(){
115
+ this.readyState.should.eql 1
116
+ }
117
+ request.open('GET', 'path')
118
+ end
119
+
120
+ it 'should be called when sending request'
121
+ request.open('GET', 'path')
122
+ request.onreadystatechange = function(){
123
+ this.readyState.should.eql 4
124
+ }
125
+ request.send(null)
126
+ end
127
+ end
128
+
129
+ describe '.setRequestHeader()'
130
+ it 'should set request headers'
131
+ mockRequest().and_return('bar', 'text/plain', 200)
132
+ request.open('GET', 'path', false, 'foo', 'bar')
133
+ request.setRequestHeader('Accept', 'foo')
134
+ request.send(null)
135
+ request.requestHeaders['accept'].should.eql 'foo'
136
+ end
137
+ end
138
+
139
+ describe 'HEAD'
140
+ it 'should respond with headers only'
141
+ mockRequest().and_return('bar', 'text/plain', 200)
142
+ request.open('HEAD', 'path', false)
143
+ request.send(null)
144
+ request.responseText.should.be_null
145
+ end
146
+ end
147
+
148
+ describe 'with uri'
149
+ it 'should mock only the uri specified'
150
+ mockRequest('ilike').and_return('cookies')
151
+ responseFrom('async').should.eql 'cookies'
152
+ end
153
+ end
154
+ end
155
+ end
156
+ end
@@ -0,0 +1,4 @@
1
+ 0.0.1 / YYYY-MM-DD
2
+ ------------------
3
+
4
+ * Initial release
@@ -0,0 +1,30 @@
1
+ YourLib
2
+ =======
3
+
4
+ Description
5
+
6
+ License
7
+ -------
8
+
9
+ (The MIT License)
10
+
11
+ Copyright (c) 2009 Your Name <Your Email>
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining
14
+ a copy of this software and associated documentation files (the
15
+ 'Software'), to deal in the Software without restriction, including
16
+ without limitation the rights to use, copy, modify, merge, publish,
17
+ distribute, sublicense, and/or sell copies of the Software, and to
18
+ permit persons to whom the Software is furnished to do so, subject to
19
+ the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be
22
+ included in all copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
25
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
27
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
28
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+
2
+ // Your library here
@@ -0,0 +1,4 @@
1
+
2
+ get '/lib/*' do |path|
3
+ send_file File.dirname(__FILE__) + '/../lib/' + path
4
+ end
@@ -0,0 +1,20 @@
1
+ <html>
2
+ <head>
3
+ <link type="text/css" rel="stylesheet" href="JSPEC_ROOT/lib/jspec.css" />
4
+ <script src="JSPEC_ROOT/lib/jspec.js"></script>
5
+ <script src="../lib/yourlib.js"></script>
6
+ <script>
7
+ function runSuites() {
8
+ JSpec
9
+ .exec('yourlib_spec.js')
10
+ .run()
11
+ .report()
12
+ }
13
+ </script>
14
+ </head>
15
+ <body class="jspec" onLoad="runSuites();">
16
+ <div id="jspec-top"><h2 id="jspec-title">JSpec <em><script>document.write(JSpec.version)</script></em></h2></div>
17
+ <div id="jspec"></div>
18
+ <div id="jspec-bottom"></div>
19
+ </body>
20
+ </html>
@@ -0,0 +1,9 @@
1
+
2
+ load('JSPEC_ROOT/spec/env.js')
3
+ load('JSPEC_ROOT/spec/lib/jspec.js')
4
+ load('lib/yourlib.js')
5
+
6
+ JSpec
7
+ .exec('spec/yourlib_spec.js')
8
+ .run({ formatter: JSpec.formatters.Terminal, failuresOnly: true })
9
+ .report()
@@ -0,0 +1,16 @@
1
+ <html>
2
+ <head>
3
+ <script src="/jspec/jspec.js"></script>
4
+ <script src="/lib/yourlib.js"></script>
5
+ <script>
6
+ function runSuites() {
7
+ JSpec
8
+ .exec('yourlib_spec.js')
9
+ .run({ formatter: JSpec.formatters.Server, verbose: true, failuresOnly: true })
10
+ .report()
11
+ }
12
+ </script>
13
+ </head>
14
+ <body class="jspec" onLoad="runSuites();">
15
+ </body>
16
+ </html>
@@ -0,0 +1,11 @@
1
+ describe 'YourLib'
2
+
3
+ describe 'some additional context'
4
+
5
+ it 'should do something'
6
+ true.should.be true
7
+ end
8
+
9
+ end
10
+
11
+ end
@@ -0,0 +1,4 @@
1
+
2
+ get '/public/*' do |path|
3
+ send_file File.dirname(__FILE__) + '/../public/' + path
4
+ end
@@ -0,0 +1,8 @@
1
+
2
+ describe 'YourLib'
3
+ describe '.someMethod()'
4
+ it 'should do something'
5
+ true.should.be true
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ <html>
2
+ <head>
3
+ <link type="text/css" rel="stylesheet" href="JSPEC_ROOT/lib/jspec.css" />
4
+ <script src="JSPEC_ROOT/lib/jspec.js"></script>
5
+ <script src="../public/javascripts/application.js"></script>
6
+ <script>
7
+ function runSuites() {
8
+ JSpec
9
+ .exec('spec.application.js')
10
+ .run()
11
+ .report()
12
+ }
13
+ </script>
14
+ </head>
15
+ <body class="jspec" onLoad="runSuites();">
16
+ <div id="jspec-top"><h2 id="jspec-title">JSpec <em><script>document.write(JSpec.version)</script></em></h2></div>
17
+ <div id="jspec"></div>
18
+ <div id="jspec-bottom"></div>
19
+ </body>
20
+ </html>
@@ -0,0 +1,8 @@
1
+
2
+ load('JSPEC_ROOT/lib/jspec.js')
3
+ load('public/javascripts/application.js')
4
+
5
+ JSpec
6
+ .exec('spec/spec.application.js')
7
+ .run({ formatter : JSpec.formatters.Terminal })
8
+ .report()
@@ -0,0 +1,16 @@
1
+ <html>
2
+ <head>
3
+ <script src="/jspec/jspec.js"></script>
4
+ <script src="/public/javascripts/application.js"></script>
5
+ <script>
6
+ function runSuites() {
7
+ JSpec
8
+ .exec('spec.application.js')
9
+ .run({ formatter : JSpec.formatters.Server, verbose: true, failuresOnly: true })
10
+ .report()
11
+ }
12
+ </script>
13
+ </head>
14
+ <body class="jspec" onLoad="runSuites();">
15
+ </body>
16
+ </html>
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mattpuchlerz-jspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.11.0
5
+ platform: ruby
6
+ authors:
7
+ - TJ Holowaychuk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-10 00:00:00 -07:00
13
+ default_executable: jspec
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: sinatra
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: visionmedia-commander
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 3.2.9
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: visionmedia-bind
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 0.2.6
54
+ version:
55
+ description: JavaScript BDD Testing Framework
56
+ email: tj@vision-media.ca
57
+ executables:
58
+ - jspec
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - README.rdoc
63
+ - bin/jspec
64
+ - lib/images/bg.png
65
+ - lib/images/hr.png
66
+ - lib/images/loading.gif
67
+ - lib/images/sprites.bg.png
68
+ - lib/images/sprites.png
69
+ - lib/images/vr.png
70
+ - lib/jspec.css
71
+ - lib/jspec.jquery.js
72
+ - lib/jspec.js
73
+ - lib/jspec.shell.js
74
+ - lib/jspec.timers.js
75
+ - lib/jspec.xhr.js
76
+ files:
77
+ - History.rdoc
78
+ - Manifest
79
+ - README.rdoc
80
+ - Rakefile
81
+ - bin/jspec
82
+ - jspec.gemspec
83
+ - lib/images/bg.png
84
+ - lib/images/hr.png
85
+ - lib/images/loading.gif
86
+ - lib/images/sprites.bg.png
87
+ - lib/images/sprites.png
88
+ - lib/images/vr.png
89
+ - lib/jspec.css
90
+ - lib/jspec.jquery.js
91
+ - lib/jspec.js
92
+ - lib/jspec.shell.js
93
+ - lib/jspec.timers.js
94
+ - lib/jspec.xhr.js
95
+ - server/browsers.rb
96
+ - server/helpers.rb
97
+ - server/routes.rb
98
+ - server/server.rb
99
+ - spec/async
100
+ - spec/env.js
101
+ - spec/fixtures/test.html
102
+ - spec/fixtures/test.json
103
+ - spec/fixtures/test.xml
104
+ - spec/helpers.js
105
+ - spec/server.rb
106
+ - spec/spec.dom.html
107
+ - spec/spec.fixtures.js
108
+ - spec/spec.grammar-less.js
109
+ - spec/spec.grammar.js
110
+ - spec/spec.jquery.js
111
+ - spec/spec.jquery.xhr.js
112
+ - spec/spec.js
113
+ - spec/spec.matchers.js
114
+ - spec/spec.modules.js
115
+ - spec/spec.node.js
116
+ - spec/spec.rhino.js
117
+ - spec/spec.server.html
118
+ - spec/spec.shared-behaviors.js
119
+ - spec/spec.utils.js
120
+ - spec/spec.xhr.js
121
+ - templates/default/History.md
122
+ - templates/default/README.md
123
+ - templates/default/lib/yourlib.js
124
+ - templates/default/spec/server.rb
125
+ - templates/default/spec/yourlib_spec.js
126
+ - templates/default/spec/spec.dom.html
127
+ - templates/default/spec/spec.rhino.js
128
+ - templates/default/spec/spec.server.html
129
+ - templates/rails/server.rb
130
+ - templates/rails/spec.application.js
131
+ - templates/rails/spec.dom.html
132
+ - templates/rails/spec.rhino.js
133
+ - templates/rails/spec.server.html
134
+ has_rdoc: false
135
+ homepage: http://visionmedia.github.com/jspec
136
+ post_install_message:
137
+ rdoc_options:
138
+ - --line-numbers
139
+ - --inline-source
140
+ - --title
141
+ - Jspec
142
+ - --main
143
+ - README.rdoc
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: "0"
151
+ version:
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: "1.2"
157
+ version:
158
+ requirements: []
159
+
160
+ rubyforge_project: jspec
161
+ rubygems_version: 1.2.0
162
+ signing_key:
163
+ specification_version: 3
164
+ summary: JavaScript BDD Testing Framework
165
+ test_files: []
166
+