bootcamp 0.1.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.
Files changed (126) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +14 -0
  5. data/Gemfile.lock +36 -0
  6. data/LICENSE.txt +20 -0
  7. data/NOTES +3 -0
  8. data/README.rdoc +49 -0
  9. data/Rakefile +42 -0
  10. data/VERSION +1 -0
  11. data/bin/bootcamp +8 -0
  12. data/bootcamp.gemspec +190 -0
  13. data/lib/bootcamp.rb +22 -0
  14. data/lib/bootcamp/armory.rb +20 -0
  15. data/lib/bootcamp/drill_instructor.rb +95 -0
  16. data/lib/bootcamp/formations/core.rb +13 -0
  17. data/lib/bootcamp/formations/html.rb +17 -0
  18. data/lib/bootcamp/formations/jquery.rb +13 -0
  19. data/lib/bootcamp/recruit.rb +28 -0
  20. data/spec/bootcamp_spec.rb +12 -0
  21. data/spec/spec_helper.rb +12 -0
  22. data/vendor/core.js +1 -0
  23. data/vendor/dojo.js +14 -0
  24. data/vendor/jquery.js +18 -0
  25. data/vendor/midori.js +1502 -0
  26. data/vendor/mootools.js +486 -0
  27. data/vendor/prototype.js +6082 -0
  28. data/vendor/test_suites/jasmine/SpecRunner.html +27 -0
  29. data/vendor/test_suites/jasmine/lib/jasmine-1.0.2/MIT.LICENSE +20 -0
  30. data/vendor/test_suites/jasmine/lib/jasmine-1.0.2/jasmine-html.js +188 -0
  31. data/vendor/test_suites/jasmine/lib/jasmine-1.0.2/jasmine.css +166 -0
  32. data/vendor/test_suites/jasmine/lib/jasmine-1.0.2/jasmine.js +2421 -0
  33. data/vendor/test_suites/jasmine/spec/PlayerSpec.js +58 -0
  34. data/vendor/test_suites/jasmine/spec/SpecHelper.js +9 -0
  35. data/vendor/test_suites/jasmine/src/Player.js +22 -0
  36. data/vendor/test_suites/jasmine/src/Song.js +7 -0
  37. data/vendor/test_suites/jspec/History.md +790 -0
  38. data/vendor/test_suites/jspec/Manifest +79 -0
  39. data/vendor/test_suites/jspec/README.md +1030 -0
  40. data/vendor/test_suites/jspec/Rakefile +28 -0
  41. data/vendor/test_suites/jspec/bin/jspec +182 -0
  42. data/vendor/test_suites/jspec/jspec.gemspec +44 -0
  43. data/vendor/test_suites/jspec/lib/images/bg.png +0 -0
  44. data/vendor/test_suites/jspec/lib/images/hr.png +0 -0
  45. data/vendor/test_suites/jspec/lib/images/loading.gif +0 -0
  46. data/vendor/test_suites/jspec/lib/images/sprites.bg.png +0 -0
  47. data/vendor/test_suites/jspec/lib/images/sprites.png +0 -0
  48. data/vendor/test_suites/jspec/lib/images/vr.png +0 -0
  49. data/vendor/test_suites/jspec/lib/jspec.css +149 -0
  50. data/vendor/test_suites/jspec/lib/jspec.growl.js +115 -0
  51. data/vendor/test_suites/jspec/lib/jspec.jquery.js +72 -0
  52. data/vendor/test_suites/jspec/lib/jspec.js +1876 -0
  53. data/vendor/test_suites/jspec/lib/jspec.shell.js +39 -0
  54. data/vendor/test_suites/jspec/lib/jspec.timers.js +90 -0
  55. data/vendor/test_suites/jspec/lib/jspec.xhr.js +195 -0
  56. data/vendor/test_suites/jspec/spec/commands/example_command.rb +19 -0
  57. data/vendor/test_suites/jspec/spec/dom.html +33 -0
  58. data/vendor/test_suites/jspec/spec/fixtures/test.html +1 -0
  59. data/vendor/test_suites/jspec/spec/fixtures/test.json +1 -0
  60. data/vendor/test_suites/jspec/spec/fixtures/test.xml +5 -0
  61. data/vendor/test_suites/jspec/spec/node.js +17 -0
  62. data/vendor/test_suites/jspec/spec/rhino.js +23 -0
  63. data/vendor/test_suites/jspec/spec/ruby/bin/init_spec.rb +101 -0
  64. data/vendor/test_suites/jspec/spec/ruby/bin/install_spec.rb +141 -0
  65. data/vendor/test_suites/jspec/spec/ruby/bin/run_spec.rb +0 -0
  66. data/vendor/test_suites/jspec/spec/ruby/bin/shell_spec.rb +13 -0
  67. data/vendor/test_suites/jspec/spec/ruby/bin/spec_helper.rb +8 -0
  68. data/vendor/test_suites/jspec/spec/ruby/bin/update_spec.rb +72 -0
  69. data/vendor/test_suites/jspec/spec/server.html +29 -0
  70. data/vendor/test_suites/jspec/spec/server.rb +2 -0
  71. data/vendor/test_suites/jspec/spec/support/env.js +10118 -0
  72. data/vendor/test_suites/jspec/spec/support/jquery.js +4376 -0
  73. data/vendor/test_suites/jspec/spec/unit/helpers.js +64 -0
  74. data/vendor/test_suites/jspec/spec/unit/spec.fixtures.js +24 -0
  75. data/vendor/test_suites/jspec/spec/unit/spec.grammar-less.js +34 -0
  76. data/vendor/test_suites/jspec/spec/unit/spec.grammar.js +275 -0
  77. data/vendor/test_suites/jspec/spec/unit/spec.jquery.js +178 -0
  78. data/vendor/test_suites/jspec/spec/unit/spec.jquery.xhr.js +84 -0
  79. data/vendor/test_suites/jspec/spec/unit/spec.js +187 -0
  80. data/vendor/test_suites/jspec/spec/unit/spec.matchers.js +577 -0
  81. data/vendor/test_suites/jspec/spec/unit/spec.modules.js +51 -0
  82. data/vendor/test_suites/jspec/spec/unit/spec.shared-behaviors.js +279 -0
  83. data/vendor/test_suites/jspec/spec/unit/spec.utils.js +346 -0
  84. data/vendor/test_suites/jspec/spec/unit/spec.xhr.js +157 -0
  85. data/vendor/test_suites/jspec/src/browsers.rb +279 -0
  86. data/vendor/test_suites/jspec/src/helpers.rb +67 -0
  87. data/vendor/test_suites/jspec/src/installables.rb +229 -0
  88. data/vendor/test_suites/jspec/src/project.rb +341 -0
  89. data/vendor/test_suites/jspec/src/routes.rb +57 -0
  90. data/vendor/test_suites/jspec/src/server.rb +88 -0
  91. data/vendor/test_suites/jspec/support/js.jar +0 -0
  92. data/vendor/test_suites/jspec/templates/default/History.md +5 -0
  93. data/vendor/test_suites/jspec/templates/default/Readme.md +29 -0
  94. data/vendor/test_suites/jspec/templates/default/lib/yourlib.js +2 -0
  95. data/vendor/test_suites/jspec/templates/default/spec/commands/example_command.rb +19 -0
  96. data/vendor/test_suites/jspec/templates/default/spec/dom.html +22 -0
  97. data/vendor/test_suites/jspec/templates/default/spec/node.js +10 -0
  98. data/vendor/test_suites/jspec/templates/default/spec/rhino.js +10 -0
  99. data/vendor/test_suites/jspec/templates/default/spec/server.html +18 -0
  100. data/vendor/test_suites/jspec/templates/default/spec/server.rb +4 -0
  101. data/vendor/test_suites/jspec/templates/default/spec/unit/spec.helper.js +0 -0
  102. data/vendor/test_suites/jspec/templates/default/spec/unit/spec.js +8 -0
  103. data/vendor/test_suites/jspec/templates/node/History.md +5 -0
  104. data/vendor/test_suites/jspec/templates/node/Readme.md +29 -0
  105. data/vendor/test_suites/jspec/templates/node/lib/yourlib.js +2 -0
  106. data/vendor/test_suites/jspec/templates/node/spec/node.js +10 -0
  107. data/vendor/test_suites/jspec/templates/node/spec/unit/spec.helper.js +0 -0
  108. data/vendor/test_suites/jspec/templates/node/spec/unit/spec.js +8 -0
  109. data/vendor/test_suites/jspec/templates/rails/commands/example_commands.rb +19 -0
  110. data/vendor/test_suites/jspec/templates/rails/dom.html +22 -0
  111. data/vendor/test_suites/jspec/templates/rails/rhino.js +10 -0
  112. data/vendor/test_suites/jspec/templates/rails/server.html +18 -0
  113. data/vendor/test_suites/jspec/templates/rails/server.rb +4 -0
  114. data/vendor/test_suites/jspec/templates/rails/unit/spec.helper.js +0 -0
  115. data/vendor/test_suites/jspec/templates/rails/unit/spec.js +8 -0
  116. data/vendor/test_suites/qunit/README.md +24 -0
  117. data/vendor/test_suites/qunit/package.json +21 -0
  118. data/vendor/test_suites/qunit/qunit/qunit.css +225 -0
  119. data/vendor/test_suites/qunit/qunit/qunit.js +1448 -0
  120. data/vendor/test_suites/qunit/test/headless.html +24 -0
  121. data/vendor/test_suites/qunit/test/index.html +19 -0
  122. data/vendor/test_suites/qunit/test/logs.html +17 -0
  123. data/vendor/test_suites/qunit/test/logs.js +150 -0
  124. data/vendor/test_suites/qunit/test/same.js +1421 -0
  125. data/vendor/test_suites/qunit/test/test.js +324 -0
  126. metadata +282 -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,279 @@
