visionmedia-jspec 2.10.0 → 2.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,14 @@
1
1
 
2
+ === 2.11.0 / 2009-09-04
3
+
4
+ * Added --symlink switch (links the current version of JSpec to ./spec/lib) [#4]
5
+ * Added --freeze switch (copies the current version of JSpec to ./spec/lib) [#4]
6
+
7
+ === 2.10.1 / 2009-09-02
8
+
9
+ * Added `jspec shell` sub command (interactive Rhino shell through JSpec)
10
+ * Added jspec.shell.js
11
+
2
12
  === 2.10.0 / 2009-08-27
3
13
 
4
14
  * Added Async support via mock timers (lib/jspec.timers.js) [#19]
data/Manifest CHANGED
@@ -1,5 +1,8 @@
1
- bin/jspec
2
1
  History.rdoc
2
+ Manifest
3
+ README.rdoc
4
+ Rakefile
5
+ bin/jspec
3
6
  jspec.gemspec
4
7
  lib/images/bg.png
5
8
  lib/images/hr.png
@@ -10,11 +13,9 @@ lib/images/vr.png
10
13
  lib/jspec.css
11
14
  lib/jspec.jquery.js
12
15
  lib/jspec.js
16
+ lib/jspec.shell.js
13
17
  lib/jspec.timers.js
14
18
  lib/jspec.xhr.js
15
- Manifest
16
- Rakefile
17
- README.rdoc
18
19
  server/browsers.rb
19
20
  server/helpers.rb
20
21
  server/routes.rb
@@ -24,7 +25,7 @@ spec/env.js
24
25
  spec/fixtures/test.html
25
26
  spec/fixtures/test.json
26
27
  spec/fixtures/test.xml
27
- spec/modules.js
28
+ spec/helpers.js
28
29
  spec/server.rb
29
30
  spec/spec.dom.html
30
31
  spec/spec.fixtures.js
@@ -42,8 +43,8 @@ spec/spec.shared-behaviors.js
42
43
  spec/spec.utils.js
43
44
  spec/spec.xhr.js
44
45
  templates/default/History.rdoc
45
- templates/default/lib/yourlib.core.js
46
46
  templates/default/README.rdoc
47
+ templates/default/lib/yourlib.core.js
47
48
  templates/default/spec/server.rb
48
49
  templates/default/spec/spec.core.js
49
50
  templates/default/spec/spec.dom.html
@@ -33,6 +33,7 @@ and much more.
33
33
  * Method Stubbing
34
34
  * Shared behaviors
35
35
  * Profiling
36
+ * Interactive Shell
36
37
  * Ruby on Rails Integration
37
38
  * Tiny (15 kb compressed, 1300-ish LOC)
38
39
 
@@ -49,6 +50,13 @@ provides the `jspec` executable. To install execute:
49
50
  At which point you may:
50
51
  $ jspec init myproject
51
52
 
53
+ By default, the command above will use absolute path for all JSpec library files.
54
+ This behavior can be a problem when you're working across different computers or
55
+ operating systems. You can freeze the library or symlink it.
56
+
57
+ $ jspec init myproject --freeze
58
+ $ jspec init myproject --symlink
59
+
52
60
  JSpec scripts should NOT be referenced via the <script> tag, they should be
53
61
  loaded using the exec method (unless you are using the grammar-less alternative).
54
62
  Below is an example:
@@ -700,6 +708,20 @@ to reply, where as $.get('/status/404', function(){}) will respond
700
708
  with an 404 status code. Add additional Sinatra routes to the jspec.rb
701
709
  file to add your own functionality.
702
710
 
711
+ == Interactive Shell
712
+
713
+ JSpec provides an interactive shell through Rhino, utilize with:
714
+
715
+ $ jspec shell
716
+
717
+ Or to specify additional files to load:
718
+
719
+ $ jspec shell lib/*.js
720
+
721
+ Or view additional shell help
722
+
723
+ $ jspec help shell
724
+
703
725
  == Ruby on Rails
704
726
 
705
727
  No additional gems are required for JSpec to work with rails, although
@@ -722,6 +744,17 @@ Or run via the terminal using Rhino:
722
744
 
723
745
  $ jspec run --rhino
724
746
 
747
+ == Support Browsers
748
+
749
+ Browsers below are supported and can be found in server/browsers.rb, however
750
+ your spec/server.rb file may support additional browsers.
751
+
752
+ * Safari
753
+ * Chrome
754
+ * Firefox
755
+ * Opera
756
+ * Internet Explorer
757
+
725
758
  == Known Issues
726
759
 
727
760
  * Tabs may cause a parse error. To prevent this use 'soft tabs' (setting in your IDE/Editor)
@@ -762,6 +795,7 @@ JSpec more enjoyable, and bug free ;)
762
795
  * mpd@jesters-court.ne
763
796
  * kevin.gisi@gmail.com
764
797
  * enno84@gmx.net
798
+ * fnando
765
799
 
766
800
  == License
767
801
 
data/bin/jspec CHANGED
@@ -12,7 +12,7 @@ require 'server/server'
12
12
  RHINO = 'java org.mozilla.javascript.tools.shell.Main'
13
13
 
14
14
  program :name, 'JSpec'
15
- program :version, '2.10.0'
15
+ program :version, '2.11.0'
16
16
  program :description, 'JavaScript BDD Testing Framework'
17
17
  default_command :bind
18
18
 
@@ -21,17 +21,47 @@ command :init do |c|
21
21
  c.summary = 'Initialize a JSpec project template'
22
22
  c.description = 'Initialize a JSpec project template. Defaults to the current directory
23
23
  when [dest] is not specified. The template includes several files for
24
- running via Rhino, DOM, and the JSpec Rack server.'
24
+ running via Rhino, DOM, and the JSpec Rack server.
25
+
26
+ Additional switches --freeze, and --symlink are available in order
27
+ to preserve the version of JSpec at the time of initialization. Otherwise
28
+ incompatibilities from later versions may prevent your suite from
29
+ running properly.'
30
+ c.option '-R', '--rails', 'Initialize rails template from rails root directory'
31
+ c.option '-f', '--freeze', 'Copy the JSpec library'
32
+ c.option '-s', '--symlink', 'Symlink the JSpec library instead of copying it'
25
33
  c.example 'Create a directory foo, initialized with a jspec template', 'jspec init foo'
26
- c.option '-R', '--rails', 'Initialize rails template'
27
34
  c.when_called do |args, options|
28
35
  dest = args.shift || '.'
29
36
  if options.rails
30
- initialize_rails_at dest
37
+ initialize_rails_at dest, options
31
38
  else
32
- initialize_at dest
39
+ initialize_at dest, options
40
+ end
41
+ say "Template initialized at `#{dest}'"
42
+ end
43
+ end
44
+
45
+ command :shell do |c|
46
+ c.syntax = 'jspec shell [path ...]'
47
+ c.summary = 'JSpec interactive shell'
48
+ c.description = 'Launch interactive shell with jspec.js, jspec.shell.js,
49
+ and any [path]s given. Simply type "quit" or "exit" to
50
+ terminate the shell.'
51
+ c.example 'Run shell', 'jspec shell'
52
+ c.example 'Run shell with glob of files', 'jspec shell lib/*.js'
53
+ c.example 'Run shell with list of files', 'jspec shell lib/foo.js lib/bar.js'
54
+ c.when_called do |args, options|
55
+ paths = ['jspec.js', 'jspec.shell.js'] | args
56
+ paths.map! do |path|
57
+ if path.include? 'jspec'
58
+ "-f #{JSPEC_ROOT}/lib/#{path}"
59
+ else
60
+ "-f #{path}"
61
+ end
33
62
  end
34
- say "Template initialized at '#{dest}'"
63
+ say "JSpec #{program(:version)}"
64
+ `#{RHINO} #{paths.join(' ')} -f -`
35
65
  end
36
66
  end
37
67
 
@@ -126,22 +156,26 @@ alias_command :bind, :run, '--bind'
126
156
  ##
127
157
  # Initialize template at _dest_.
128
158
 
129
- def initialize_at dest
159
+ def initialize_at dest, options
130
160
  unless Dir[dest + '/*'].empty?
131
161
  abort unless agree "'#{dest}' is not empty; continue? "
132
162
  end
163
+
133
164
  copy_template_to 'default', dest
165
+ setup_lib_dir dest, options
134
166
  replace_root_in dest, 'spec/spec.dom.html', 'spec/spec.rhino.js'
135
167
  end
136
168
 
137
169
  ##
138
170
  # Initialize rails template at _dest_.
139
171
 
140
- def initialize_rails_at dest
172
+ def initialize_rails_at dest, options
141
173
  unless looks_like_rails_root?(dest)
142
174
  abort unless agree "'#{dest}' does not look like root of a rails project; continue? "
143
175
  end
176
+
144
177
  copy_template_to 'rails', "#{dest}/jspec"
178
+ setup_lib_dir "#{dest}/jspec", options
145
179
  replace_root_in "#{dest}/jspec", 'spec.dom.html', 'spec.rhino.js'
146
180
  end
147
181
 
@@ -214,9 +248,17 @@ end
214
248
  # Replace JSPEC_ROOT placeholder in _paths_ relative to _dest_.
215
249
 
216
250
  def replace_root_in dest, *paths
251
+ if rails? && File.exist?("#{dest}/jspec/lib")
252
+ root = "."
253
+ elsif File.exist?("#{dest}/spec/lib")
254
+ root = "."
255
+ else
256
+ root = JSPEC_ROOT
257
+ end
258
+
217
259
  paths.each do |path|
218
260
  path = File.join dest, path
219
- contents = File.read(path).gsub 'JSPEC_ROOT', JSPEC_ROOT
261
+ contents = File.read(path).gsub 'JSPEC_ROOT', root
220
262
  File.open(path, 'w') { |file| file.write contents }
221
263
  end
222
264
  end
@@ -240,3 +282,24 @@ end
240
282
  def looks_like_rails_root? path = '.'
241
283
  File.directory? "#{path}/vendor"
242
284
  end
285
+
286
+ ##
287
+ # Copy or symlink library to the specified path.
288
+
289
+ def setup_lib_dir dest, options
290
+ return unless options.symlink || options.freeze
291
+
292
+ if rails?
293
+ dest = File.join dest, "lib"
294
+ else
295
+ dest = File.join dest, "spec", "lib"
296
+ end
297
+
298
+ from = File.join JSPEC_ROOT, "lib"
299
+
300
+ if options.symlink
301
+ FileUtils.symlink from, dest, :force => true
302
+ else
303
+ FileUtils.cp_r from, dest
304
+ end
305
+ end
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{jspec}
5
- s.version = "2.10.0"
5
+ s.version = "2.11.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-08-27}
9
+ s.date = %q{2009-09-04}
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
- 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", "lib/jspec.timers.js", "lib/jspec.xhr.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", "lib/jspec.timers.js", "lib/jspec.xhr.js", "Manifest", "Rakefile", "README.rdoc", "server/browsers.rb", "server/helpers.rb", "server/routes.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/server.rb", "spec/spec.dom.html", "spec/spec.fixtures.js", "spec/spec.grammar-less.js", "spec/spec.grammar.js", "spec/spec.jquery.js", "spec/spec.jquery.xhr.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", "spec/spec.xhr.js", "templates/default/History.rdoc", "templates/default/lib/yourlib.core.js", "templates/default/README.rdoc", "templates/default/spec/server.rb", "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/server.rb", "templates/rails/spec.application.js", "templates/rails/spec.dom.html", "templates/rails/spec.rhino.js", "templates/rails/spec.server.html"]
14
+ s.extra_rdoc_files = ["README.rdoc", "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", "lib/jspec.shell.js", "lib/jspec.timers.js", "lib/jspec.xhr.js"]
15
+ s.files = ["History.rdoc", "Manifest", "README.rdoc", "Rakefile", "bin/jspec", "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", "lib/jspec.shell.js", "lib/jspec.timers.js", "lib/jspec.xhr.js", "server/browsers.rb", "server/helpers.rb", "server/routes.rb", "server/server.rb", "spec/async", "spec/env.js", "spec/fixtures/test.html", "spec/fixtures/test.json", "spec/fixtures/test.xml", "spec/helpers.js", "spec/server.rb", "spec/spec.dom.html", "spec/spec.fixtures.js", "spec/spec.grammar-less.js", "spec/spec.grammar.js", "spec/spec.jquery.js", "spec/spec.jquery.xhr.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", "spec/spec.xhr.js", "templates/default/History.rdoc", "templates/default/README.rdoc", "templates/default/lib/yourlib.core.js", "templates/default/spec/server.rb", "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/server.rb", "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"]
@@ -5,7 +5,7 @@
5
5
 
6
6
  JSpec = {
7
7
 
8
- version : '2.10.0',
8
+ version : '2.11.0',
9
9
  cache : {},
10
10
  suites : [],
11
11
  modules : [],
@@ -501,14 +501,14 @@
501
501
  // Add passing assertion
502
502
 
503
503
  pass : function(message) {
504
- this.assertions.push({ passed : true, message : message })
504
+ this.assertions.push({ passed: true, message: message })
505
505
  ++JSpec.stats.passes
506
506
  },
507
507
 
508
508
  // Add failing assertion
509
509
 
510
510
  fail : function(message) {
511
- this.assertions.push({ passed : false, message : message })
511
+ this.assertions.push({ passed: false, message: message })
512
512
  ++JSpec.stats.failures
513
513
  },
514
514
 
@@ -0,0 +1,36 @@
1
+
2
+ // JSpec - Shell - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
3
+
4
+ ;(function(){
5
+
6
+ var _quit = quit
7
+
8
+ Shell = {
9
+
10
+ // --- Global
11
+
12
+ main: this,
13
+
14
+ // --- Commands
15
+
16
+ commands: {
17
+ quit: ['Terminate the shell', function(){ _quit() }],
18
+ exit: ['Terminate the shell', function(){ _quit() }]
19
+ },
20
+
21
+ /**
22
+ * Start the interactive shell.
23
+ *
24
+ * @api public
25
+ */
26
+
27
+ start : function() {
28
+ for (var name in this.commands)
29
+ if (this.commands.hasOwnProperty(name))
30
+ this.main.__defineGetter__(name, this.commands[name][1])
31
+ }
32
+ }
33
+
34
+ Shell.start()
35
+
36
+ })()
@@ -1,6 +1,32 @@
1
1
 
