rspec 1.1.3 → 1.1.4

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 (122) hide show
  1. data/CHANGES +35 -0
  2. data/MIT-LICENSE +1 -1
  3. data/README +9 -44
  4. data/Rakefile +34 -51
  5. data/TODO +0 -1
  6. data/UPGRADE +0 -24
  7. data/bin/spec +0 -0
  8. data/bin/spec_translator +0 -0
  9. data/examples/pure/behave_as_example.rb +0 -0
  10. data/examples/pure/partial_mock_example.rb +1 -0
  11. data/examples/stories/calculator.rb +1 -1
  12. data/lib/autotest/rspec.rb +7 -9
  13. data/lib/spec/example.rb +1 -1
  14. data/lib/spec/example/configuration.rb +30 -16
  15. data/lib/spec/example/example_group.rb +2 -1
  16. data/lib/spec/example/example_group_factory.rb +23 -21
  17. data/lib/spec/example/example_group_methods.rb +18 -5
  18. data/lib/spec/example/example_matcher.rb +0 -0
  19. data/lib/spec/example/example_methods.rb +6 -0
  20. data/lib/spec/example/module_inclusion_warnings.rb +37 -0
  21. data/lib/spec/expectations/differs/default.rb +1 -1
  22. data/lib/spec/expectations/extensions/object.rb +4 -12
  23. data/lib/spec/expectations/handler.rb +8 -0
  24. data/lib/spec/extensions.rb +1 -0
  25. data/lib/spec/extensions/metaclass.rb +7 -0
  26. data/lib/spec/extensions/object.rb +0 -4
  27. data/lib/spec/matchers/change.rb +1 -1
  28. data/lib/spec/matchers/has.rb +1 -11
  29. data/lib/spec/matchers/operator_matcher.rb +0 -0
  30. data/lib/spec/matchers/raise_error.rb +53 -30
  31. data/lib/spec/mocks.rb +1 -1
  32. data/lib/spec/mocks/argument_constraint_matchers.rb +5 -1
  33. data/lib/spec/mocks/argument_expectation.rb +26 -0
  34. data/lib/spec/mocks/extensions.rb +1 -0
  35. data/lib/spec/mocks/framework.rb +15 -0
  36. data/lib/spec/mocks/message_expectation.rb +29 -5
  37. data/lib/spec/mocks/mock.rb +9 -7
  38. data/lib/spec/mocks/proxy.rb +26 -12
  39. data/lib/spec/rake/spectask.rb +5 -5
  40. data/lib/spec/runner/backtrace_tweaker.rb +1 -1
  41. data/lib/spec/runner/formatter/base_formatter.rb +2 -3
  42. data/lib/spec/runner/formatter/base_text_formatter.rb +2 -2
  43. data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +4 -8
  44. data/lib/spec/runner/formatter/html_formatter.rb +18 -14
  45. data/lib/spec/runner/formatter/nested_text_formatter.rb +65 -0
  46. data/lib/spec/runner/formatter/profile_formatter.rb +4 -0
  47. data/lib/spec/runner/formatter/progress_bar_formatter.rb +5 -1
  48. data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -1
  49. data/lib/spec/runner/formatter/story/plain_text_formatter.rb +18 -7
  50. data/lib/spec/runner/option_parser.rb +17 -15
  51. data/lib/spec/runner/options.rb +37 -14
  52. data/lib/spec/runner/reporter.rb +15 -11
  53. data/lib/spec/story/extensions/regexp.rb +2 -2
  54. data/lib/spec/story/extensions/string.rb +2 -2
  55. data/lib/spec/story/runner.rb +9 -5
  56. data/lib/spec/story/runner/plain_text_story_runner.rb +2 -2
  57. data/lib/spec/story/runner/scenario_runner.rb +8 -0
  58. data/lib/spec/story/runner/story_mediator.rb +1 -1
  59. data/lib/spec/story/runner/story_runner.rb +3 -1
  60. data/lib/spec/story/step.rb +4 -4
  61. data/lib/spec/story/story.rb +8 -11
  62. data/lib/spec/story/world.rb +0 -1
  63. data/lib/spec/version.rb +2 -2
  64. data/plugins/mock_frameworks/rspec.rb +2 -0
  65. data/spec/autotest/rspec_spec.rb +12 -10
  66. data/spec/spec/example/configuration_spec.rb +0 -0
  67. data/spec/spec/example/example_group/described_module_spec.rb +20 -0
  68. data/spec/spec/example/example_group/warning_messages_spec.rb +76 -0
  69. data/spec/spec/example/example_group_factory_spec.rb +117 -102
  70. data/spec/spec/example/example_group_methods_spec.rb +51 -17
  71. data/spec/spec/example/example_group_spec.rb +13 -1
  72. data/spec/spec/example/example_methods_spec.rb +28 -6
  73. data/spec/spec/example/nested_example_group_spec.rb +12 -0
  74. data/spec/spec/example/predicate_matcher_spec.rb +0 -0
  75. data/spec/spec/expectations/differs/default_spec.rb +27 -9
  76. data/spec/spec/matchers/be_spec.rb +24 -0
  77. data/spec/spec/matchers/has_spec.rb +16 -0
  78. data/spec/spec/matchers/raise_error_spec.rb +124 -0
  79. data/spec/spec/mocks/{bug_report_10263.rb → bug_report_10263_spec.rb} +0 -0
  80. data/spec/spec/mocks/bug_report_11545_spec.rb +2 -0
  81. data/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +8 -0
  82. data/spec/spec/mocks/hash_including_matcher_spec.rb +32 -0
  83. data/spec/spec/mocks/mock_spec.rb +56 -37
  84. data/spec/spec/mocks/partial_mock_spec.rb +41 -5
  85. data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +6 -0
  86. data/spec/spec/runner/execution_context_spec.rb +7 -1
  87. data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +3 -2
  88. data/spec/spec/runner/formatter/html_formatted-1.8.6.html +30 -25
  89. data/spec/spec/runner/formatter/html_formatter_spec.rb +0 -3
  90. data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +333 -0
  91. data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +12 -2
  92. data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +2 -2
  93. data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +110 -78
  94. data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +105 -1
  95. data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +33 -28
  96. data/spec/spec/runner/option_parser_spec.rb +65 -49
  97. data/spec/spec/runner/options_spec.rb +103 -17
  98. data/spec/spec/runner/reporter_spec.rb +10 -7
  99. data/spec/spec/runner/spec_drb.opts +1 -0
  100. data/spec/spec/runner/spec_parser_spec.rb +10 -4
  101. data/spec/spec/story/runner/plain_text_story_runner_spec.rb +14 -13
  102. data/spec/spec/story/runner/scenario_runner_spec.rb +124 -52
  103. data/spec/spec/story/runner/story_mediator_spec.rb +2 -2
  104. data/spec/spec/story/runner/story_runner_spec.rb +40 -2
  105. data/spec/spec/story/runner_spec.rb +59 -72
  106. data/spec/spec/story/step_spec.rb +20 -1
  107. data/spec/spec/story/story_spec.rb +2 -2
  108. data/stories/all.rb +1 -1
  109. data/stories/example_groups/stories.rb +4 -3
  110. data/stories/mock_framework_integration/stories.rb +7 -0
  111. data/stories/mock_framework_integration/use_flexmock.story +9 -0
  112. data/stories/resources/spec/spec_with_flexmock.rb +18 -0
  113. metadata +21 -18
  114. data/pre_commit/lib/pre_commit.rb +0 -4
  115. data/pre_commit/lib/pre_commit/core.rb +0 -50
  116. data/pre_commit/lib/pre_commit/pre_commit.rb +0 -54
  117. data/pre_commit/lib/pre_commit/rspec.rb +0 -111
  118. data/pre_commit/lib/pre_commit/rspec_on_rails.rb +0 -313
  119. data/pre_commit/spec/pre_commit/pre_commit_spec.rb +0 -15
  120. data/pre_commit/spec/pre_commit/rspec_on_rails_spec.rb +0 -36
  121. data/pre_commit/spec/spec_helper.rb +0 -3
  122. data/pre_commit/spec/spec_suite.rb +0 -11