1
+ shared_behaviors_for 'animal'
2
+ before
3
+ animal = { eats: function(){ return true } }
4
+ end
5
+
6
+ it 'should eat'
7
+ animal.eats().should.eql true
8
+ end
9
+ end
10
+
11
+ shared_behaviors_for 'canine'
12
+ should_behave_like('animal')
13
+
14
+ before
15
+ animal.hasFourLegs = function(){ return true }
16
+ animal.barks = function(){ return true }
17
+ end
18
+
19
+ it 'should have 4 legs'
20
+ animal.hasFourLegs().should.eql true
21
+ end
22
+
23
+ it 'should bark'
24
+ animal.barks().should.eql true
25
+ end
26
+ end
27
+
28
+ describe 'mastif'
29
+ should_behave_like('canine')
30
+
31
+ before
32
+ animal.weight = 200
33
+ end
34
+
35
+ it 'should weigh > 100 lbs'
36
+ animal.weight.should.be_greater_than 100
37
+ end
38
+ end
39
+
40
+ describe 'poodle breeds'
41
+ should_behave_like('canine')
42
+
43
+ shared_behaviors_for 'poodle'
44
+ before
45
+ animal.isMean = true
46
+ end
47
+
48
+ it 'should be mean'
49
+ animal.isMean.should.eql true
50
+ end
51
+ end
52
+
53
+ describe 'fancy poodle'
54
+ should_behave_like('poodle')
55
+
56
+ before
57
+ animal.looksRidiculous = true
58
+ end
59
+
60
+ it 'should look ridiculous'
61
+ animal.looksRidiculous.should.eql true
62
+ end
63
+ end
64
+ end
65
+
66
+ describe 'shared behaviors'
67
+ before
68
+ before_sequence = []
69
+ before_each_sequence = []
70
+ after_sequence = []
71
+ after_each_sequence = []
72
+ end
73
+
74
+ shared_behaviors_for 'A'
75
+ before
76
+ before_sequence.push('A')
77
+ end
78
+
79
+ after
80
+ after_sequence.push('A')
81
+ end
82
+
83
+ before_each
84
+ before_each_sequence.push('A')
85
+ end
86
+
87
+ after_each
88
+ after_each_sequence.push('A')
89
+ end
90
+ end
91
+
92
+ shared_behaviors_for 'B'
93
+ before
94
+ before_sequence.push('B')
95
+ end
96
+
97
+ after
98
+ after_sequence.push('B')
99
+ end
100
+
101
+ before_each
102
+ before_each_sequence.push('B')
103
+ end
104
+
105
+ after_each
106
+ after_each_sequence.push('B')
107
+ end
108
+ end
109
+
110
+ describe 'before ordering'
111
+ should_behave_like('B')
112
+
113
+ before
114
+ before_sequence.push('C')
115
+ end
116
+
117
+ should_behave_like('A')
118
+
119
+ after
120
+ after_sequence.push('C')
121
+ end
122
+
123
+ before_each
124
+ before_each_sequence.push('C')
125
+ end
126
+
127
+ after_each
128
+ after_each_sequence.push('C')
129
+ end
130
+
131
+ it "should sequence befores in include order"
132
+ before_sequence.should.eql ['B', 'C', 'A']
133
+ end
134
+
135
+ it "should sequence before_eachs in include order"
136
+ before_each_sequence.should.eql ['B', 'A', 'C', 'B', 'A', 'C']
137
+ end
138
+ end
139
+
140
+ describe 'after ordering'
141
+ it "should sequence afters in include order"
142
+ after_sequence.should.eql ['B', 'A', 'C']
143
+ end
144
+
145
+ it "should sequence after_eachs in include order"
146
+ after_each_sequence.should.eql ['B', 'A', 'C', 'B', 'A', 'C']
147
+ end
148
+ end
149
+ end
150
+
151
+ shared_behaviors_for 'person'
152
+ it 'should have a name'
153
+ person.should.have_property 'name'
154
+ end
155
+ end
156
+
157
+ shared_behaviors_for 'administrator'
158
+ should_behave_like('person')
159
+
160
+ it 'should have access to all permissions'
161
+ person.may('edit pages').should.be_true
162
+ person.may('delete users').should.be_true
163
+ end
164
+ end
165
+
166
+ describe 'Shared Behaviors'
167
+ describe 'User'
168
+ before
169
+ User = function(name) { this.name = name }
170
+ person = new User('joe')
171
+ end
172
+
173
+ should_behave_like('person')
174
+ end
175
+
176
+ describe 'Administrator'
177
+ before
178
+ Admin = function(name) { this.name = name }
179
+ Admin.prototype.may = function(perm){ return true }
180
+ person = new Admin('tj')
181
+ end
182
+
183
+ should_behave_like('administrator')
184
+ end
185
+
186
+ describe 'Super Administrator'
187
+ before
188
+ SuperAdmin = function(name) { this.name = name }
189
+ SuperAdmin.prototype.may = function(perm){ return true }
190
+ SuperAdmin.prototype.canCreateUsers = function(){ return true }
191
+ person = new SuperAdmin('tj')
192
+ end
193
+
194
+ should_behave_like('administrator')
195
+
196
+ it "should be allowed to create users"
197
+ person.canCreateUsers().should.be_true
198
+ end
199
+ end
200
+
201
+ shared_behaviors_for 'User with toString()'
202
+ before
203
+ person = { toString : function() { return '<User tj>' }}
204
+ end
205
+
206
+ it 'should return &lt;User NAME&gt;'
207
+ person.toString().should.match(/\<User/)
208
+ end
209
+ end
210
+
211
+ describe 'Manager'
212
+ should_behave_like('person')
213
+ should_behave_like('User with toString()')
214
+
215
+ before
216
+ Manager = function(name) { this.name = name }
217
+ Manager.prototype.may = function(perm){ return perm == 'hire' || perm == 'fire' }
218
+ Manager.prototype.toString = function(){ return '<User ' + this.name + '>' }
219
+ person = new Manager('tj')
220
+ end
221
+
222
+ it 'should have access to hire or fire employees'
223
+ person.may('hire').should.be_true
224
+ person.may('fire').should.be_true
225
+ person.may('do anything else').should.be_false
226
+ end
227
+ end
228
+
229
+ describe 'findLocalSharedBehavior'
230
+ it 'should find shared behavior by name'
231
+ JSpec.findLocalSharedBehavior('User with toString()').should.be_a JSpec.Suite
232
+ end
233
+
234
+ it 'should return null when not found'
235
+ JSpec.findGlobalSharedBehavior('Rawr').should.be_null
236
+ end
237
+
238
+ describe 'nested'
239
+ it 'should find shared behavior by name when nested'
240
+ JSpec.findLocalSharedBehavior('User with toString()').should.be_a JSpec.Suite
241
+ end
242
+ end
243
+ end
244
+
245
+ describe 'findGlobalSharedBehavior'
246
+ it 'should find shared behavior by name'
247
+ JSpec.findGlobalSharedBehavior('person').should.be_a JSpec.Suite
248
+ end
249
+
250
+ it 'should return null when not found'
251
+ JSpec.findGlobalSharedBehavior('Rawr').should.be_null
252
+ end
253
+ end
254
+
255
+ describe 'findSharedBehavior'
256
+ shared_behaviors_for 'person'
257
+ it 'should not have name'
258
+ person.should.not.have_property 'name'
259
+ end
260
+ end
261
+
262
+ describe 'override behavior'
263
+ it 'should find local shared behavior before global'
264
+ JSpec.findSharedBehavior('person').body.toString().should.match(/should not have name/)
265
+ end
266
+ end
267
+
268
+ it 'should find shared global behavior by name'
269
+ JSpec.findGlobalSharedBehavior('animal').should.be_a JSpec.Suite
270
+ end
271
+
272
+ it 'should return null when not found at either level'
273
+ JSpec.findGlobalSharedBehavior('Rawr').should.be_null
274
+ end
275
+ end
276
+ end
277
+
278
+
279
+
@@ -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