visionmedia-jspec 2.1.0 → 2.2.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.
data/History.rdoc CHANGED
@@ -1,4 +1,13 @@
1
1
 
2
+ === 2.2.0 / 2009-06-18
3
+
4
+ * Added link to JSpec in JSMag June 2009
5
+ * Added Github gem source location to docs
6
+ * Changed throw_error matcher; now accepts two arguments
7
+ * Changed --server; serves from current working directory.
8
+ This allows files in ../lib/* to be served rather than ./spec/* only.
9
+ * Refactored argumentsToArray()
10
+
2
11
  === 2.1.0 / 2009-06-12
3
12
 
4
13
  * Changed `jspec init` to utilize a single template
data/Manifest CHANGED
@@ -18,14 +18,14 @@ server/server.rb
18
18
  spec/async
19
19
  spec/env.js
20
20
  spec/jquery-1.3.1.js
21
- spec/server.html
21
+ spec/spec.dom.html
22
22
  spec/spec.grammar-less.js
23
23
  spec/spec.grammar.js
24
- spec/spec.html
25
24
  spec/spec.jquery.js
26
25
  spec/spec.js
27
26
  spec/spec.matchers.js
28
27
  spec/spec.rhino.js
28
+ spec/spec.server.html
29
29
  spec/spec.shared-behaviors.js
30
30
  spec/spec.utils.js
31
31
  templates/default/History.rdoc
data/README.rdoc CHANGED
@@ -29,7 +29,7 @@ and much more.
29
29
  * Shared behaviors
30
30
  * Profiling
31
31
  * Rails Integration (http://github.com/bhauman/jspec-rails)
32
- * Tiny (15 kb compressed, 1600-ish LOC)
32
+ * Tiny (15 kb compressed, 1300-ish LOC)
33
33
 
34
34
  == Installation
35
35
 
@@ -38,6 +38,7 @@ Head over to the downloads section on Github, clone this public repo, or
38
38
  add JSpec as a git submodule with in your project. Alternatively JSpec is
39
39
  also available as a Ruby Gem (though this is not required), which also
40
40
  provides the `jspec` executable. To install execute:
41
+ $ gem sources -a http://gems.github.com (if you have not previously done so)
41
42
  $ sudo gem install visionmedia-jspec
42
43
 
43
44
  At which point you may:
@@ -139,7 +140,7 @@ JSpec.options.failuresOnly = true, and ?failuresOnly=1 will both work.
139
140
  - be_type be type of x
140
141
  - be_greater_than >
141
142
  - be_less_than <
142
- - throw_error should throw an error, optionally supply the error string for comparison
143
+ - throw_error should throw an error, optionally supply the error string or regexp for message comparison
143
144
  - have object should have n of property (person.should.have(2, 'pets'))
144
145
  - have_at_least object should have at least n of property
145
146
  - have_at_most object should have a maximum n of property
@@ -463,6 +464,7 @@ Run with:
463
464
 
464
465
  == More Information
465
466
 
467
+ * Featured article in JSMag: http://www.jsmag.com/main.issues.description/id=21/
466
468
  * Syntax comparison with other frameworks http://gist.github.com/92283
467
469
  * Get the TextMate bundle at https://github.com/visionmedia/jspec.tmbundle/tree
468
470
  * For more information consult the JSpec source code documentation or visit http://visionmedia.github.com/jspec
data/bin/jspec CHANGED
@@ -10,7 +10,7 @@ require 'fileutils'
10
10
  RHINO = 'java org.mozilla.javascript.tools.shell.Main'
11
11
 
12
12
  program :name, 'JSpec'
13
- program :version, '2.1.0'
13
+ program :version, '2.2.0'
14
14
  program :description, 'JavaScript BDD Testing Framework'
15
15
  default_command :bind
16
16
 
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.1.0"
5
+ s.version = "2.2.0"
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-06-12}
9
+ s.date = %q{2009-06-18}
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/jquery-1.3.1.js", "spec/server.html", "spec/spec.grammar-less.js", "spec/spec.grammar.js", "spec/spec.html", "spec/spec.jquery.js", "spec/spec.js", "spec/spec.matchers.js", "spec/spec.rhino.js", "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"]
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/jquery-1.3.1.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.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"]
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.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  JSpec = {
7
7
 
8
- version : '2.1.0',
8
+ version : '2.2.0',
9
9
  suites : [],
10
10
  allSuites : [],
11
11
  matchers : {},
@@ -582,9 +582,7 @@
582
582
  */