2
- ExampleModule = {
3
- name : 'ExampleModule',
2
+ JSpec.include({
3
+ name: 'Helpers',
4
+ utilities : {
5
+ mock_it : function(body) {
6
+ var spec = new JSpec.Spec('mock', body)
7
+ var prev = JSpec.currentSpec
8
+ JSpec.runSpec(spec)
9
+ JSpec.currentSpec = prev
10
+ return spec
11
+ }
12
+ },
13
+
14
+ matchers : {
15
+ have_failure_message : function(spec, expected) {
16
+ return JSpec.any(spec.assertions, function(assertion){
17
+ if (assertion.passed) return
18
+ switch (expected.constructor) {
19
+ case String: return assertion.message == expected
20
+ case RegExp: return expected.test(assertion.message)
21
+ default : return false
22
+ }
23
+ })
24
+ }
25
+ }
26
+ })
27
+
28
+ JSpec.include({
29
+ name: 'ExampleModule',
4
30
  utilities : {
5
31
  doFoo : function(){ return 'foo' },
6
32
  doBar : function(){ return 'bar' }
@@ -33,9 +59,7 @@ ExampleModule = {
33
59
  }
34
60
  }
35
61
  }
36
- }
37
-
38
- JSpec.include(ExampleModule)
62
+ })
39
63
 