@@ -267,11 +267,21 @@ module Spec
267
267
  @out.string.should include(" Given a pink dog with 21 legs")
268
268
  end
269
269
 
270
+ it 'should document steps that include dollar signs ($)' do
271
+ @formatter.step_succeeded :given, 'kicks that cost $$amount', 50
272
+ @out.string.should include("Given kicks that cost $50")
273
+ end
274
+
270
275
  it 'should document regexp steps with replaced params' do
271
276
  @formatter.step_succeeded :given, /a (pink|blue) dog with (.*) legs/, 'pink', 21
272
277
  @out.string.should include(" Given a pink dog with 21 legs")
273
278
  end
274
279
 
280
+ it 'should document regex steps that include dollar signs ($)' do
281
+ @formatter.step_succeeded :given, /kicks that cost \$(\d+)/, 50
282
+ @out.string.should include("Given kicks that cost $50")
283
+ end
284
+
275
285
  it "should append PENDING for the first pending step" do
276
286
  @formatter.scenario_started('','')
277
287
  @formatter.step_pending(:given, 'a context')
@@ -302,7 +312,7 @@ module Spec
302
312
  @out.string.should include('When I say hey (SKIPPED)')
303
313
  end
304
314
 
305
- it "should append SKIPPED for the a failiure after PENDING" do
315
+ it "should append SKIPPED for a failure after PENDING" do
306
316
  @formatter.scenario_started('','')