583
583
 
584
584
  argumentsToArray : function(arguments, offset) {
585
- var args = []
586
- for (i = 0; i < arguments.length; i++) args.push(arguments[i])
587
- return args.slice(offset || 0)
585
+ return Array.prototype.slice.call(arguments, offset || 0)
588
586
  },
589
587
 
590
588
  /**
@@ -1408,28 +1406,37 @@
1408
1406
  return true
1409
1407
  },
1410
1408
 
1411
- throw_error : { match : function(actual, expected) {
1409
+ throw_error : { match : function(actual, expected, message) {
1412
1410
  try { actual() }
1413
1411
  catch (e) {
1414
1412
  this.e = e
1415
- if (expected == undefined) return true
1416
- switch (expected.constructor) {
1417
- case RegExp : return expected.test(e)
1418
- case Function : return e instanceof expected
1419
- case String : return expected == e.toString()
1413
+ var assert = function(arg) {
1414
+ console.log(e.constructor);
1415
+ switch (arg.constructor) {
1416
+ case RegExp : return arg.test(e)
1417
+ case Function : return e.constructor == arg
1418
+ case String : return arg == (e.message || e.toString())
1419
+ }
1420
1420
  }
1421
+ return message ? assert(expected) && assert(message) :
1422
+ expected ? assert(expected) :
1423
+ true
1421
1424
  }
1422
1425
  }, message : function(actual, expected, negate) {
1423
- // TODO: fix when expected is ONLY expected values
1424
- expected = (function(){
1425
- if (expected[1] == undefined) return 'exception'
1426
- switch (expected[1].constructor) {
1427
- case RegExp : return 'exception matching ' + puts(expected[1])
1428
- case Function : return 'instance of ' + expected[1].name
1429
- case String : return 'exception of ' + puts(expected[1])
1426
+ // TODO: refactor when actual is not in expected [0]
1427
+ var message_for = function(i) {
1428
+ if (expected[i] == undefined) return 'exception'
1429
+ switch (expected[i].constructor) {
1430
+ case RegExp : return 'exception matching ' + puts(expected[i])
1431
+ case Function : return expected[i].name
1432
+ case String : return 'exception of ' + puts(expected[i])
1430
1433
  }
1431
- })()
1432
- return 'expected ' + (negate ? 'no ' : 'an ' ) + expected +
1434
+ }
1435
+ if (expected[1] == Error && expected[2] == 'oh no!') {
1436
+ console.log(expected);
1437
+ }
1438
+ exception = message_for(1) + (expected[2] ? ' and ' + message_for(2) : '')
1439
+ return 'expected ' + exception + (negate ? ' not ' : '' ) +
1433
1440
  ' to be thrown, but ' + (this.e ? 'got ' + puts(this.e) : 'nothing was')
1434
1441
  }},
1435
1442
 
data/server/server.rb CHANGED
@@ -25,7 +25,7 @@ module JSpec
25
25
  'close'
26
26
  when /jspec/
27
27
  type = 'application/javascript'
28
- File.read File.join(JSPEC_ROOT, 'lib', request.path_info)
28
+ File.read File.join(JSPEC_ROOT, 'lib', File.basename(request.path_info))
29
29
  when /\.js/
30
30
  type = 'application/javascript'
31
31
  File.read File.join(root, request.path_info)
@@ -74,7 +74,7 @@ module JSpec
74
74
 
75
75
  def self.start options, spec
76
76
  app = Rack::Builder.new do
77
- server = JSpec::Server.new :browsers => options.browsers, :root => File.dirname(spec)
77
+ server = JSpec::Server.new :browsers => options.browsers, :root => '.'
78
78
  server.when_finished { exit }
79
79
  run server
80
80
  end
@@ -92,7 +92,7 @@ module JSpec
92
92
 
93
93
  def self.run_browsers browsers, spec
94
94
  browsers.each do |name|
95
- browser(name).open "http://localhost:4444/#{File.basename(spec)}"
95
+ browser(name).open "http://localhost:4444/#{spec}"
96
96
  end
97
97
  end
98
98
 
File without changes
data/spec/spec.js CHANGED
@@ -57,6 +57,14 @@ describe 'Negative specs'
57
57
  -{ throw 'foo' }.should.not.throw_error(/foo/)
58
58
  end
59
59
 
60
+ it 'should fail saying constructors'
61
+ -{ throw new TypeError('oh no') }.should.throw_error(Error)
62
+ end
63
+
64
+ it 'should should fail saying multiple arg messages'
65
+ -{ throw new TypeError('oh no') }.should.throw_error(TypeError, /foo/)
66
+ end
67
+
60
68
  it 'should fail with constructor name'
61
69
  function Foo(){}
62
70
  function Bar(){}
@@ -182,8 +182,8 @@ describe 'Matchers'
182
182
 
183
183
  describe 'throw_error'
184
184
  it 'should check if an error is thrown'
185
- -{ throw 'error' }.should_throw_error
186
- -{ return 'test' }.should_not_throw_error
185
+ -{ throw 'error' }.should.throw_error
186
+ -{ return 'test' }.should.not.throw_error
187
187
  end
188
188
 
189
189
  it 'should check if an error with a specific message is thrown'
@@ -198,6 +198,15 @@ describe 'Matchers'
198
198
  -{ throw new TypeError('foo') }.should.throw_error(TypeError)
199
199
  -{ throw 'foo' }.should.not.throw_error(Error)
200
200
  end
201
+
202
+ it 'should check if an error with a specific constructor and message is thrown'
203
+ -{ throw new TypeError('oh no!') }.should.throw_error(TypeError, 'oh no!')
204
+ -{ throw new TypeError('oh no!') }.should.not.throw_error(TypeError, 'foo bar')
205
+ -{ throw new TypeError('oh no!') }.should.throw_error(TypeError, /oh no/)
206
+ -{ throw new TypeError('oh no!') }.should.not.throw_error(TypeError, /foo bar/)
207
+ -{ throw new TypeError('oh no!') }.should.not.throw_error(Error, 'oh no!')
208
+ -{ throw new TypeError('oh no!') }.should.not.throw_error(Error, 'foo bar')
209
+ end
201
210
  end
202
211
 
203
212
  describe 'be_an_instance_of'
File without changes
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.1.0
4
+ version: 2.2.0
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-06-12 00:00:00 -07:00
12
+ date: 2009-06-18 00:00:00 -07:00
13
13
  default_executable: jspec
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -61,14 +61,14 @@ files:
61
61
  - spec/async
62
62
  - spec/env.js
63
63
  - spec/jquery-1.3.1.js
64
- - spec/server.html
64
+ - spec/spec.dom.html
65
65
  - spec/spec.grammar-less.js
66
66
  - spec/spec.grammar.js
67
- - spec/spec.html
68
67
  - spec/spec.jquery.js
69
68
  - spec/spec.js
70
69
  - spec/spec.matchers.js
71
70
  - spec/spec.rhino.js
71
+ - spec/spec.server.html
72
72
  - spec/spec.shared-behaviors.js
73
73
  - spec/spec.utils.js
74
74
  - templates/default/History.rdoc