jspec-steventux 3.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/History.md +763 -0
  2. data/Manifest +73 -0
  3. data/README.md +974 -0
  4. data/Rakefile +44 -0
  5. data/bin/jspec +178 -0
  6. data/jspec-steventux.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 +149 -0
  14. data/lib/jspec.growl.js +115 -0
  15. data/lib/jspec.jquery.js +72 -0
  16. data/lib/jspec.js +1756 -0
  17. data/lib/jspec.shell.js +39 -0
  18. data/lib/jspec.timers.js +90 -0
  19. data/lib/jspec.xhr.js +195 -0
  20. data/spec/commands/example_command.rb +19 -0
  21. data/spec/dom.html +33 -0
  22. data/spec/fixtures/test.html +1 -0
  23. data/spec/fixtures/test.json +1 -0
  24. data/spec/fixtures/test.xml +5 -0
  25. data/spec/node.js +17 -0
  26. data/spec/rhino.js +23 -0
  27. data/spec/ruby/bin/init_spec.rb +101 -0
  28. data/spec/ruby/bin/install_spec.rb +142 -0
  29. data/spec/ruby/bin/run_spec.rb +0 -0
  30. data/spec/ruby/bin/shell_spec.rb +13 -0
  31. data/spec/ruby/bin/spec_helper.rb +8 -0
  32. data/spec/ruby/bin/update_spec.rb +72 -0
  33. data/spec/server.html +29 -0
  34. data/spec/server.rb +2 -0
  35. data/spec/support/env.js +10118 -0
  36. data/spec/support/jquery.js +4376 -0
  37. data/spec/unit/helpers.js +64 -0
  38. data/spec/unit/spec.fixtures.js +17 -0
  39. data/spec/unit/spec.grammar-less.js +34 -0
  40. data/spec/unit/spec.grammar.js +241 -0
  41. data/spec/unit/spec.jquery.js +178 -0
  42. data/spec/unit/spec.jquery.xhr.js +84 -0
  43. data/spec/unit/spec.js +187 -0
  44. data/spec/unit/spec.matchers.js +577 -0
  45. data/spec/unit/spec.modules.js +51 -0
  46. data/spec/unit/spec.shared-behaviors.js +80 -0
  47. data/spec/unit/spec.utils.js +346 -0
  48. data/spec/unit/spec.xhr.js +157 -0
  49. data/src/browsers.rb +294 -0
  50. data/src/helpers.rb +67 -0
  51. data/src/installables.rb +229 -0
  52. data/src/project.rb +341 -0
  53. data/src/routes.rb +57 -0
  54. data/src/server.rb +99 -0
  55. data/support/js.jar +0 -0
  56. data/templates/default/History.md +5 -0
  57. data/templates/default/Readme.md +29 -0
  58. data/templates/default/lib/yourlib.js +2 -0
  59. data/templates/default/spec/commands/example_command.rb +19 -0
  60. data/templates/default/spec/dom.html +22 -0
  61. data/templates/default/spec/node.js +10 -0
  62. data/templates/default/spec/rhino.js +10 -0
  63. data/templates/default/spec/server.html +18 -0
  64. data/templates/default/spec/server.rb +4 -0
  65. data/templates/default/spec/unit/spec.helper.js +0 -0
  66. data/templates/default/spec/unit/spec.js +8 -0
  67. data/templates/rails/commands/example_commands.rb +19 -0
  68. data/templates/rails/dom.html +22 -0
  69. data/templates/rails/rhino.js +10 -0
  70. data/templates/rails/server.html +18 -0
  71. data/templates/rails/server.rb +4 -0
  72. data/templates/rails/unit/spec.helper.js +0 -0
  73. data/templates/rails/unit/spec.js +8 -0
  74. metadata +185 -0