307
317
  @formatter.step_pending(:given, 'a context')
308
318
  @formatter.step_failed(:when, 'I say hey')
@@ -310,6 +320,100 @@ module Spec
310
320
  @out.string.should include('When I say hey (SKIPPED)')
311
321
  end
312
322
 
323
+ it "should print steps which succeeded in green" do
324
+ @out.stub!(:tty?).and_return(true)
325
+ @options.stub!(:colour).and_return(true)
326
+
327
+ @formatter.scenario_started('','')
328
+ @formatter.step_succeeded(:given, 'a context')
329
+
330
+ @out.string.should =~ /\e\[32m[\n\s]+Given a context\e\[0m/m
331
+ end
332
+
333
+ it "should print failed steps in red" do
334
+ @out.stub!(:tty?).and_return(true)
335
+ @options.stub!(:colour).and_return(true)
336
+
337
+ @formatter.scenario_started('','')
338
+ @formatter.step_failed(:given, 'a context')
339
+
340
+ @out.string.should =~ /\e\[31m[\n\s]+Given a context\e\[0m/m
341
+ end
342
+
343
+ it "should print ' (FAILED)' in red" do
344
+ @out.stub!(:tty?).and_return(true)
345
+ @options.stub!(:colour).and_return(true)
346
+
347
+ @formatter.scenario_started('','')
348
+ @formatter.step_failed(:given, 'a context')
349
+
350
+ @out.string.should =~ /\e\[31m \(FAILED\)\e\[0m/
351
+ end
352
+
353
+ it "should print pending steps in yellow" do
354
+ @out.stub!(:tty?).and_return(true)
355
+ @options.stub!(:colour).and_return(true)
356
+
357
+ @formatter.scenario_started('','')
358
+ @formatter.step_pending(:given, 'a context')
359
+
360
+ @out.string.should =~ /\e\[33m[\n\s]+Given a context\e\[0m/m
361
+ end
362
+
363
+ it "should print ' (PENDING)' in yellow" do
364
+ @out.stub!(:tty?).and_return(true)
365
+ @options.stub!(:colour).and_return(true)
366
+
367
+ @formatter.scenario_started('','')
368
+ @formatter.step_pending(:given, 'a context')
369
+
370
+ @out.string.should =~ /\e\[33m \(PENDING\)\e\[0m/
371
+ end
372
+
373
+ it "should print skipped steps in yellow if the scenario is already pending" do
374
+ @out.stub!(:tty?).and_return(true)
375
+ @options.stub!(:colour).and_return(true)
376
+
377
+ @formatter.scenario_started('','')
378
+ @formatter.step_pending(:given, 'a context')
379
+ @formatter.step_failed(:when, 'I say hey')
380
+
381
+ @out.string.should =~ /\e\[33m[\n\s]+When I say hey\e\[0m/m
382
+ end
383
+
384
+ it "should print ' (SKIPPED)' in yellow if the scenario is already pending" do
385
+ @out.stub!(:tty?).and_return(true)
386
+ @options.stub!(:colour).and_return(true)
387
+
388
+ @formatter.scenario_started('','')
389
+ @formatter.step_pending(:given, 'a context')
390
+ @formatter.step_failed(:when, 'I say hey')
391
+
392
+ @out.string.should =~ /\e\[33m \(SKIPPED\)\e\[0m/
393
+ end
394
+
395
+ it "should print skipped steps in red if the scenario has already failed" do
396
+ @out.stub!(:tty?).and_return(true)
397
+ @options.stub!(:colour).and_return(true)
398
+
399
+ @formatter.scenario_started('','')
400
+ @formatter.step_failed(:given, 'a context')
401
+ @formatter.step_failed(:when, 'I say hey')
402
+
403
+ @out.string.should =~ /\e\[31m[\n\s]+When I say hey\e\[0m/m
404
+ end
405
+
406
+ it "should print ' (SKIPPED)' in red if the scenario has already failed" do
407
+ @out.stub!(:tty?).and_return(true)
408
+ @options.stub!(:colour).and_return(true)
409
+
410
+ @formatter.scenario_started('','')
411
+ @formatter.step_failed(:given, 'a context')
412
+ @formatter.step_failed(:when, 'I say hey')
413
+
414
+ @out.string.should =~ /\e\[31m \(SKIPPED\)\e\[0m/m
415
+ end
416
+
313
417
  it 'should print some white space after each story' do
314
418
  # when
315
419
  @formatter.story_ended 'title', 'narrative'
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE html
2
+ <!DOCTYPE html
3
3
  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
4
4
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5
5
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
@@ -188,10 +188,10 @@ a {
188
188
  <span class="failed_spec_name">should fail when expected message not received</span>
189
189
  <div class="failure" id="failure_1">
190
190
  <div class="message"><pre>Mock 'poke me' expected :poke with (any args) once, but received it 0 times</pre></div>
191
- <div class="backtrace"><pre>./failing_examples/mocking_example.rb:13:
192
- ./spec/spec/runner/formatter/html_formatter_spec.rb:18:
193
- ./spec/spec/runner/formatter/html_formatter_spec.rb:14:in `chdir'
194
- ./spec/spec/runner/formatter/html_formatter_spec.rb:14:</pre></div>
191
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/mocking_example.rb&line=13">./failing_examples/mocking_example.rb:13</a>
192
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a>
193
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir'
194
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div>
195
195
  <pre class="ruby"><code><span class="linenum">11</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">should fail when expected message not received</span><span class="punct">&quot;</span> <span class="keyword">do</span>
196
196
  <span class="linenum">12</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">(&quot;</span><span class="string">poke me</span><span class="punct">&quot;)</span>
197
197
  <span class="offending"><span class="linenum">13</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span>
@@ -204,10 +204,10 @@ a {
204
204
  <span class="failed_spec_name">should fail when messages are received out of order</span>
205
205
  <div class="failure" id="failure_2">
206
206
  <div class="message"><pre>Mock 'one two three' received :three out of order</pre></div>
207
- <div class="backtrace"><pre>./failing_examples/mocking_example.rb:22:
208
- ./spec/spec/runner/formatter/html_formatter_spec.rb:18:
209
- ./spec/spec/runner/formatter/html_formatter_spec.rb:14:in `chdir'
210
- ./spec/spec/runner/formatter/html_formatter_spec.rb:14:</pre></div>
207
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/mocking_example.rb&line=22">./failing_examples/mocking_example.rb:22</a>
208
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a>
209
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir'
210
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div>
211
211
  <pre class="ruby"><code><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span>
212
212
  <span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span>
213
213
  <span class="offending"><span class="linenum">22</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span>
@@ -219,15 +219,14 @@ a {
219
219
  <dd class="spec failed">
220
220
  <span class="failed_spec_name">should get yelled at when sending unexpected messages</span>
221
221
  <div class="failure" id="failure_3">
222
- <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (any args) 0 times, but received it once</pre></div>
223
- <div class="backtrace"><pre>./failing_examples/mocking_example.rb:28:
224
- ./spec/spec/runner/formatter/html_formatter_spec.rb:18:
225
- ./spec/spec/runner/formatter/html_formatter_spec.rb:14:in `chdir'
226
- ./spec/spec/runner/formatter/html_formatter_spec.rb:14:</pre></div>
227
- <pre class="ruby"><code><span class="linenum">26</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">should get yelled at when sending unexpected messages</span><span class="punct">&quot;</span> <span class="keyword">do</span>
228
- <span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">(&quot;</span><span class="string">don't talk to me</span><span class="punct">&quot;)</span>
229
- <span class="offending"><span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span></span>
230
- <span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span>
222
+ <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (no args) 0 times, but received it once</pre></div>
223
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/mocking_example.rb&line=29">./failing_examples/mocking_example.rb:29</a>
224
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a>
225
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir'
226
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div>
227
+ <pre class="ruby"><code><span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">(&quot;</span><span class="string">don't talk to me</span><span class="punct">&quot;)</span>
228
+ <span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span>
229
+ <span class="offending"><span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span></span>
231
230
  <span class="linenum">30</span> <span class="keyword">end</span></code></pre>
232
231
  </div>
233
232
  </dd>
@@ -236,7 +235,10 @@ a {
236
235
  <span class="failed_spec_name">has a bug we need to fix</span>
237
236
  <div class="failure" id="failure_4">
238
237
  <div class="message"><pre>Expected pending 'here is the bug' to fail. No Error was raised.</pre></div>
239
-
238
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/mocking_example.rb&line=33">./failing_examples/mocking_example.rb:33</a>
239
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a>
240
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir'
241
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div>
240
242
  <pre class="ruby"><code><span class="linenum">31</span>
241
243
  <span class="linenum">32</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">has a bug we need to fix</span><span class="punct">&quot;</span> <span class="keyword">do</span>
242
244
  <span class="offending"><span class="linenum">33</span> <span class="ident">pending</span> <span class="punct">&quot;</span><span class="string">here is the bug</span><span class="punct">&quot;</span> <span class="keyword">do</span></span>
@@ -259,11 +261,14 @@ a {
259
261
  Diff:
260
262
  @@ -1,4 +1,4 @@
261
263
  RSpec is a
262
- -behavior driven development
263
- +behaviour driven development
264
+ -behaviour driven development
265
+ +behavior driven development
264
266
  framework for Ruby
265
267
  </pre></div>
266
-
268
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/diffing_spec.rb&line=13">./failing_examples/diffing_spec.rb:13</a>
269
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a>
270
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir'
271
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div>
267
272
  <pre class="ruby"><code><span class="linenum">11</span><span class="ident">framework</span> <span class="keyword">for</span> <span class="constant">Ruby</span>
268
273
  <span class="linenum">12</span><span class="constant">EOF</span>
269
274
  <span class="offending"><span class="linenum">13</span> <span class="ident">usa</span><span class="punct">.</span><span class="ident">should</span> <span class="punct">==</span> <span class="ident">uk</span></span>
@@ -287,14 +292,14 @@ Diff:
287
292
  @@ -1,5 +1,5 @@
288
293
  &lt;Animal
289
294
  name=bob,
290
- -species=giraffe
291
- +species=tortoise
295
+ -species=tortoise
296
+ +species=giraffe
292
297
  &gt;
293
298
  </pre></div>
294
- <div class="backtrace"><pre>./failing_examples/mocking_example.rb:33:
295
- ./spec/spec/runner/formatter/html_formatter_spec.rb:18:
296
- ./spec/spec/runner/formatter/html_formatter_spec.rb:14:in `chdir'
297
- ./spec/spec/runner/formatter/html_formatter_spec.rb:14:</pre></div>
299
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/diffing_spec.rb&line=34">./failing_examples/diffing_spec.rb:34</a>
300
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a>
301
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir'
302
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div>
298
303
  <pre class="ruby"><code><span class="linenum">32</span> <span class="ident">expected</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">&quot;</span><span class="string">bob</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">giraffe</span><span class="punct">&quot;</span>
299
304
  <span class="linenum">33</span> <span class="ident">actual</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">&quot;</span><span class="string">bob</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">tortoise</span><span class="punct">&quot;</span>
300
305
  <span class="offending"><span class="linenum">34</span> <span class="ident">expected</span><span class="punct">.</span><span class="ident">should</span> <span class="ident">eql</span><span class="punct">(</span><span class="ident">actual</span><span class="punct">)</span></span>
@@ -17,12 +17,12 @@ describe "OptionParser" do
17
17
  options = parse(["--pattern", "foo"])
18
18
  options.filename_pattern.should == "foo"
19
19
  end
20
-
20
+
21
21
  it "should accept dry run option" do
22
22
  options = parse(["--dry-run"])
23
23
  options.dry_run.should be_true
24
24
  end
25
-
25
+
26
26
  it "should eval and use custom formatter when none of the builtins" do
27
27
  options = parse(["--format", "Custom::Formatter"])
28
28
  options.formatters[0].class.should be(Custom::Formatter)
@@ -40,17 +40,17 @@ describe "OptionParser" do
40
40
  options.formatters[2].where.should eql("foo\\bar")
41
41
  options.formatters[3].where.should eql("/foo/bar")
42
42
  end
43
-
43
+
44
44
  it "should not be verbose by default" do
45
45
  options = parse([])
46
46
  options.verbose.should be_nil
47
47
  end
48
-
48
+
49
49
  it "should not use colour by default" do
50
50
  options = parse([])
51
51
  options.colour.should == false
52
52
  end
53
-
53
+
54
54
  it "should print help to stdout if no args" do
55
55
  pending 'A regression since 1.0.8' do
56
56
  options = parse([])
@@ -58,13 +58,13 @@ describe "OptionParser" do
58
58
  @out.read.should match(/Usage: spec \(FILE\|DIRECTORY\|GLOB\)\+ \[options\]/m)
59
59
  end
60
60
  end
61
-
61
+
62
62
  it "should print help to stdout" do
63
63
  options = parse(["--help"])
64
64
  @out.rewind
65
65
  @out.read.should match(/Usage: spec \(FILE\|DIRECTORY\|GLOB\)\+ \[options\]/m)
66
66
  end
67
-
67
+
68
68
  it "should print instructions about how to require missing formatter" do
69
69
  lambda do
70
70
  options = parse(["--format", "Custom::MissingFormatter"])
@@ -72,7 +72,7 @@ describe "OptionParser" do
72
72
  end.should raise_error(NameError)
73
73
  @err.string.should match(/Couldn't find formatter class Custom::MissingFormatter/n)
74
74
  end
75
-
75
+
76
76
  it "should print version to stdout" do
77
77
  options = parse(["--version"])
78
78
  @out.rewind
@@ -84,37 +84,37 @@ describe "OptionParser" do
84
84
  parse(["--require", "whatever"])
85
85
  end.should raise_error(LoadError)
86
86
  end
87
-
87
+
88
88
  it "should support c option" do
89
89
  options = parse(["-c"])
90
90
  options.colour.should be_true
91
91
  end
92
-
92
+
93
93
  it "should support queens colour option" do
94
94
  options = parse(["--colour"])
95
95
  options.colour.should be_true
96
96
  end
97
-
97
+
98
98
  it "should support us color option" do
99
99
  options = parse(["--color"])
100
100
  options.colour.should be_true
101
101
  end
102
-
102
+
103
103
  it "should support single example with -e option" do
104
104
  options = parse(["-e", "something or other"])
105
105
  options.examples.should eql(["something or other"])
106
106
  end
107
-
107
+
108
108
  it "should support single example with -s option (will be removed when autotest supports -e)" do
109
109
  options = parse(["-s", "something or other"])
110
110
  options.examples.should eql(["something or other"])
111
111
  end
112
-
112
+
113
113
  it "should support single example with --example option" do
114
114
  options = parse(["--example", "something or other"])
115
115
  options.examples.should eql(["something or other"])
116
116
  end
117
-
117
+
118
118
  it "should read several example names from file if --example is given an existing file name" do
119
119
  options = parse(["--example", File.dirname(__FILE__) + '/examples.txt'])
120
120
  options.examples.should eql([
@@ -126,27 +126,27 @@ describe "OptionParser" do
126
126
  options = parse(["--example", File.dirname(__FILE__) + '/empty_file.txt'])
127
127
  options.examples.should eql([])
128
128
  end
129
-
129
+
130
130
  it "should use html formatter when format is h" do
131
131
  options = parse(["--format", "h"])
132
132
  options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter)
133
133
  end
134
-
134
+
135
135
  it "should use html story formatter when format is h" do
136
136
  options = parse(["--format", "h"])
137
137
  options.story_formatters[0].class.should equal(Spec::Runner::Formatter::Story::HtmlFormatter)
138
138
  end
139
-
139
+
140
140
  it "should use html formatter when format is html" do
141
141
  options = parse(["--format", "html"])
142
142
  options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter)
143
143
  end
144
-
144
+
145
145
  it "should use html story formatter when format is html" do
146
146
  options = parse(["--format", "html"])
147
147
  options.story_formatters[0].class.should equal(Spec::Runner::Formatter::Story::HtmlFormatter)
148
148
  end
149
-
149
+
150
150
  it "should use html formatter with explicit output when format is html:test.html" do
151
151
  FileUtils.rm 'test.html' if File.exist?('test.html')
152
152
  options = parse(["--format", "html:test.html"])
@@ -156,69 +156,79 @@ describe "OptionParser" do
156
156
  options.formatters[0].close
157
157
  FileUtils.rm 'test.html'
158
158
  end
159
-
159
+
160
160
  it "should use noisy backtrace tweaker with b option" do
161
161
  options = parse(["-b"])
162
162
  options.backtrace_tweaker.should be_instance_of(Spec::Runner::NoisyBacktraceTweaker)
163
163
  end
164
-
164
+
165
165
  it "should use noisy backtrace tweaker with backtrace option" do
166
166
  options = parse(["--backtrace"])
167
167
  options.backtrace_tweaker.should be_instance_of(Spec::Runner::NoisyBacktraceTweaker)
168
168
  end
169
-
169
+
170
170
  it "should use quiet backtrace tweaker by default" do
171
171
  options = parse([])
172
172
  options.backtrace_tweaker.should be_instance_of(Spec::Runner::QuietBacktraceTweaker)
173
173
  end
174
-
174
+
175
175
  it "should use progress bar formatter by default" do
176
176
  options = parse([])
177
177
  options.formatters[0].class.should equal(Spec::Runner::Formatter::ProgressBarFormatter)
178
178
  end
179
-
179
+
180
180
  it "should use specdoc formatter when format is s" do
181
181
  options = parse(["--format", "s"])
182
182
  options.formatters[0].class.should equal(Spec::Runner::Formatter::SpecdocFormatter)
183
183
  end
184
-
184
+
185
185
  it "should use specdoc formatter when format is specdoc" do
186
186
  options = parse(["--format", "specdoc"])
187
187
  options.formatters[0].class.should equal(Spec::Runner::Formatter::SpecdocFormatter)
188
188
  end
189
189
 
190
+ it "should use nested text formatter when format is s" do
191
+ options = parse(["--format", "n"])
192
+ options.formatters[0].class.should equal(Spec::Runner::Formatter::NestedTextFormatter)
193
+ end
194
+
195
+ it "should use nested text formatter when format is nested" do
196
+ options = parse(["--format", "nested"])
197
+ options.formatters[0].class.should equal(Spec::Runner::Formatter::NestedTextFormatter)
198
+ end
199
+
190
200
  it "should support diff option when format is not specified" do
191
201
  options = parse(["--diff"])
192
202
  options.diff_format.should == :unified
193
203
  end
194
-
204
+
195
205
  it "should use unified diff format option when format is unified" do
196
206
  options = parse(["--diff", "unified"])
197
207
  options.diff_format.should == :unified
198
208
  options.differ_class.should equal(Spec::Expectations::Differs::Default)
199
209
  end
200
-
210
+
201
211
  it "should use context diff format option when format is context" do
202
212
  options = parse(["--diff", "context"])
203
213
  options.diff_format.should == :context
204
214
  options.differ_class.should == Spec::Expectations::Differs::Default
205
215
  end
206
-
216
+
207
217
  it "should use custom diff format option when format is a custom format" do
208
218
  Spec::Expectations.differ.should_not be_instance_of(Custom::Differ)
209
-
219
+
210
220
  options = parse(["--diff", "Custom::Differ"])
211
221
  options.parse_diff "Custom::Differ"
212
222
  options.diff_format.should == :custom
213
223
  options.differ_class.should == Custom::Differ
214
224
  Spec::Expectations.differ.should be_instance_of(Custom::Differ)
215
225
  end
216
-
226
+
217
227
  it "should print instructions about how to fix missing differ" do
218
228
  lambda { parse(["--diff", "Custom::MissingFormatter"]) }.should raise_error(NameError)
219
229
  @err.string.should match(/Couldn't find differ class Custom::MissingFormatter/n)
220
230
  end
221
-
231
+
222
232
  describe "when attempting a focussed spec" do
223
233
  attr_reader :file, :dir
224
234
  before do
@@ -226,18 +236,18 @@ describe "OptionParser" do
226
236
  @file = "#{File.dirname(__FILE__)}/spec_parser/spec_parser_fixture.rb"
227
237
  @dir = File.dirname(file)
228
238
  end
229
-
239
+
230
240
  after do
231
241
  $rspec_options = @original_rspec_options
232
242
  end
233
-
243
+
234
244
  def parse(args)
235
245
  options = super
236
246
  $rspec_options = options
237
247
  options.filename_pattern = "*_fixture.rb"
238
248
  options
239
249
  end
240
-
250
+
241
251
  it "should support --line to identify spec" do
242
252
  options = parse([file, "--line", "13"])
243
253
  options.line_number.should == 13
@@ -245,34 +255,34 @@ describe "OptionParser" do
245
255
  options.run_examples
246
256
  options.examples.should eql(["d"])
247
257
  end
248
-
258
+
249
259
  it "should fail with error message if file is dir along with --line" do
250
260
  options = parse([dir, "--line", "169"])
251
261
  options.line_number.should == 169
252
262
  options.run_examples
253
263
  @err.string.should match(/You must specify one file, not a directory when using the --line option/n)
254
264
  end
255
-
265
+
256
266
  it "should fail with error message if file does not exist along with --line" do
257
267
  options = parse(["some file", "--line", "169"])
258
268
  proc do
259
269
  options.run_examples
260
270
  end.should raise_error
261
271
  end
262
-
272
+
263
273
  it "should fail with error message if more than one files are specified along with --line" do
264
274
  options = parse([file, file, "--line", "169"])
265
275
  options.run_examples
266
276
  @err.string.should match(/Only one file can be specified when using the --line option/n)
267
277
  end
268
-
278
+
269
279
  it "should fail with error message if --example and --line are used simultaneously" do
270
280
  options = parse([file, "--example", "some example", "--line", "169"])
271
281
  options.run_examples
272
282
  @err.string.should match(/You cannot use both --line and --example/n)
273
283
  end
274
284
  end
275
-
285
+
276
286
  if [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM}
277
287
  it "should barf when --heckle is specified (and platform is windows)" do
278
288
  lambda do
@@ -285,18 +295,24 @@ describe "OptionParser" do
285
295
  options.heckle_runner.should be_instance_of(Spec::Runner::HeckleRunner)
286
296
  end
287
297
  end
288
-
298
+
289
299
  it "should read options from file when --options is specified" do
290
300
  options = parse(["--options", File.dirname(__FILE__) + "/spec.opts"])
291
301
  options.diff_format.should_not be_nil
292
302
  options.colour.should be_true
293
303
  end
294
-
304
+
295
305
  it "should default the formatter to ProgressBarFormatter when using options file" do
296
306
  options = parse(["--options", File.dirname(__FILE__) + "/spec.opts"])
297
307
  options.formatters.first.should be_instance_of(::Spec::Runner::Formatter::ProgressBarFormatter)
298
308
  end
299
309
 
310
+ it "should run parse drb after parsing options" do
311
+ @parser.stub!(:parse_drb)
312
+ @parser.should_receive(:parse_drb).with(["--drb"]).and_return(true)
313
+ options = parse(["--options", File.dirname(__FILE__) + "/spec_drb.opts"])
314
+ end
315
+
300
316
  it "should read spaced and multi-line options from file when --options is specified" do
301
317
  options = parse(["--options", File.dirname(__FILE__) + "/spec_spaced.opts"])
302
318
  options.diff_format.should_not be_nil
@@ -310,14 +326,14 @@ describe "OptionParser" do
310
326
  IO.read('test.spec.opts').should == "--colour\n--diff\n"
311
327
  FileUtils.rm 'test.spec.opts'
312
328
  end
313
-
329
+
314
330
  it "should save config to file when -G is specified" do
315
331
  FileUtils.rm 'test.spec.opts' if File.exist?('test.spec.opts')
316
332
  options = parse(["--colour", "-G", "test.spec.opts", "--diff"])
317
333
  IO.read('test.spec.opts').should == "--colour\n--diff\n"
318
334
  FileUtils.rm 'test.spec.opts'
319
335
  end
320
-
336
+
321
337
  it "when --drb is specified, calls DrbCommandLine all of the other ARGV arguments" do
322
338
  options = Spec::Runner::OptionParser.parse([
323
339
  "some/spec.rb", "--diff", "--colour"
@@ -331,7 +347,7 @@ describe "OptionParser" do
331
347
  it "should reverse spec order when --reverse is specified" do
332
348
  options = parse(["some/spec.rb", "--reverse"])
333
349
  end
334
-
350
+
335
351
  it "should set an mtime comparator when --loadby mtime" do
336
352
  options = parse(["--loadby", 'mtime'])
337
353
  runner = Spec::Runner::ExampleGroupRunner.new(options)
@@ -339,7 +355,7 @@ describe "OptionParser" do
339
355
  with(options).
340
356
  and_return(runner)
341
357
  runner.should_receive(:load_files).with(["most_recent_spec.rb", "command_line_spec.rb"])
342
-
358
+
343
359
  Dir.chdir(File.dirname(__FILE__)) do
344
360
  options.files << 'command_line_spec.rb'
345
361
  options.files << 'most_recent_spec.rb'
@@ -348,7 +364,7 @@ describe "OptionParser" do
348
364
  FileUtils.rm "most_recent_spec.rb"
349
365
  end
350
366
  end
351
-
367
+
352
368
  it "should use the standard runner by default" do
353
369
  runner = ::Spec::Runner::ExampleGroupRunner.new(@parser.options)
354
370
  ::Spec::Runner::ExampleGroupRunner.should_receive(:new).
@@ -357,7 +373,7 @@ describe "OptionParser" do
357
373
  options = parse([])
358
374
  options.run_examples
359
375
  end
360
-
376
+
361
377
  it "should use a custom runner when given" do
362
378
  runner = Custom::ExampleGroupRunner.new(@parser.options, nil)
363
379
  Custom::ExampleGroupRunner.should_receive(:new).
@@ -366,7 +382,7 @@ describe "OptionParser" do
366
382
  options = parse(["--runner", "Custom::ExampleGroupRunner"])
367
383
  options.run_examples
368
384
  end
369
-
385
+
370
386
  it "should use a custom runner with extra options" do
371
387
  runner = Custom::ExampleGroupRunner.new(@parser.options, 'something')
372
388
  Custom::ExampleGroupRunner.should_receive(:new).