visionmedia-jspec 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,232 @@
1
+
2
+ === 1.1.1 / 2009-04-12
3
+
4
+ * Added gemspec
5
+
6
+ === 1.1.0 / 2009-04-12
7
+
8
+ * jspec executable fully functional
9
+
10
+ === 1.0.4 / 2009-04-09
11
+
12
+ * Added `jspec bind`
13
+ * Added `jspec run`
14
+ * Added `jspec init`
15
+ * Added `jspec` executable
16
+ * Added gemspec and manifest
17
+ * Added command-line usage docs
18
+ * Added custom matchers documentation
19
+ * Removed double negation
20
+
21
+ === 1.0.3 / 2009-04-08
22
+
23
+ * Added have_prop matcher, have_property is now strict [#56]
24
+
25
+ === 1.0.2 / 2009-04-08
26
+
27
+ * Added be_selected, be_checked matchers
28
+ * Added string support to each() each('some foo bar', ...)
29
+ * Added have_ATTR matchers [#51]
30
+ * Deprected be_a_TYPE_input matchers [#50]
31
+
32
+ === 1.0.1 / 2009-04-07
33
+
34
+ * Added have_property matcher [#53]
35
+
36
+ === 1.0.0 / 2009-04-06
37
+
38
+ * Added option() which gives the query string option precedence [#39]
39
+ * Changed; Using JSpec.options.formatter not JSpec.formatter [#44]
40
+ * Fixed Console formatter, now displays nested suites
41
+ * Check out http://visionmedia.github.com/jspec for additional documentation!
42
+
43
+ === 0.9.6 / 2009-04-03
44
+
45
+ * Added nesting support
46
+ * Added printing of nested specs
47
+ * Added assertion graphs to DOM formatter
48
+ * Refactored preprocess()
49
+ * Refactored most of the specs
50
+ * Renamed preProcess() to preprocess()
51
+ * Removed running of a single suite via ?suite= for now
52
+
53
+ === 0.9.5 / 2009-04-02
54
+
55
+ * Added support for printing of function bodies and regexps [#27]
56
+ * Added support for strings / regexp with should_throw_error [#26]
57
+ * Added have_within matcher
58
+ * Added have_at_most matcher
59
+ * Added have_at_least matcher
60
+ * Added have matcher [#24]
61
+
62
+ === 0.9.4 / 2009-04-02
63
+
64
+ * Added be_a_TYPE_input matchers (be_a_checkbox_input, be_a_text_input, etc)
65
+ * Added be_disabled matcher [#21]
66
+ * Added be_enabled matcher [#20]
67
+ * Refactored be_visible and be_hidden with $(elem).is()
68
+
69
+ === 0.9.2 / 2009-04-02
70
+
71
+ * Added support for multi-arg failure messages [#2]
72
+ * Better printing of jQuery objects [#15]
73
+
74
+ === 0.9.1 / 2009-04-02
75
+
76
+ * Added support for dotted negation of assertions (foo.should.not.equal bar)
77
+ * Added support for dot-style assertions [#17] (foo.should_not.equal bar)
78
+
79
+ === 0.9.0 / 2009-04-01
80
+
81
+ * Added spec for strip()
82
+ * Added strip()
83
+ * Added any() util
84
+ * Added new improved include matcher
85
+ * Added have_many and have_one matchers
86
+ * Added have_attr matcher [#14]
87
+ * Added map() util
88
+ * Added inject() util
89
+ * Added escape() util
90
+ * Added recursive array and object printing
91
+ * Added DOM formatter option failuresOnly
92
+ * Added support for running of a single squite via ?suite=...
93
+ * Added query() util
94
+ * Added last() util
95
+ * Added be_within matcher, accepts a range literal
96
+ * Added inclusive range literal n..n
97
+ * Added row hover
98
+ * Refactored range()
99
+ * Refactored setMessage()
100
+ * Refactored hash()
101
+ * Changed; preprocessor passing array of args (multi-arg matcher support)
102
+ * Changed jQuery to $ for internal usage
103
+
104
+ === 0.8.0 / 2009-02-27
105
+
106
+ * Added a new style for the DOM formatter (not finished yet)
107
+
108
+ === 0.7.0 / 2009-02-27
109
+
110
+ * Added Console formatter (anything implementing the console object. Firebug, Safari 4, etc)
111
+ * Added JSpec.options.profile for optional profiling of specs
112
+ * Added this. literal alternative (view readme)
113
+ * Moved formatters into JSpec.formatters
114
+ * Added error() util
115
+ * Added savings raketask
116
+ * Fixed parse error bug in Safari 4
117
+
118
+ === 0.6.3 / 2009-02-26
119
+
120
+ * Added minification for jspec.jquery.js when packaging before release
121
+ * Added compression of css when packaging before release
122
+
123
+ === 0.6.2 / 2009-02-26
124
+
125
+ * Changed; using $ in jspec.jquery.js for JSpec, take that jQuery ;)
126
+ * Added addMatchers, print, hash, and each as 'utility functions' this allows
127
+ JSpec to do each(...) internally instead of JSpec.each(...), while still preventing
128
+ pollution of the global scope.
129
+
130
+ === 0.6.1 / 2009-02-26
131
+
132
+ * Added closrue literal -{ (view README)
133
+ * Added option to DOM formatter, now allows you to specify which element id to output to
134
+
135
+ === 0.6.0 / 2009-02-24
136
+
137
+ * Added JSpec.hash
138
+ * Added be_null matcher
139
+ * Allow recursive composite matching using should_eql and should_not_eql
140
+ For example [1, 2, [3]].should_eql([1, 2, [3]]) is true, works with object
141
+ 'hashes' as well.
142
+
143
+ === 0.5.1 / 2009-02-24
144
+
145
+ * Damn auto-release messed up
146
+
147
+ === 0.5.0 / 2009-02-24
148
+
149
+ * Added async support for jQuery
150
+ * Added JSpec.requires for dependencies
151
+ * Added JSpec.throw
152
+ * Added JSpec.runSpec
153
+ * Refactored jspec.jquery.js
154
+ * Fixed evalBody exceptions, previously was not showing exception message
155
+ * Fixed bug of JSpec interpreting // in a string such as http:// to be a comment.
156
+
157
+ === 0.4.1 / 2009-02-22
158
+
159
+ * Added elements() alias of element()
160
+ * Added support for string passed to runSuite; runSuite('Matchers') is the same as
161
+ runSuite(JSpec.suites['Matchers']).
162
+ * Fixed some documentation
163
+
164
+ === 0.4.0 / 2009-02-20
165
+
166
+ * Added comment literal (//)
167
+ * Added pre-processor for convering matchers.
168
+ For example 'test'.should_be_true becomes JSpec.match('test', 'should_be', 'true'),
169
+ preventing pollution of core prototypes.
170
+
171
+ === 0.3.2 / 2009-02-19
172
+
173
+ * Added TM bundle (go checkout my jspec.tmbundle repo on github)
174
+ * Renamed have_length_of to have_length
175
+
176
+ === 0.3.1 / 2009-02-19
177
+
178
+ * Added jquery js to package
179
+
180
+ === 0.3.0 / 2009-02-19
181
+
182
+ * Added JSpec.match
183
+ * Added options to report() which are passed to formatter
184
+ * Added sandbox helpers (reg / jquery)
185
+ * Added have_child and have_children
186
+ * Added have_tag and have_tags
187
+ * Changed exec to only load / eval file
188
+ * Fixed parser token issue, was previously matching things like end() as literal end
189
+
190
+ === 0.2.3 / 2009-02-18
191
+
192
+ * Changed test dir to spec
193
+ * Changed test.js to core.spec.js
194
+
195
+ === 0.2.2 / 2009-02-18
196
+
197
+ * Added contexts
198
+
199
+ === 0.2.0 / 2009-02-18
200
+
201
+ * Added release rake task
202
+ * Added package with minified alternative
203
+
204
+ === 0.1.0 / 2009-02-18
205
+
206
+ * Added new sexy syntax (warning: you will have to re-write your specs)
207
+ * Added pre-processor for optional matcher parens
208
+ * Added several new matchers
209
+ * Added matcher aliasing
210
+ * Added simple matcher declarations
211
+ * Added __END__
212
+ * Added yet-to-be-implemented specs
213
+ * Added loading of suites via JSpec.load
214
+
215
+ === 0.0.4 / 2008-11-03
216
+
217
+ * Added ability to pass only a description to it(), meaning not yet implemented
218
+
219
+ === 0.0.3 / 2008-10-28
220
+
221
+ * Added should_fail
222
+ * Added should_match
223
+ * Added should_not_match
224
+ * Added should_be and should_not_be
225
+
226
+ === 0.0.2 / 2008-10-28
227
+
228
+ * Fixed typo in documentation for pointing to the master repo
229
+
230
+ === 0.0.1 / 2008-10-28
231
+
232
+ * Initial release
@@ -0,0 +1,26 @@
1
+ bin/jspec
2
+ History.rdoc
3
+ jspec.gemspec
4
+ lib/images/bg.png
5
+ lib/images/hr.png
6
+ lib/images/sprites.bg.png
7
+ lib/images/sprites.png
8
+ lib/images/vr.png
9
+ lib/jspec.css
10
+ lib/jspec.jquery.js
11
+ lib/jspec.js
12
+ Manifest
13
+ Rakefile
14
+ README.rdoc
15
+ spec/async
16
+ spec/jquery-1.3.1.js
17
+ spec/spec.core.dom.js
18
+ spec/spec.core.js
19
+ spec/spec.grammar.js
20
+ spec/spec.html
21
+ spec/spec.jquery.js
22
+ templates/default/History.rdoc
23
+ templates/default/lib/yourlib.core.js
24
+ templates/default/README.rdoc
25
+ templates/default/spec/spec.core.js
26
+ templates/default/spec/spec.html
@@ -0,0 +1,406 @@
1
+
2
+ = JSpec
3
+
4
+ JSpec is a minimalistic JavaScript behavior driven development framework,
5
+ providing simple installation, extremely low learning curve, absolutely no pollution
6
+ to core prototypes, async request support, and incredibly sexy syntax, tons of matchers
7
+ and much more.
8
+
9
+ == Features
10
+
11
+ * Sexiest syntax of them all
12
+ * Framework / DOM independent
13
+ * Nested describes
14
+ * Does not pollute core object prototypes
15
+ * Async support
16
+ * Extremely simple and intuitive matcher declaration
17
+ * Over 45 core matchers
18
+ * Allows parens to be optional when using matchers to increase readability
19
+ * Several helpful formatters (dom, console, terminal, ...)
20
+ * Assertion graphs displaying how many, and which assertions pass or failed
21
+ * Default / customizable evaluation contexts
22
+ * DOM sandbox support
23
+ * Great looking default DOM theme
24
+ * `jspec` command-line utility for auto-running specs, and initializing project templates
25
+ * Profiling
26
+ * Tiny (15 kb compressed, 1000-ish LOC)
27
+
28
+ == Example
29
+
30
+ describe 'ShoppingCart'
31
+ var cart
32
+
33
+ before_each
34
+ cart = new ShoppingCart
35
+ end
36
+
37
+ describe 'addProducts'
38
+ it 'should add several products'
39
+ cart.addProduct('cookie')
40
+ cart.addProduct('icecream')
41
+ cart.should.have 2, 'products'
42
+ end
43
+ end
44
+
45
+ describe 'checkout'
46
+ it 'throw an error when checking out with no products'
47
+ -{ cart.clear().checkout() }.should.throw_error
48
+ end
49
+ end
50
+ end
51
+
52
+ == Installation
53
+
54
+ Simply download JSpec and include JSpec.css and JSpec.js in your markup.
55
+ Head over to the downloads section on Github, clone this public repo, or
56
+ add JSpec as a git submodule with in your project.
57
+
58
+ JSpec scripts should NOT be referenced via the <script> tag, they should be
59
+ loaded using the exec method. Below is an example:
60
+
61
+ ...
62
+ <script>
63
+ function runSuites() {
64
+ JSpec
65
+ .exec('spec.core.js')
66
+ .exec('spec.jquery.js')
67
+ .run()
68
+ .report()
69
+ }
70
+ </script>
71
+ <body onLoad="runSuites()">
72
+ ...
73
+
74
+ You may optionally want to use sources in the /pkg directory
75
+ for your project, since it includes compressed alternatives generated
76
+ each release.
77
+
78
+ == Options
79
+
80
+ You may alter the way JSpec operates by assigning options via the
81
+ JSpec.options hash, or by passing string-based option values via the
82
+ query string. For example JSpec.options.failuresOnly = true, and ?failuresOnly=1
83
+ will both work.
84
+
85
+ * profile {bool} when enabled, uses console.time() in order to display performance information in your console log as specs are completed.
86
+ * failuresOnly {bool} displays only failing specs, making them quick to discover and fix
87
+ * reportToId {string} an element id to report to when using the DOM formatter
88
+
89
+ == Matchers
90
+
91
+ * Core
92
+
93
+ - equal ===
94
+ - be_a, be_an have constructor of x
95
+ - be_at_least >=
96
+ - be_at_most <=
97
+ - be_null == null
98
+ - be_empty length of 0
99
+ - be_true == true
100
+ - be_false == false
101
+ - be_type be type of x
102
+ - be_greater_than >
103
+ - be_less_than <
104
+ - throw_error should throw an error, optionally supply the error string for comparison
105
+ - have object should have n of property (person.should.have(2, 'pets'))
106
+ - have_at_least object should have at least n of property
107
+ - have_at_most object should have a maximum n of property
108
+ - have_within object should have within n..n of property (person.should.have_within(1..3, 'pets')
109
+ - have_length length of n
110
+ - have_prop object should have property x, optionally supplying an expected value
111
+ - have_property strict version of have_prop
112
+ - be_within checks if n is within the range passed
113
+ - include include substring, array element, or hash key
114
+ - match string should match regexp x
115
+ - respond_to property x should be a function
116
+ - eql, be matches simple literals (strings, numbers) with == .
117
+ However composites like arrays or 'hashes' are recursively matched,
118
+ meaning that [1, 2, [3]].should_eql([1, 2, [3]]) will be true.
119
+
120
+ * jQuery
121
+
122
+ - have_tag, have_one have exactly one tag
123
+ - have_tags, have_many have more than one tag
124
+ - have_child have exactly one child
125
+ - have_children have more than one child
126
+ - have_text have plain text
127
+ - have_attr have an attribute, with optional value
128
+ - have_type
129
+ - have_id
130
+ - have_title
131
+ - have_alt
132
+ - have_href
133
+ - have_rel
134
+ - have_rev
135
+ - have_name
136
+ - have_target
137
+ - have_value
138
+ - have_class
139
+ - be_visible
140
+ - be_hidden
141
+ - be_enabled
142
+ - be_disabled
143
+ - be_selected
144
+ - be_checked
145
+
146
+ == Helpers
147
+
148
+ * Core
149
+
150
+ - sandbox used to generate new DOM sandbox
151
+
152
+ * jQuery
153
+
154
+ - sandbox used to generate new DOM sandbox, using jQuery object
155
+ - element same as invoking jQuery, just reads better and no need to worry about $ collisions
156
+ - elements alias of element
157
+
158
+ == Hooks
159
+
160
+ Currently the following hooks are supported, and may be utilized any number of times as they
161
+ are simply pushed to a stack. So for instance you may have two before_each blocks within the same
162
+ scope, they will both run, but this can help keep your specs readable.
163
+
164
+ * before run once before the suite is executed
165
+ * after run once after the suite is executed
166
+ * before_each run before each specification
167
+ * after_each run after each specification
168
+
169
+ == Custom Contexts
170
+
171
+ Custom contexts can be applied to supply helper
172
+ methods or properties to all subsequent bodies (other hooks, or specs).
173
+
174
+ In most cases the default context will suffice, in combination with the
175
+ 'this' keyword. Keep in mind that when replacing the default context
176
+ you will loose functionality provided by it, unless you manually merge it
177
+ into your custom context.
178
+
179
+ To reset the context simply assign null to obtain the original context.
180
+
181
+ ...
182
+ before
183
+ JSpec.context = { foo : 'bar' }
184
+ end
185
+
186
+ after
187
+ JSpec.context = null
188
+ end
189
+
190
+ it 'will work ;)'
191
+ this.foo.should_equal 'bar'
192
+ end
193
+ ...
194
+
195
+ == Async Support
196
+
197
+ Currently only jspec.jquery.js supports async requests. JSpec uses jQuery.ajaxSetup and sets all
198
+ requests to sync, which preserves execution order, and reports correctly.
199
+
200
+ it 'should load mah cookies (textfile)'
201
+ $.post('async', function(text){
202
+ text.should_eql 'cookies!'
203
+ })
204
+ end
205
+
206
+ == Pre-processor
207
+
208
+ The pre-processing capability of JSpec is extremely powerful. Your JavaScript
209
+ code is not necessarily what it seems. For example when you seemingly invoke a
210
+ object's prototype like below:
211
+
212
+ 'foobar'.should.include 'bar'
213
+
214
+ First parens are added:
215
+
216
+ 'foobar'.should.include('bar')
217
+
218
+ Secondly the matcher invocation is converted to a non-polluting match() call:
219
+
220
+ JSpec.match('foobar', 'should', 'include', 'bar')
221
+
222
+ This also means instead of:
223
+
224
+ var object = { foo : 'bar' }
225
+ object.should.include 'foo'
226
+
227
+ We can do:
228
+
229
+ { foo : 'bar' }.should.include 'foo'
230
+
231
+ === Closure Literal
232
+
233
+ These are equivalent:
234
+
235
+ -{ throw 'test' }.should.throw_error
236
+ function() { throw 'test' }.should.throw_error
237
+
238
+ === Inclusive Range Literal
239
+
240
+ The following expands to the array of [1,2,3,4,5]
241
+
242
+ n.should.be_within 1..5
243
+
244
+ === This Literal
245
+
246
+ Commonly throughout using JSpec you will often need to do things like the following,
247
+ while referencing 'this.cart' throughout your specs:
248
+
249
+ before
250
+ this.cart = new ShoppingCart
251
+ end
252
+
253
+ Thanks to the pre-processor we can simply use the terse alternative below:
254
+
255
+ ...
256
+ before
257
+ .cart = new ShoppingCart
258
+ end
259
+
260
+ it '...'
261
+ .cart.should.have 4, 'products'
262
+ end
263
+ ...
264
+
265
+ Alternatively you may utilize literal javascript outside of the closures:
266
+
267
+ ...
268
+ cart = new ShoppingCart
269
+
270
+ it '...'
271
+ cart.should.have 4, 'products'
272
+ end
273
+ ...
274
+
275
+ Another option is to declare a variable outside of the spec closures:
276
+
277
+ var cart
278
+
279
+ before
280
+ cart = new ShoppingCart
281
+ end
282
+
283
+ it '...'
284
+ cart.should.have 4, 'products'
285
+ end
286
+ ...
287
+
288
+ == Formatters
289
+
290
+ To change a formatter simply alter the options hash like below, assigning
291
+ a new constructor:
292
+
293
+ JSpec.options.formatter = JSpec.formatters.Console
294
+
295
+ === DOM
296
+
297
+ Clean attractive HTML reporting
298
+
299
+ === Console
300
+
301
+ Reporting utilizing the console object (tested using Firebug and Safari 4)
302
+
303
+ === Terminal
304
+
305
+ Coming soon
306
+
307
+ == Custom Matchers
308
+
309
+ First lets create a simple equality matcher. In the case below JSpec is smart enough to realize
310
+ this is simply a binary operator, and simply transforms this into 'actual === expected'
311
+
312
+ JSpec.addMatchers({
313
+ equal : '==='
314
+ })
315
+
316
+ To alias a method to keep your specs readable you may alias them like below:
317
+
318
+ JSpec.addMatchers({
319
+ be : 'alias equal'
320
+ })
321
+
322
+ 'foo'.should.equal 'foo'
323
+ true.should.be true
324
+
325
+ Matchers with string bodies implicitly return the expression value.
326
+ The expanded version of the equal matcher would then be:
327
+
328
+ JSpec.addMatchers({
329
+ equal : 'actual === expected'
330
+ })
331
+
332
+ Large matchers or those which require several parameters may wish
333
+ to utilize the hash method:
334
+
335
+ JSpec.addMatchers({
336
+ equal : { match : function(actual, expected){
337
+ return actual === expected
338
+ }}
339
+ })
340
+
341
+ To keep JSpec tiny, JSpec will default to generating failure messages
342
+ for you, how ever this can be explicitly defined:
343
+
344
+ JSpec.addMatchers({
345
+ equal : {
346
+ match : function(actual, expected){
347
+ return actual === expected
348
+ },
349
+ message : function(actual, expected, negate) {
350
+ return 'a message here'
351
+ }
352
+ }
353
+ })
354
+
355
+ == JSpec Command-line Utility
356
+
357
+ When installed as a Ruby Gem, the `jspec` executable will become available,
358
+ allowing you to initialize project templates quickly, as well as auto-testing
359
+ specifications when a file is altered.
360
+
361
+ Initialize JSpec-driven project template in directory 'myproject':
362
+ $ jspec init myproject
363
+
364
+ Once within 'myproject' start testing by executing:
365
+ $ jspec
366
+
367
+ For additional usage execute:
368
+ $ jspec help
369
+
370
+ Or for specific usage:
371
+ $ jspec help run
372
+
373
+ == More Information
374
+
375
+ * Syntax comparison with other frameworks http://gist.github.com/92283
376
+
377
+ * Get the TextMate bundle at https://github.com/visionmedia/jspec.tmbundle/tree
378
+
379
+ * For more information consult the JSpec source code documentation or visit http://visionmedia.github.com/jspec
380
+
381
+ == License
382
+
383
+ (The MIT License)
384
+
385
+ Copyright (c) 2008 - 2009 TJ Holowaychuk <tj@vision-media.ca>
386
+
387
+ Permission is hereby granted, free of charge, to any person obtaining
388
+ a copy of this software and associated documentation files (the
389
+ 'Software'), to deal in the Software without restriction, including
390
+ without limitation the rights to use, copy, modify, merge, publish,
391
+ distribute, sublicense, and/or sell copies of the Software, and to
392
+ permit persons to whom the Software is furnished to do so, subject to
393
+ the following conditions:
394
+
395
+ The above copyright notice and this permission notice shall be
396
+ included in all copies or substantial portions of the Software.
397
+
398
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
399
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
400
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
401
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
402
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
403
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
404
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
405
+
406
+