visionmedia-jspec 2.7.0 → 2.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +8 -0
- data/Manifest +0 -1
- data/README.rdoc +1 -0
- data/bin/jspec +3 -1
- data/jspec.gemspec +3 -3
- data/lib/jspec.jquery.js +3 -2
- data/lib/jspec.js +30 -5
- data/spec/spec.dom.html +1 -1
- data/spec/spec.matchers.js +50 -1
- data/spec/spec.rhino.js +1 -1
- data/spec/spec.server.html +1 -1
- metadata +2 -3
- data/spec/jquery-1.3.1.js +0 -4241
data/History.rdoc
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
|
2
|
+
=== 2.7.1 / 2009-07-17
|
3
|
+
|
4
|
+
* Changed; hash() now accepts null
|
5
|
+
* Fixed should_receive issue with validating boolean args or return values
|
6
|
+
* Fixed --server-only switch
|
7
|
+
* Fixed jQuery dependency error message when jQuery is not available
|
8
|
+
when using jspec.jquery.js
|
9
|
+
|
2
10
|
=== 2.7.0 / 2009-07-14
|
3
11
|
|
4
12
|
* Added fixture() utility function
|
data/Manifest
CHANGED
data/README.rdoc
CHANGED
@@ -624,6 +624,7 @@ Or run via the terminal using Rhino:
|
|
624
624
|
* Syntax comparison with other frameworks http://gist.github.com/92283
|
625
625
|
* Get the TextMate bundle at https://github.com/visionmedia/jspec.tmbundle/tree
|
626
626
|
* For more information consult the JSpec source code documentation or visit http://visionmedia.github.com/jspec
|
627
|
+
* jQuery + HTML fixture example http://gist.github.com/147831
|
627
628
|
|
628
629
|
== Contributors
|
629
630
|
|
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.
|
14
|
+
program :version, '2.7.1'
|
15
15
|
program :description, 'JavaScript BDD Testing Framework'
|
16
16
|
default_command :bind
|
17
17
|
|
@@ -95,6 +95,8 @@ command :run do |c|
|
|
95
95
|
if options.rhino
|
96
96
|
spec = args.shift || path_to('spec.rhino.js')
|
97
97
|
action = lambda { rhino spec }
|
98
|
+
elsif options.server_only
|
99
|
+
start_server options, nil
|
98
100
|
elsif options.server
|
99
101
|
spec = args.shift || path_to('spec.server.html')
|
100
102
|
action = lambda { start_server options, spec }
|
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.
|
5
|
+
s.version = "2.7.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-
|
9
|
+
s.date = %q{2009-07-17}
|
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
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/
|
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"]
|
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
@@ -1,12 +1,13 @@
|
|
1
1
|
|
2
2
|
// JSpec - jQuery - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
|
3
3
|
|
4
|
-
JSpec
|
4
|
+
JSpec
|
5
|
+
.requires('jQuery', 'when using jspec.jquery.js')
|
6
|
+
.include({
|
5
7
|
|
6
8
|
// --- Initialize
|
7
9
|
|
8
10
|
init : function() {
|
9
|
-
this.requires('jQuery', 'when using jspec.jquery.js')
|
10
11
|
jQuery.ajaxSetup({ async : false })
|
11
12
|
},
|
12
13
|
|
data/lib/jspec.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
JSpec = {
|
7
7
|
|
8
|
-
version : '2.7.
|
8
|
+
version : '2.7.1',
|
9
9
|
cache : {},
|
10
10
|
suites : [],
|
11
11
|
modules : [],
|
@@ -49,6 +49,22 @@
|
|
49
49
|
return { an_instance_of : constructor }
|
50
50
|
},
|
51
51
|
|
52
|
+
/**
|
53
|
+
* Load fixture at _path_. This utility function
|
54
|
+
* supplies the means to resolve, and cache fixture contents
|
55
|
+
* via the DOM or Rhino.
|
56
|
+
*
|
57
|
+
* Fixtures are resolved as:
|
58
|
+
*
|
59
|
+
* - <path>
|
60
|
+
* - fixtures/<path>
|
61
|
+
* - fixtures/<path>.html
|
62
|
+
*
|
63
|
+
* @param {string} path
|
64
|
+
* @return {string}
|
65
|
+
* @api public
|
66
|
+
*/
|
67
|
+
|
52
68
|
fixture : function(path) {
|
53
69
|
if (JSpec.cache[path]) return JSpec.cache[path]
|
54
70
|
function tryLoading(path) {
|
@@ -293,6 +309,8 @@
|
|
293
309
|
})
|
294
310
|
},
|
295
311
|
|
312
|
+
// Check if any calls have passing results
|
313
|
+
|
296
314
|
anyResultsPass : function() {
|
297
315
|
return any(this.calls, function(call){
|
298
316
|
return self.expectedResult.an_instance_of ?
|
@@ -301,6 +319,8 @@
|
|
301
319
|
})
|
302
320
|
},
|
303
321
|
|
322
|
+
// Return the passing result
|
323
|
+
|
304
324
|
passingResult : function() {
|
305
325
|
return this.anyResultsPass().result
|
306
326
|
},
|
@@ -316,6 +336,7 @@
|
|
316
336
|
anyArgsFail : function() {
|
317
337
|
return any(this.calls, function(call){
|
318
338
|
return any(self.expectedArgs, function(i, arg){
|
339
|
+
if (arg == null) return call.args[i] == null
|
319
340
|
return arg.an_instance_of ?
|
320
341
|
call.args[i].constructor != arg.an_instance_of:
|
321
342
|
hash(arg) != hash(call.args[i])
|
@@ -324,6 +345,8 @@
|
|
324
345
|
})
|
325
346
|
},
|
326
347
|
|
348
|
+
// Check if any arguments pass
|
349
|
+
|
327
350
|
anyArgsPass : function() {
|
328
351
|
return any(this.calls, function(call){
|
329
352
|
return any(self.expectedArgs, function(i, arg){
|
@@ -335,6 +358,8 @@
|
|
335
358
|
})
|
336
359
|
},
|
337
360
|
|
361
|
+
// Return the passing args
|
362
|
+
|
338
363
|
passingArgs : function() {
|
339
364
|
return this.anyArgsPass().args
|
340
365
|
},
|
@@ -361,7 +386,7 @@
|
|
361
386
|
return n > 2 ? n + ' times' : { 1 : 'once', 2 : 'twice' }[n]
|
362
387
|
}
|
363
388
|
|
364
|
-
if (this.expectedResult && (negate ? this.anyResultsPass() : this.anyResultsFail()))
|
389
|
+
if (this.expectedResult != null && (negate ? this.anyResultsPass() : this.anyResultsFail()))
|
365
390
|
this.message = methodString + ' to return ' + puts(this.expectedResult) +
|
366
391
|
' but ' + (negate ? 'it did' : 'got ' + puts(this.failingResult()))
|
367
392
|
|
@@ -532,9 +557,6 @@
|
|
532
557
|
|
533
558
|
Module : function(methods) {
|
534
559
|
extend(this, methods)
|
535
|
-
extend(this, {
|
536
|
-
requires : JSpec.requires
|
537
|
-
})
|
538
560
|
},
|
539
561
|
|
540
562
|
// --- DSLs
|
@@ -813,6 +835,7 @@
|
|
813
835
|
*/
|
814
836
|
|
815
837
|
hash : function(object) {
|
838
|
+
if (object == null) return 'null'
|
816
839
|
if (object == undefined) return 'undefined'
|
817
840
|
serialize = function(prefix) {
|
818
841
|
return inject(object, prefix + ':', function(buffer, key, value){
|
@@ -1367,6 +1390,7 @@
|
|
1367
1390
|
*
|
1368
1391
|
* @param {string} dependency
|
1369
1392
|
* @param {string} message (optional)
|
1393
|
+
* @return {JSpec}
|
1370
1394
|
* @api public
|
1371
1395
|
*/
|
1372
1396
|
|
@@ -1374,6 +1398,7 @@
|
|
1374
1398
|
hook('requiring', dependency, message)
|
1375
1399
|
try { eval(dependency) }
|
1376
1400
|
catch (e) { throw 'JSpec depends on ' + dependency + ' ' + message }
|
1401
|
+
return this
|
1377
1402
|
},
|
1378
1403
|
|
1379
1404
|
/**
|
data/spec/spec.dom.html
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
<html>
|
2
2
|
<head>
|
3
3
|
<link type="text/css" rel="stylesheet" href="../lib/jspec.css" />
|
4
|
-
<script src="jquery
|
4
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
|
5
5
|
<script src="../lib/jspec.js"></script>
|
6
6
|
<script src="../lib/jspec.jquery.js"></script>
|
7
7
|
<script src="modules.js"></script>
|
data/spec/spec.matchers.js
CHANGED
@@ -362,7 +362,38 @@ describe 'Matchers'
|
|
362
362
|
personWithPets.should.not.receive('addPets', 'twice')
|
363
363
|
personWithPets.addPets('izzy')
|
364
364
|
end
|
365
|
-
|
365
|
+
|
366
|
+
it 'should pass with boolean args'
|
367
|
+
foo = { bar : function(arg){ return arg }}
|
368
|
+
foo.should.receive('bar', 'twice').with_args(true)
|
369
|
+
foo.bar(true)
|
370
|
+
foo.bar(true)
|
371
|
+
end
|
372
|
+
|
373
|
+
it 'should pass with null args'
|
374
|
+
foo = { bar : function(arg){ return arg }}
|
375
|
+
foo.should.receive('bar').with_args(null)
|
376
|
+
foo.bar(null)
|
377
|
+
end
|
378
|
+
|
379
|
+
it 'should pass with boolean return value true'
|
380
|
+
foo = { bar : function(){ return true }}
|
381
|
+
foo.should.receive('bar').and_return(true)
|
382
|
+
foo.bar()
|
383
|
+
end
|
384
|
+
|
385
|
+
it 'should pass with boolean return value false'
|
386
|
+
foo = { bar : function(){ return false }}
|
387
|
+
foo.should.receive('bar').and_return(false)
|
388
|
+
foo.bar()
|
389
|
+
end
|
390
|
+
|
391
|
+
it 'should pass with null return value'
|
392
|
+
foo = { bar : function(){ return null }}
|
393
|
+
foo.should.receive('bar').and_return(null)
|
394
|
+
foo.bar()
|
395
|
+
end
|
396
|
+
|
366
397
|
it 'should fail when the method does not exist'
|
367
398
|
person.should.receive('getPets')
|
368
399
|
end
|
@@ -432,6 +463,24 @@ describe 'Matchers'
|
|
432
463
|
personWithPets.addPets('izzy')
|
433
464
|
personWithPets.addPets('max')
|
434
465
|
end
|
466
|
+
|
467
|
+
it 'should fail with boolean args'
|
468
|
+
foo = { bar : function(arg){ return arg }}
|
469
|
+
foo.should.receive('bar').with_args(true)
|
470
|
+
foo.bar(false)
|
471
|
+
end
|
472
|
+
|
473
|
+
it 'should fail with boolean return value true'
|
474
|
+
foo = { bar : function(){ return true }}
|
475
|
+
foo.should.receive('bar').and_return(false)
|
476
|
+
foo.bar()
|
477
|
+
end
|
478
|
+
|
479
|
+
it 'should fail with boolean return value false'
|
480
|
+
foo = { bar : function(){ return false }}
|
481
|
+
foo.should.receive('bar').and_return(true)
|
482
|
+
foo.bar()
|
483
|
+
end
|
435
484
|
end
|
436
485
|
|
437
486
|
end
|
data/spec/spec.rhino.js
CHANGED
@@ -10,5 +10,5 @@ JSpec
|
|
10
10
|
.exec('spec/spec.utils.js')
|
11
11
|
.exec('spec/spec.shared-behaviors.js')
|
12
12
|
.exec('spec/spec.modules.js')
|
13
|
-
.run({ formatter : JSpec.formatters.Terminal, failuresOnly :
|
13
|
+
.run({ formatter : JSpec.formatters.Terminal, failuresOnly : false })
|
14
14
|
.report()
|
data/spec/spec.server.html
CHANGED
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.
|
4
|
+
version: 2.7.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-
|
12
|
+
date: 2009-07-17 00:00:00 -07:00
|
13
13
|
default_executable: jspec
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -73,7 +73,6 @@ files:
|
|
73
73
|
- spec/fixtures/test.html
|
74
74
|
- spec/fixtures/test.json
|
75
75
|
- spec/fixtures/test.xml
|
76
|
-
- spec/jquery-1.3.1.js
|
77
76
|
- spec/modules.js
|
78
77
|
- spec/spec.dom.html
|
79
78
|
- spec/spec.grammar-less.js
|