40
64
  JSpec.include({
41
65
  name : 'EmptyModule'
@@ -6,7 +6,7 @@
6
6
  <script src="../lib/jspec.jquery.js"></script>
7
7
  <script src="../lib/jspec.xhr.js"></script>
8
8
  <script src="../lib/jspec.timers.js"></script>
9
- <script src="modules.js"></script>
9
+ <script src="helpers.js"></script>
10
10
  <script src="spec.grammar-less.js"></script>
11
11
  <script>
12
12
  function runSuites() {
@@ -21,7 +21,7 @@
21
21
  .exec('spec.modules.js')
22
22
  .exec('spec.xhr.js')
23
23
  .exec('spec.jquery.xhr.js')
24
- .run()
24
+ .run({ failuresOnly: true })
25
25
  .report()
26
26
  }
27
27
  </script>
@@ -49,7 +49,10 @@ describe 'jQuery'
49
49
  end
50
50
 
51
51
  it 'should fail with pretty print of element'
52
- elem.should.not.have_tag 'label'
52
+ spec = mock_it(function() {
53
+ elem.should.not.have_tag 'label'
54
+ })
55
+ spec.should.have_failure_message(/<label>\s*<em>Save?/i)
53
56
  end
54
57
 
55
58
  describe 'have_tag / have_one'
@@ -1,107 +1,146 @@
1
1
 
2
- describe 'Negative specs'
2
+ describe 'Failing specs'
3
3
 
4
4
  it 'should fail'
5
- 'test'.should.not_eql 'test'
5
+ spec = mock_it(function(){
6
+ 'test'.should.not.eql 'test'
7
+ })
8
+ spec.should.have_failure_message("expected 'test' to not eql 'test'")
6
9
  end
7
10
 
8
11
  it 'should fail with one faulty assertion'
9
- 'test'.should.equal 'test'
10
- 'test'.should.equal 'foo'
12
+ spec = mock_it(function() {
13
+ 'test'.should.equal 'test'
14
+ 'test'.should.equal 'foo'
15
+ })
16
+ spec.should.have_failure_message("expected 'test' to be 'foo'")
11
17
  end
12
18
 
13
19
  it 'should fail and print array with square braces'
14
- [1,2].should.equal [1,3]
20
+ spec = mock_it(function() {
21
+ [1,2].should.equal [1,3]
22
+ })
23
+ spec.should.have_failure_message("expected [ 1, 2 ] to be [ 1, 3 ]")
15
24
  end
16
25
 
17
26
  it 'should fail and print nested array'
18
- [1, ['foo']].should.equal [1, ['bar', ['whatever', 1.0, { foo : 'bar', bar : { 1 : 2 } }]]]
19
- end
20
-
21
- it 'should fail and print html elements'
22
- elem = document.createElement('a')
23
- elem.setAttribute('href', 'http://vision-media.ca')
24
- elem.should.not.eql elem
27
+ spec = mock_it(function() {
28
+ [1, ['foo']].should.equal [1, ['bar', ['whatever', 1.0, { foo : 'bar', bar : { 1 : 2 } }]]]
29
+ })
30
+ spec.should.have_failure_message(/^expected \[\s*1,\s*\[\s*'foo'/)
25
31
  end
26
32
 
27
33
  it 'should fail with selector for jQuery objects'
28
- elem = { jquery : '1.3.1', selector : '.foobar' }
29
- elem.should.eql 'foo'
34
+ spec = mock_it(function() {
35
+ elem = { jquery : '1.3.1', selector : '.foobar' }
36
+ elem.should.eql 'foo'
37
+ })
38
+ spec.should.have_failure_message("expected selector '.foobar' to eql 'foo'")
30
39
  end
31
40
 
32
- it 'should fail with negative message'
33
- '1'.should.not.be_true
41
+ it 'should fail with negated message'
42
+ spec = mock_it(function(){
43
+ '1'.should.not.be_true
44
+ })
45
+ spec.should.have_failure_message(/expected '1' to not be true/)
34
46
  end
35
47
 
36
48
  it 'should fail with positive message'
37
- false.should.be_true
38
- end
39
-
40
- it 'should fail saying an error was throw'
41
- -{ throw 'foo' }.should.not.throw_error
49
+ spec = mock_it(function() {
50
+ false.should.be_true
51
+ })
52
+ spec.should.have_failure_message(/expected false to be true/)
42
53
  end
43
54
 
44
55
  it 'should fail saying which error has been thrown'
45
- -{ throw 'foo' }.should.throw_error 'bar'
56
+ spec = mock_it(function() {
57
+ -{ throw 'foo' }.should.throw_error 'bar'
58
+ })
59
+ spec.should.have_failure_message("expected exception of 'bar' to be thrown, but got 'foo'")
46
60
  end
47
61
 
48
62
  it 'should fail saying no error was thrown'
49
- -{ }.should.throw_error 'foo'
63
+ spec = mock_it(function() {
64
+ -{ }.should.throw_error 'foo'
65
+ })
66
+ spec.should.have_failure_message("expected exception of 'foo' to be thrown, but nothing was")
50
67
  end
51
68
 
52
69
  it 'should fail saying no error matching was thrown'
53
- -{ throw 'bar' }.should.throw_error(/foo/)
54
- end
55
-
56
- it 'should fail saying no error matching foo should be thrown'
57
- -{ throw 'foo' }.should.not.throw_error(/foo/)
70
+ spec = mock_it(function() {
71
+ -{ throw 'bar' }.should.throw_error(/foo/)
72
+ })
73
+ spec.should.have_failure_message("expected exception matching /foo/ to be thrown, but got 'bar'")
58
74
  end
59
75
 
60
76
  it 'should fail saying constructors'
61
- -{ throw new TypeError('oh no') }.should.throw_error(Error)
77
+ spec = mock_it(function() {
78
+ -{ throw new TypeError('oh no') }.should.throw_error(Error)
79
+ })
80
+ spec.should.have_failure_message("expected Error to be thrown, but got TypeError: oh no")
62
81
  end
63
82
 
64
83
  it 'should fail saying multiple arg messages'
65
- -{ throw new TypeError('oh no') }.should.throw_error(TypeError, /foo/)
84
+ spec = mock_it(function() {
85
+ -{ throw new TypeError('oh no') }.should.throw_error(TypeError, /foo/)
86
+ })
87
+ spec.should.have_failure_message("expected TypeError and exception matching /foo/ to be thrown, but got TypeError: oh no")
66
88
  end
67
89
 
68
90
  it 'should fail with constructor name'
69
- function Foo(){}
70
- function Bar(){}
71
- Bar.prototype.toString = function(){ return 'Bar error: oh no' }
72
- -{ throw new Bar }.should.throw_error Foo
73
- end
74
-
75
- it 'should fail with function body string'
76
- -{ 'foo' }.should.not.include 'foo'
91
+ spec = mock_it(function() {
92
+ function Foo(){}
93
+ function Bar(){}
94
+ Bar.prototype.toString = function(){ return 'Bar: oh no' }
95
+ -{ throw new Bar }.should.throw_error Foo
96
+ })
97
+ spec.should.have_failure_message("expected Foo to be thrown, but got Bar: oh no")
77
98
  end
78
99
 
79
100
  it 'should fail with constructor name'
80
- function Foo(){ this.toString = function(){ return '<Foo>' }}
81
- foo = new Foo
82
- foo.should.not.be_an_instance_of Foo
101
+ spec = mock_it(function() {
102
+ function Foo(){ this.toString = function(){ return '<Foo>' }}
103
+ foo = new Foo
104
+ foo.should.not.be_an_instance_of Foo
105
+ })
106
+ spec.should.have_failure_message("expected <Foo> to not be an instance of Foo")
83
107
  end
84
108
 
85
109
  it 'should fail with message of first failure'
86
- true.should.be_true
87
- 'bar'.should.match(/foo/gm)
88
- 'bar'.should.include 'foo'
110
+ spec = mock_it(function() {
111
+ true.should.be_true
112
+ 'bar'.should.match(/foo/gm)
113
+ 'bar'.should.include 'foo'
114
+ })
115
+ spec.should.have_failure_message("expected 'bar' to match /foo/gm")
89
116
  end
90
117
 
91
118
  it 'should fail with list'
92
- ['foo', 'bar'].should.include 'foo', 'car'
119
+ spec = mock_it(function() {
120
+ ['foo', 'bar'].should.include 'foo', 'car'
121
+ })
122
+ spec.should.have_failure_message("expected [ 'foo', 'bar' ] to include 'foo', 'car'")
93
123
  end
94
124
 
95
125
  it 'should catch exceptions throw within specs'
96
- throw new Error('Oh noes!')
126
+ spec = mock_it(function() {
127
+ throw new Error('Oh noes!')
128
+ })
129
+ spec.should.have_failure_message(/Error: Oh noes!/)
97
130
  end
98
131
 
99
- it 'should catch improper exceptions'
100
- throw 'oh noes'
132
+ it 'should catch exceptions without constructors'
133
+ spec = mock_it(function() {
134
+ throw 'oh noes'
135
+ })
136
+ spec.should.have_failure_message(/oh noes/)
101
137
  end
102
138
 
103
- it 'should catch proper exceptions'
104
- iDoNotExist.neitherDoI()
139
+ it 'should catch indirect exceptions'
140
+ spec = mock_it(function() {
141
+ iDoNotExist.neitherDoI()
142
+ })
143
+ spec.should.have_failure_message(/iDoNotExist/)
105
144
  end
106
145
 
107
146
  end
@@ -1,7 +1,7 @@
1
1
 
2
2
  load('lib/jspec.js')
3
3
  load('lib/jspec.xhr.js')
4
- load('spec/modules.js')
4
+ load('spec/helpers.js')
5
5
  load('spec/spec.grammar-less.js')
6
6
 
7
7
  JSpec
@@ -4,7 +4,7 @@
4
4
  <script src="/jspec/jspec.js"></script>
5
5
  <script src="/jspec/jspec.jquery.js"></script>
6
6
  <script src="/jspec/jspec.xhr.js"></script>
7
- <script src="modules.js"></script>
7
+ <script src="helpers.js"></script>
8
8
  <script src="spec.grammar-less.js"></script>
9
9
  <script>
10
10
  function runSuites() {
@@ -2,7 +2,10 @@
2
2
  describe 'Utility'
3
3
  describe 'fail()'
4
4
  it 'should fail the current spec'
5
- fail('I failed!')
5
+ spec = mock_it(function() {
6
+ fail('I failed!')
7
+ })
8
+ spec.should.have_failure_message('I failed!')
6
9
  end
7
10
  end
8
11
 
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.10.0
4
+ version: 2.11.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-08-27 00:00:00 -07:00
12
+ date: 2009-09-04 00:00:00 -07:00
13
13
  default_executable: jspec
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -59,6 +59,7 @@ executables:
59
59
  extensions: []
60
60
 
61
61
  extra_rdoc_files:
62
+ - README.rdoc
62
63
  - bin/jspec
63
64
  - lib/images/bg.png
64
65
  - lib/images/hr.png
@@ -69,12 +70,15 @@ extra_rdoc_files:
69
70
  - lib/jspec.css
70
71
  - lib/jspec.jquery.js
71
72
  - lib/jspec.js
73
+ - lib/jspec.shell.js
72
74
  - lib/jspec.timers.js
73
75
  - lib/jspec.xhr.js
74
- - README.rdoc
75
76
  files:
76
- - bin/jspec
77
77
  - History.rdoc
78
+ - Manifest
79
+ - README.rdoc
80
+ - Rakefile
81
+ - bin/jspec
78
82
  - jspec.gemspec
79
83
  - lib/images/bg.png
80
84
  - lib/images/hr.png
@@ -85,11 +89,9 @@ files:
85
89
  - lib/jspec.css
86
90
  - lib/jspec.jquery.js
87
91
  - lib/jspec.js
92
+ - lib/jspec.shell.js
88
93
  - lib/jspec.timers.js
89
94
  - lib/jspec.xhr.js
90
- - Manifest
91
- - Rakefile
92
- - README.rdoc
93
95
  - server/browsers.rb
94
96
  - server/helpers.rb
95
97
  - server/routes.rb
@@ -99,7 +101,7 @@ files:
99
101
  - spec/fixtures/test.html
100
102
  - spec/fixtures/test.json
101
103
  - spec/fixtures/test.xml
102
- - spec/modules.js
104
+ - spec/helpers.js
103
105
  - spec/server.rb
104
106
  - spec/spec.dom.html
105
107
  - spec/spec.fixtures.js
@@ -117,8 +119,8 @@ files:
117
119
  - spec/spec.utils.js
118
120
  - spec/spec.xhr.js
119
121
  - templates/default/History.rdoc
120
- - templates/default/lib/yourlib.core.js
121
122
  - templates/default/README.rdoc
123
+ - templates/default/lib/yourlib.core.js
122
124
  - templates/default/spec/server.rb
123
125
  - templates/default/spec/spec.core.js
124
126
  - templates/default/spec/spec.dom.html