@@ -0,0 +1,51 @@
1
+
2
+ describe 'JSpec'
3
+ describe 'module'
4
+ describe 'hooks'
5
+ it 'should run beforeSpec'
6
+ addedBeforeSpec.should.be_true
7
+ end
8
+
9
+ it 'should run afterSpec'
10
+ addedAfterSpec.should.be_true
11
+ end
12
+
13
+ describe 'with suites'
14
+ it 'should run beforeSuite'
15
+ addedBeforeSuite.should.be_true
16
+ end
17
+ end
18
+
19
+ it 'should run afterSuite'
20
+ addedAfterSuite.should.be_true
21
+ end
22
+ end
23
+
24
+ describe '.hook()'
25
+ it 'should invoke hooks, returning an array of results'
26
+ results = hook('randomHook', 'foo', 'bar')
27
+ results.should.eql [['foo', 'bar']]
28
+ end
29
+ end
30
+
31
+ describe '.utilities'
32
+ it 'should be merged with the default utilities'
33
+ doFoo().should.eql 'foo'
34
+ doBar().should.eql 'bar'
35
+ end
36
+ end
37
+
38
+ describe '.matchers'
39
+ it 'should be merged with default matchers'
40
+ 'test'.should.be_foo_bar
41
+ end
42
+ end
43
+
44
+ describe '.DSLs'
45
+ it 'should be merged with default DSLs'
46
+ JSpec.DSLs.snake.some_snake_case_stuff().should.be_true
47
+ JSpec.DSLs.camel.someCamelCaseStuff().should.be_true
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,80 @@
1
+
2
+ describe 'Shared Behaviors'
3
+ describe 'User'
4
+ before
5
+ User = function(name) { this.name = name }
6
+ user = new User('joe')
7
+ end
8
+
9
+ it 'should have a name'
10
+ user.should.have_property 'name'
11
+ end
12
+
13
+ describe 'Administrator'
14
+ should_behave_like('User')
15
+
16
+ before
17
+ Admin = function(name) { this.name = name }
18
+ Admin.prototype.may = function(perm){ return true }
19
+ user = new Admin('tj')
20
+ end
21
+
22
+ it 'should have access to all permissions'
23
+ user.may('edit pages').should.be_true
24
+ user.may('delete users').should.be_true
25
+ end
26
+
27
+ describe 'Super Administrator'
28
+ should_behave_like('Administrator')
29
+
30
+ before
31
+ SuperAdmin = function(name) { this.name = name }
32
+ SuperAdmin.prototype.may = function(perm){ return true }
33
+ user = new SuperAdmin('tj')
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ describe 'User with toString()'
40
+ before
41
+ user = { toString : function() { return '<User tj>' }}
42
+ end
43
+
44
+ it 'should return &lt;User NAME&gt;'
45
+ user.toString().should.match(/\<User/)
46
+ end
47
+ end
48
+
49
+ describe 'Manager'
50
+ should_behave_like('User')
51
+ should_behave_like('User with toString()')
52
+
53
+ before
54
+ Manager = function(name) { this.name = name }
55
+ Manager.prototype.may = function(perm){ return perm == 'hire' || perm == 'fire' }
56
+ Manager.prototype.toString = function(){ return '<User ' + this.name + '>' }
57
+ user = new Manager('tj')
58
+ end
59
+
60
+ it 'should have access to hire or fire employees'
61
+ user.may('hire').should.be_true
62
+ user.may('fire').should.be_true
63
+ user.may('do anything else').should.be_false
64
+ end
65
+ end
66
+
67
+ describe 'findSuite'
68
+ it 'should find a suite by full description'
69
+ JSpec.findSuite('Shared Behaviors User Administrator').should.be_a JSpec.Suite
70
+ end
71
+
72
+ it 'should find a suite by name'
73
+ JSpec.findSuite('User').should.be_a JSpec.Suite
74
+ end
75
+
76
+ it 'should return null when not found'
77
+ JSpec.findSuite('Rawr').should.be_null
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,346 @@
1
+
2
+ describe 'Utility'
3
+ describe 'fail()'
4
+ it 'should fail the current spec'
5
+ spec = mock_it(function() {
6
+ fail('I failed!')
7
+ })
8
+ spec.should.have_failure_message('I failed!')
9
+ end
10
+ end
11
+
12
+ describe 'pass()'
13
+ it 'should pass the current spec'
14
+ pass('yay')
15
+ pass('wahoo')
16
+ end
17
+ end
18
+
19
+ describe 'stubbing'
20
+ before_each
21
+ Object.prototype.stubby = function() { return 'Not stubbed' }
22
+ object = { toString : function() { return '<Im an object>' }}
23
+ stub(object, 'stubby').and_return('Im stubbed')
24
+ stub(object, 'toString').and_return('<No im not>')
25
+ end
26
+
27
+ after_each
28
+ delete Object.prototype.stubby
29
+ end
30
+
31
+ describe 'stub()'
32
+ it 'should stub :)'
33
+ object.stubby().should.eql 'Im stubbed'
34
+ object.toString().should.eql '<No im not>'
35
+ end
36
+
37
+ it 'should allow being called as a core prototype method'
38
+ foo = { bar : function(){ return 'baz' }}
39
+ foo.stub('bar').and_return('something else')
40
+ foo.bar().should.eql 'something else'
41
+ foo.destub()
42
+ foo.bar().should.eql 'baz'
43
+ end
44
+
45
+ it 'should stub methods starting with an underscore'
46
+ object._foo = function(){ return 'bar' }
47
+ object.stub('_foo').and_return('something else')
48
+ object._foo().should.eql 'something else'
49
+ object.destub()
50
+ object._foo().should.eql 'bar'
51
+ end
52
+
53
+ it 'should stub methods with whitespace'
54
+ object['foo bar'] = function(){ return 'rawr' }
55
+ object.stub('foo bar').and_return('baz')
56
+ object['foo bar']().should.eql 'baz'
57
+ object.destub()
58
+ object['foo bar']().should.eql 'rawr'
59
+ end
60
+
61
+ it 'should stub with arbitrary method when no return value is set'
62
+ object.stub(' super cool ')
63
+ object[' super cool '].should.be_a Function
64
+ destub(object)
65
+ object[' super cool '].should.be_null
66
+ end
67
+
68
+ it 'should stub sub properties using the JSpec grammar'
69
+ object = { foo : { bar : {}}}
70
+ object.foo.bar.stub('kitten').and_return('meow')
71
+ object.foo.bar.kitten().should.eql 'meow'
72
+ object.foo.bar.destub()
73
+ object.foo.bar.should.not.respond_to('kitten')
74
+ end
75
+
76
+ it 'should allow functions to be passed as a method'
77
+ stub(object, 'post').and_return(function(url, callback){
78
+ if (url == 'http://jspec.info')
79
+ callback('is awesome')
80
+ })
81
+ object.post('http://jspec.info', function(text){
82
+ text.should_eql 'is awesome'
83
+ })
84
+ end
85
+ end
86
+
87
+ describe 'destub()'
88
+ it 'should restore old methods'
89
+ destub(object, 'toString')
90
+ destub(object, 'stubby')
91
+ object.toString().should.eql '<Im an object>'
92
+ object.stubby().should.eql 'Not stubbed'
93
+ end
94
+
95
+ it 'should restore prototypal methods'
96
+ Object.prototype.stubby = function() { return 'Oh no im new' }
97
+ destub(object, 'stubby')
98
+ object.stubby().should.eql 'Oh no im new'
99
+ end
100
+
101
+ it 'should destub all methods stubbed related to the object passed when no method is given'
102
+ destub(object)
103
+ object.toString().should.eql '<Im an object>'
104
+ object.stubby().should.eql 'Not stubbed'
105
+ end
106
+
107
+ describe 'should restore after each spec'
108
+ before
109
+ a = { toString : function(){ return 'Wahoo' }}
110
+ b = { toString : function(){ return 'Wahhhhhooo' }}
111
+ end
112
+
113
+ it 'should stub'
114
+ stub(a, 'toString').and_return('Oh no')
115
+ stub(b, 'toString').and_return('Oh noooo')
116
+ a.toString().should.eql 'Oh no'
117
+ b.toString().should.eql 'Oh noooo'
118
+ end
119
+
120
+ it 'should restore'
121
+ a.toString().should.eql 'Wahoo'
122
+ b.toString().should.eql 'Wahhhhhooo'
123
+ end
124
+ end
125
+ end
126
+ end
127
+
128
+ describe 'query()'
129
+ it 'should return a pairs value'
130
+ query('suite', '?suite=Positive%20specs').should.equal 'Positive specs'
131
+ end
132
+
133
+ it 'should return null when key is not present'
134
+ query('foo', '?suite=Positive%20specs').should.be_null
135
+ end
136
+ end
137
+
138
+ describe 'strip()'
139
+ it 'should strip whitespace by default'
140
+ strip(" foo \n\n").should.equal 'foo'
141
+ end
142
+
143
+ it 'should strip the characters passed'
144
+ strip('[foo]', '\\[\\]').should.equal 'foo'
145
+ end
146
+ end
147
+
148
+ describe 'each()'
149
+ it 'should iterate an array'
150
+ result = []
151
+ each([1,2,3], function(value){
152
+ result.push(value)
153
+ })
154
+ result.should.eql [1,2,3]
155
+ end
156
+ end
157
+
158
+ describe 'map()'
159
+ it 'should return an array of mapped values'
160
+ result = map([1,2,3], function(value){
161
+ return value * 2
162
+ })
163
+ result.should.eql [2,4,6]
164
+ end
165
+ end
166
+
167
+ describe 'inject()'
168
+ it 'should provide a memo object while iterating, not expecting returning of memo for composits'
169
+ result = inject([1,2,3], [], function(memo, value){
170
+ memo.push(value)
171
+ })
172
+ result.should.eql [1,2,3]
173
+ end
174
+
175
+ it 'should require returning of memo for scalar variables'
176
+ result = inject([1,2,3], false, function(memo, value){
177
+ return memo ? memo : value == 2
178
+ })
179
+ result.should.be_true
180
+ end
181
+ end
182
+
183
+ describe 'any()'
184
+ it 'should return null when no matches are found'
185
+ result = any('some foo bar', function(value){
186
+ return value.length > 5
187
+ })
188
+ result.should.be_null
189
+ end
190
+
191
+ it 'should return the value of the first matching expression'
192
+ result = any(['foo', 'some', 'bar'], function(value){
193
+ return value.length > 3
194
+ })
195
+ result.should.eql 'some'
196
+ end
197
+
198
+ describe 'haveStopped'
199
+ it 'should check if "stop" has been returned by a callback hook'
200
+ any([true, 'stop'], haveStopped).should.eql 'stop'
201
+ any([true, true], haveStopped).should.be_null
202
+ any([true, null], haveStopped).should.be_null
203
+ end
204
+ end
205
+ end
206
+
207
+ describe 'select()'
208
+ it 'should return an array of values when the callback evaluates to true'
209
+ result = select(['some', 'foo', 'bar', 'baz', 'stuff'], function(value){
210
+ return value.length > 3
211
+ })
212
+ result.should.eql ['some', 'stuff']
213
+ end
214
+ end
215
+
216
+ describe 'last()'
217
+ it 'should return the last element in an array'
218
+ last(['foo', 'bar']).should.eql 'bar'
219
+ end
220
+ end
221
+
222
+ describe 'toArray()'
223
+ it 'should convert an arraylike object to an array'
224
+ func = function(){ return toArray(arguments) }
225
+ func('foo', 'bar').should.eql ['foo', 'bar']
226
+ end
227
+
228
+ it 'should allow a slice offset'
229
+ func = function(){ return toArray(arguments, 2) }
230
+ func('foo', 'bar', 'baz').should.eql ['baz']
231
+ end
232
+ end
233
+
234
+ describe 'does()'
235
+ it 'should assert without reporting'
236
+ does('foo', 'eql', 'foo')
237
+ JSpec.currentSpec.assertions.should.have_length 0
238
+ end
239
+ end
240
+
241
+ describe 'contentsOf()'
242
+ it 'should return a function body'
243
+ JSpec.contentsOf(-{ return 'foo' }).should.include 'return', 'foo'
244
+ end
245
+ end
246
+
247
+ describe 'puts()'
248
+ describe 'with primitive scalar values'
249
+ it 'should output true'
250
+ puts(true).should.eql 'true'
251
+ end
252
+
253
+ it 'should output false'
254
+ puts(false).should.eql 'false'
255
+ end
256
+
257
+ it 'should output null'
258
+ puts(null).should.eql 'null'
259
+ end
260
+
261
+ it 'should output undefined'
262
+ puts().should.eql 'undefined'
263
+ end
264
+ end
265
+
266
+ describe 'with strings'
267
+ it 'should output within double quotes'
268
+ puts("string").should.eql '"string"'
269
+ end
270
+
271
+ it 'should escape double quotes'
272
+ puts('he said "hey"').should.eql '"he said \\"hey\\""'
273
+ end
274
+
275
+ it 'should output non-printables as \n \t etc'
276
+ puts("\n\t\n\t").should.eql '"\\n\\t\\n\\t"'
277
+ end
278
+ end
279
+
280
+ describe 'with arrays'
281
+ it 'should output an array literal'
282
+ puts([1, 2, 3]).should.eql '[ 1, 2, 3 ]'
283
+ end
284
+
285
+ it 'should output nested arrays'
286
+ puts([1, 2, [ 1, 2 ]]).should.eql '[ 1, 2, [ 1, 2 ] ]'
287
+ end
288
+
289
+ it 'should output empty arrays'
290
+ puts([]).should.eql '[ ]'
291
+ end
292
+ end
293
+
294
+ describe 'with integers'
295
+ it 'should output an integer literal'
296
+ puts(1).should.eql '1'
297
+ puts(10).should.eql '10'
298
+ end
299
+ end
300
+
301
+ describe 'with floats'
302
+ it 'should output a float literal'
303
+ puts(1.5).should.eql '1.5'
304
+ end
305
+ end
306
+
307
+ describe 'with regular expressions'
308
+ it 'should output a regexp literal'
309
+ puts(/test/).should.eql '/test/'
310
+ end
311
+
312
+ it 'should output flags as well'
313
+ puts(/test/gm).should.eql '/test/gm'
314
+ end
315
+ end
316
+
317
+ describe 'with hashes'
318
+ it 'should output an object literal'
319
+ puts({ foo: 'bar' }).should.eql '{ foo: "bar" }'
320
+ end
321
+
322
+ it 'should output nested objects'
323
+ puts({ foo: { bar: 'baz' }}).should.eql '{ foo: { bar: "baz" } }'
324
+ end
325
+
326
+ it 'should output empty objects'
327
+ puts({}).should.eql '{ }'
328
+ end
329
+ end
330
+
331
+ describe 'with an_instance_of'
332
+ it 'should output an instance of Constructor'
333
+ object = { an_instance_of: Array }
334
+ puts(object).should.eql 'an instance of Array'
335
+ end
336
+ end
337
+
338
+ describe 'circular references'
339
+ it 'should output <circular reference> with objects'
340
+ object = { a: 1 }
341
+ object.b = object
342
+ puts(object).should.eql '{ a: 1, b: <circular reference> }'
343
+ end
344
+ end
345
+ end
346
+ end