rspec-core 2.6.4 → 2.7.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/README.md +1 -1
  2. data/{bin → exe}/autospec +0 -0
  3. data/{bin → exe}/rspec +0 -0
  4. data/features/Upgrade.md +11 -0
  5. data/features/command_line/exit_status.feature +20 -3
  6. data/features/command_line/format_option.feature +8 -0
  7. data/features/command_line/line_number_appended_to_path.feature +35 -1
  8. data/features/command_line/line_number_option.feature +16 -3
  9. data/features/command_line/pattern_option.feature +31 -0
  10. data/features/command_line/rake_task.feature +1 -1
  11. data/features/command_line/ruby.feature +22 -0
  12. data/features/configuration/default_path.feature +38 -0
  13. data/features/example_groups/{shared_example_group.feature → shared_examples.feature} +49 -26
  14. data/features/expectation_framework_integration/configure_expectation_framework.feature +1 -1
  15. data/features/filtering/inclusion_filters.feature +4 -5
  16. data/features/formatters/text_formatter.feature +16 -13
  17. data/features/helper_methods/let.feature +4 -4
  18. data/features/hooks/around_hooks.feature +1 -1
  19. data/features/hooks/before_and_after_hooks.feature +3 -3
  20. data/features/hooks/filtering.feature +13 -6
  21. data/features/metadata/user_defined.feature +12 -10
  22. data/features/pending/pending_examples.feature +21 -8
  23. data/features/step_definitions/additional_cli_steps.rb +1 -1
  24. data/features/subject/attribute_of_subject.feature +2 -2
  25. data/features/support/env.rb +1 -2
  26. data/lib/rspec/core.rb +1 -23
  27. data/lib/rspec/core/configuration.rb +64 -16
  28. data/lib/rspec/core/configuration_options.rb +11 -4
  29. data/lib/rspec/core/example.rb +10 -7
  30. data/lib/rspec/core/example_group.rb +34 -18
  31. data/lib/rspec/core/formatters/base_text_formatter.rb +10 -2
  32. data/lib/rspec/core/formatters/html_formatter.rb +3 -1
  33. data/lib/rspec/core/formatters/snippet_extractor.rb +9 -3
  34. data/lib/rspec/core/formatters/text_mate_formatter.rb +20 -6
  35. data/lib/rspec/core/hooks.rb +2 -2
  36. data/lib/rspec/core/let.rb +5 -5
  37. data/lib/rspec/core/metadata.rb +136 -94
  38. data/lib/rspec/core/option_parser.rb +10 -5
  39. data/lib/rspec/core/pending.rb +2 -1
  40. data/lib/rspec/core/rake_task.rb +26 -15
  41. data/lib/rspec/core/reporter.rb +2 -3
  42. data/lib/rspec/core/runner.rb +1 -1
  43. data/lib/rspec/core/shared_example_group.rb +4 -4
  44. data/lib/rspec/core/subject.rb +7 -7
  45. data/lib/rspec/core/version.rb +1 -1
  46. data/lib/rspec/core/world.rb +4 -8
  47. data/spec/autotest/discover_spec.rb +2 -2
  48. data/spec/autotest/failed_results_re_spec.rb +29 -21
  49. data/spec/autotest/rspec_spec.rb +3 -3
  50. data/spec/rspec/core/command_line_spec.rb +1 -6
  51. data/spec/rspec/core/configuration_options_spec.rb +65 -13
  52. data/spec/rspec/core/configuration_spec.rb +148 -37
  53. data/spec/rspec/core/deprecations_spec.rb +2 -2
  54. data/spec/rspec/core/drb_command_line_spec.rb +6 -6
  55. data/spec/rspec/core/example_group_spec.rb +197 -61
  56. data/spec/rspec/core/example_spec.rb +33 -16
  57. data/spec/rspec/core/formatters/base_formatter_spec.rb +3 -3
  58. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +149 -1
  59. data/spec/rspec/core/formatters/helpers_spec.rb +8 -8
  60. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +85 -17
  61. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +12 -11
  62. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +12 -11
  63. data/spec/rspec/core/formatters/{html_formatted-1.9.1.html → html_formatted-1.9.3.html} +12 -11
  64. data/spec/rspec/core/formatters/html_formatter_spec.rb +5 -5
  65. data/spec/rspec/core/formatters/progress_formatter_spec.rb +2 -2
  66. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +2 -2
  67. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +86 -18
  68. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +13 -12
  69. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +29 -28
  70. data/spec/rspec/core/formatters/{text_mate_formatted-1.9.1.html → text_mate_formatted-1.9.3.html} +29 -28
  71. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +2 -2
  72. data/spec/rspec/core/hooks_filtering_spec.rb +18 -18
  73. data/spec/rspec/core/let_spec.rb +19 -6
  74. data/spec/rspec/core/metadata_spec.rb +146 -61
  75. data/spec/rspec/core/pending_example_spec.rb +4 -4
  76. data/spec/rspec/core/rake_task_spec.rb +71 -50
  77. data/spec/rspec/core/reporter_spec.rb +2 -2
  78. data/spec/rspec/core/ruby_project_spec.rb +2 -2
  79. data/spec/rspec/core/runner_spec.rb +4 -1
  80. data/spec/rspec/core/shared_example_group_spec.rb +15 -119
  81. data/spec/rspec/core/subject_spec.rb +13 -13
  82. data/spec/rspec/core/world_spec.rb +31 -22
  83. data/spec/rspec/core_spec.rb +1 -29
  84. data/spec/spec_helper.rb +51 -49
  85. data/spec/support/shared_example_groups.rb +3 -3
  86. data/spec/support/spec_files.rb +8 -8
  87. metadata +79 -93
  88. data/.document +0 -5
  89. data/.gitignore +0 -12
  90. data/.rspec +0 -0
  91. data/.travis.yml +0 -9
  92. data/Changelog.md +0 -305
  93. data/Gemfile +0 -49
  94. data/Guardfile +0 -5
  95. data/License.txt +0 -23
  96. data/Rakefile +0 -93
  97. data/cucumber.yml +0 -2
  98. data/features/.nav +0 -57
  99. data/rspec-core.gemspec +0 -24
  100. data/script/FullBuildRakeFile +0 -63
  101. data/script/console +0 -8
  102. data/script/cucumber +0 -1
  103. data/script/full_build +0 -1
  104. data/script/spec +0 -1
  105. data/spec.txt +0 -1126
  106. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +0 -398
  107. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +0 -398
@@ -312,18 +312,18 @@ a {
312
312
  <span class="failed_spec_name">fails</span>
313
313
  <div class="failure" id="failure_1">
314
314
  <div class="message"><pre>RSpec::Core::PendingExampleFixedError</pre></div>
315
- <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/resources/formatter_specs.rb&line=18">./spec/rspec/core/resources/formatter_specs.rb:18</a> :in `block (3 levels) in <top (required)>'
316
- <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=24">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:24</a> :in `block (2 levels) in <module:Formatters>'
317
- <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (5 levels) in <module:Formatters>'
315
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/resources/formatter_specs.rb&line=18">./spec/rspec/core/resources/formatter_specs.rb:18</a> :in `block (3 levels) in &lt;top (required)&gt;'
316
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=24">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:24</a> :in `block (2 levels) in &lt;module:Formatters&gt;'
317
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (5 levels) in &lt;module:Formatters&gt;'
318
318
  <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `open'
319
- <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (4 levels) in <module:Formatters>'
319
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (4 levels) in &lt;module:Formatters&gt;'
320
320
  <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `chdir'
321
- <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `block (3 levels) in <module:Formatters>'</pre></div>
322
- <pre class="ruby"><code><span class="linenum">29</span> <span class="ident">teardown_mocks_for_rspec</span>
323
- <span class="linenum">30</span> <span class="keyword">end</span>
324
- <span class="offending"><span class="linenum">31</span> <span class="keyword">raise</span> <span class="constant">RSpec</span><span class="punct">::</span><span class="constant">Core</span><span class="punct">::</span><span class="constant">PendingExampleFixedError</span><span class="punct">.</span><span class="ident">new</span> <span class="keyword">if</span> <span class="ident">result</span></span>
325
- <span class="linenum">32</span> <span class="keyword">end</span>
326
- <span class="linenum">33</span> <span class="keyword">raise</span> <span class="constant">PendingDeclaredInExample</span><span class="punct">.</span><span class="ident">new</span><span class="punct">(</span><span class="ident">message</span><span class="punct">)</span></code></pre>
321
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `block (3 levels) in &lt;module:Formatters&gt;'</pre></div>
322
+ <pre class="ruby"><code><span class="linenum">16</span> <span class="ident">context</span> <span class="punct">&quot;</span><span class="string">with content that would pass</span><span class="punct">&quot;</span> <span class="keyword">do</span>
323
+ <span class="linenum">17</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">fails</span><span class="punct">&quot;</span> <span class="keyword">do</span>
324
+ <span class="offending"><span class="linenum">18</span> <span class="ident">pending</span> <span class="keyword">do</span></span>
325
+ <span class="linenum">19</span> <span class="number">1</span><span class="punct">.</span><span class="ident">should</span> <span class="ident">eq</span><span class="punct">(</span><span class="number">1</span><span class="punct">)</span>
326
+ <span class="linenum">20</span> <span class="keyword">end</span></code></pre>
327
327
  </div>
328
328
  </dd>
329
329
  </dl>
@@ -345,22 +345,23 @@ a {
345
345
  <span class="failed_spec_name">fails</span>
346
346
  <div class="failure" id="failure_2">
347
347
  <div class="message"><pre>
348
- expected 2
349
- got 1
348
+ expected: 2
349
+ got: 1
350
350
 
351
351
  (compared using ==)
352
352
  </pre></div>
353
- <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/resources/formatter_specs.rb&line=33">./spec/rspec/core/resources/formatter_specs.rb:33</a> :in `block (2 levels) in <top (required)>'
354
- <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=24">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:24</a> :in `block (2 levels) in <module:Formatters>'
355
- <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (5 levels) in <module:Formatters>'
353
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/resources/formatter_specs.rb&line=33">./spec/rspec/core/resources/formatter_specs.rb:33</a> :in `block (2 levels) in &lt;top (required)&gt;'
354
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=24">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:24</a> :in `block (2 levels) in &lt;module:Formatters&gt;'
355
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (5 levels) in &lt;module:Formatters&gt;'
356
356
  <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `open'
357
- <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (4 levels) in <module:Formatters>'
357
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (4 levels) in &lt;module:Formatters&gt;'
358
358
  <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `chdir'
359
- <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `block (3 levels) in <module:Formatters>'</pre></div>
360
- <pre class="ruby"><code><span class="linenum">27</span> <span class="keyword">end</span>
361
- <span class="linenum">28</span>
362
- <span class="offending"><span class="linenum">29</span> <span class="keyword">raise</span><span class="punct">(</span><span class="constant">RSpec</span><span class="punct">::</span><span class="constant">Expectations</span><span class="punct">::</span><span class="constant">ExpectationNotMetError</span><span class="punct">.</span><span class="ident">new</span><span class="punct">(</span><span class="ident">message</span><span class="punct">))</span></span>
363
- <span class="linenum">30</span> <span class="keyword">end</span></code></pre>
359
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `block (3 levels) in &lt;module:Formatters&gt;'</pre></div>
360
+ <pre class="ruby"><code><span class="linenum">31</span><span class="ident">describe</span> <span class="punct">&quot;</span><span class="string">failing spec</span><span class="punct">&quot;</span> <span class="keyword">do</span>
361
+ <span class="linenum">32</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">fails</span><span class="punct">&quot;</span> <span class="keyword">do</span>
362
+ <span class="offending"><span class="linenum">33</span> <span class="number">1</span><span class="punct">.</span><span class="ident">should</span> <span class="ident">eq</span><span class="punct">(</span><span class="number">2</span><span class="punct">)</span></span>
363
+ <span class="linenum">34</span> <span class="keyword">end</span>
364
+ <span class="linenum">35</span><span class="keyword">end</span></code></pre>
364
365
  </div>
365
366
  </dd>
366
367
  </dl>
@@ -375,14 +376,14 @@ expected 2
375
376
  <span class="failed_spec_name">fails with a backtrace that has no file</span>
376
377
  <div class="failure" id="failure_3">
377
378
  <div class="message"><pre>foo</pre></div>
378
- <div class="backtrace"><pre>(erb):1:in `<main>'
379
- <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/resources/formatter_specs.rb&line=41">./spec/rspec/core/resources/formatter_specs.rb:41</a> :in `block (2 levels) in <top (required)>'
380
- <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=24">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:24</a> :in `block (2 levels) in <module:Formatters>'
381
- <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (5 levels) in <module:Formatters>'
379
+ <div class="backtrace"><pre>(erb):1:in `&lt;main&gt;'
380
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/resources/formatter_specs.rb&line=41">./spec/rspec/core/resources/formatter_specs.rb:41</a> :in `block (2 levels) in &lt;top (required)&gt;'
381
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=24">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:24</a> :in `block (2 levels) in &lt;module:Formatters&gt;'
382
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (5 levels) in &lt;module:Formatters&gt;'
382
383
  <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `open'
383
- <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (4 levels) in <module:Formatters>'
384
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=47">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47</a> :in `block (4 levels) in &lt;module:Formatters&gt;'
384
385
  <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `chdir'
385
- <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `block (3 levels) in <module:Formatters>'</pre></div>
386
+ <a href="txmt://open?url=file:///Users/david/projects/ruby/rspec2/repos/rspec-core/spec/rspec/core/formatters/text_mate_formatter_spec.rb&line=46">./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46</a> :in `block (3 levels) in &lt;module:Formatters&gt;'</pre></div>
386
387
  <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for (erb)</span></code></pre>
387
388
  </div>
388
389
  </dd>
@@ -391,7 +392,7 @@ expected 2
391
392
  <span class="failed_spec_name">fails with a backtrace containing an erb file</span>
392
393
  <div class="failure" id="failure_4">
393
394
  <div class="message"><pre>Exception</pre></div>
394
- <div class="backtrace"><pre><a href="txmt://open?url=file:///foo.html.erb&line=1">/foo.html.erb:1</a> :in `<main>': foo (RuntimeError)</pre></div>
395
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///foo.html.erb&line=1">/foo.html.erb:1</a> :in `&lt;main&gt;': foo (RuntimeError)</pre></div>
395
396
  <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for /foo.html.erb</span></code></pre>
396
397
  </div>
397
398
  </dd>
@@ -22,7 +22,7 @@ module RSpec
22
22
  err, out = StringIO.new, StringIO.new
23
23
  command_line = RSpec::Core::CommandLine.new(options)
24
24
  command_line.run(err, out)
25
- out.string.gsub /\d+\.\d+ seconds/, 'x seconds'
25
+ out.string.gsub(/\d+\.\d+ seconds/, 'x seconds')
26
26
 
27
27
  end
28
28
 
@@ -58,7 +58,7 @@ module RSpec
58
58
  expected_doc = Nokogiri::HTML(expected_html)
59
59
  expected_doc.search("div.backtrace").remove
60
60
 
61
- actual_doc.inner_html.should == expected_doc.inner_html
61
+ actual_doc.inner_html.should eq(expected_doc.inner_html)
62
62
 
63
63
  backtrace_lines.each do |backtrace_line|
64
64
  backtrace_line['href'].should include("txmt://open?url=")
@@ -15,13 +15,13 @@ module RSpec::Core
15
15
  group = ExampleGroup.describe
16
16
  group.example("example") {}
17
17
  group.run
18
- filters.should == [
18
+ filters.should eq([
19
19
  "before all in config",
20
20
  "around each in config",
21
21
  "before each in config",
22
22
  "after each in config",
23
23
  "after all in config"
24
- ]
24
+ ])
25
25
  end
26
26
  end
27
27
 
@@ -38,11 +38,11 @@ module RSpec::Core
38
38
  group = ExampleGroup.describe(:match => true)
39
39
  group.example("example") {}
40
40
  group.run
41
- filters.should == [
41
+ filters.should eq([
42
42
  "around each in config",
43
43
  "before each in config",
44
44
  "after each in config"
45
- ]
45
+ ])
46
46
  end
47
47
  end
48
48
 
@@ -58,13 +58,13 @@ module RSpec::Core
58
58
  group = ExampleGroup.describe(:match => true)
59
59
  group.example("example") {}
60
60
  group.run
61
- filters.should == [
61
+ filters.should eq([
62
62
  "before all in config",
63
63
  "around each in config",
64
64
  "before each in config",
65
65
  "after each in config",
66
66
  "after all in config"
67
- ]
67
+ ])
68
68
  end
69
69
 
70
70
  it "runs before|after :all hooks on matching nested example groups" do
@@ -85,8 +85,8 @@ module RSpec::Core
85
85
  group.run
86
86
 
87
87
  example_1_filters.should be_empty
88
- example_2_filters.should == [:before_all]
89
- filters.should == [:before_all, :after_all]
88
+ example_2_filters.should eq([:before_all])
89
+ filters.should eq([:before_all, :after_all])
90
90
  end
91
91
 
92
92
  it "runs before|after :all hooks only on the highest level group that matches the filter" do
@@ -109,11 +109,11 @@ module RSpec::Core
109
109
  end
110
110
  group.run
111
111
 
112
- example_1_filters.should == [:before_all]
113
- example_2_filters.should == [:before_all]
114
- example_3_filters.should == [:before_all]
112
+ example_1_filters.should eq([:before_all])
113
+ example_2_filters.should eq([:before_all])
114
+ example_3_filters.should eq([:before_all])
115
115
 
116
- filters.should == [:before_all, :after_all]
116
+ filters.should eq([:before_all, :after_all])
117
117
  end
118
118
 
119
119
  it "should not be ran if the filter doesn't match the example group's filter" do
@@ -128,7 +128,7 @@ module RSpec::Core
128
128
  group = ExampleGroup.describe(:match => true)
129
129
  group.example("example") {}
130
130
  group.run
131
- filters.should == []
131
+ filters.should eq([])
132
132
  end
133
133
 
134
134
  context "when the hook filters apply to individual examples instead of example groups" do
@@ -164,11 +164,11 @@ module RSpec::Core
164
164
  let(:example_metadata) { { :foo => :bar } }
165
165
 
166
166
  it "runs the `:each` hooks" do
167
- each_filters.should == [
167
+ each_filters.should eq([
168
168
  'around each in config',
169
169
  'before each in config',
170
170
  'after each in config'
171
- ]
171
+ ])
172
172
  end
173
173
 
174
174
  it "does not run the `:all` hooks" do
@@ -199,13 +199,13 @@ module RSpec::Core
199
199
  group = ExampleGroup.describe(:one => 1, :two => 2, :three => 3)
200
200
  group.example("example") {}
201
201
  group.run
202
- filters.should == [
202
+ filters.should eq([
203
203
  "before all in config",
204
204
  "around each in config",
205
205
  "before each in config",
206
206
  "after each in config",
207
207
  "after all in config"
208
- ]
208
+ ])
209
209
  end
210
210
 
211
211
  it "should not be ran if some hook filters don't match the group's filters" do
@@ -220,7 +220,7 @@ module RSpec::Core
220
220
  group = ExampleGroup.describe(:one => 1, :two => 2, :three => 3)
221
221
  group.example("example") {}
222
222
  group.run
223
- filters.should == []
223
+ filters.should eq([])
224
224
  end
225
225
  end
226
226
  end
@@ -12,19 +12,32 @@ describe "#let" do
12
12
  end.new
13
13
  end
14
14
 
15
+ let(:nil_value) do
16
+ @nil_value_count += 1
17
+ nil
18
+ end
19
+
15
20
  it "generates an instance method" do
16
- counter.count.should == 1
21
+ counter.count.should eq(1)
17
22
  end
18
23
 
19
24
  it "caches the value" do
20
- counter.count.should == 1
21
- counter.count.should == 2
25
+ counter.count.should eq(1)
26
+ counter.count.should eq(2)
27
+ end
28
+
29
+ it "caches a nil value" do
30
+ @nil_value_count = 0
31
+ nil_value
32
+ nil_value
33
+
34
+ @nil_value_count.should eq(1)
22
35
  end
23
36
  end
24
37
 
25
38
  describe "#let!" do
26
39
  let!(:creator) do
27
- class Creator
40
+ Class.new do
28
41
  @count = 0
29
42
  def self.count
30
43
  @count += 1
@@ -33,10 +46,10 @@ describe "#let!" do
33
46
  end
34
47
 
35
48
  it "evaluates the value non-lazily" do
36
- lambda { Creator.count }.should_not raise_error
49
+ lambda { creator.count }.should_not raise_error
37
50
  end
38
51
 
39
52
  it "does not interfere between tests" do
40
- Creator.count.should == 1
53
+ creator.count.should eq(1)
41
54
  end
42
55
  end
@@ -17,67 +17,120 @@ module RSpec
17
17
  it "uses :caller if passed as part of the user metadata" do
18
18
  m = Metadata.new
19
19
  m.process('group', :caller => ['example_file:42'])
20
- m[:example_group][:location].should == 'example_file:42'
20
+ m[:example_group][:location].should eq("example_file:42")
21
21
  end
22
22
  end
23
23
 
24
- describe "#apply_condition" do
24
+ describe "#filter_applies?" do
25
25
 
26
26
  let(:parent_group_metadata) { Metadata.new.process('parent group', :caller => ["foo_spec.rb:#{__LINE__}"]) }
27
- let(:parent_group_line_number) { parent_group_metadata[:example_group][:line_number] }
28
27
  let(:group_metadata) { Metadata.new(parent_group_metadata).process('group', :caller => ["foo_spec.rb:#{__LINE__}"]) }
29
- let(:group_line_number) { group_metadata[:example_group][:line_number] }
30
28
  let(:example_metadata) { group_metadata.for_example('example', :caller => ["foo_spec.rb:#{__LINE__}"], :if => true) }
31
- let(:example_line_number) { example_metadata[:line_number] }
32
29
  let(:next_example_metadata) { group_metadata.for_example('next_example', :caller => ["foo_spec.rb:#{example_line_number + 2}"]) }
33
30
  let(:world) { World.new }
34
31
 
35
32
  before { RSpec.stub(:world) { world } }
36
33
 
37
- it "matches the group when the line_number is the example group line number" do
38
- world.should_receive(:preceding_declaration_line).and_return(group_line_number)
39
- # this call doesn't really make sense since apply_condition is only called
40
- # for example metadata not group metadata
41
- group_metadata.apply_condition(:line_number, group_line_number).should be_true
42
- end
34
+ shared_examples_for "matching by line number" do
35
+ let(:preceeding_declaration_lines) {{
36
+ parent_group_metadata[:example_group][:line_number] => parent_group_metadata[:example_group][:line_number],
37
+ group_metadata[:example_group][:line_number] => group_metadata[:example_group][:line_number],
38
+ example_metadata[:line_number] => example_metadata[:line_number],
39
+ (example_metadata[:line_number] + 1) => example_metadata[:line_number],
40
+ (example_metadata[:line_number] + 2) => example_metadata[:line_number] + 2,
41
+ }}
42
+ before do
43
+ world.should_receive(:preceding_declaration_line).at_least(:once).and_return do |v|
44
+ preceeding_declaration_lines[v]
45
+ end
46
+ end
43
47
 
44
- it "matches the example when the line_number is the grandparent example group line number" do
45
- world.should_receive(:preceding_declaration_line).and_return(parent_group_line_number)
46
- example_metadata.apply_condition(:line_number, parent_group_line_number).should be_true
47
- end
48
+ it "matches the group when the line_number is the example group line number" do
49
+ # this call doesn't really make sense since filter_applies? is only called
50
+ # for example metadata not group metadata
51
+ group_metadata.filter_applies?(condition_key, group_condition).should be_true
52
+ end
53
+
54
+ it "matches the example when the line_number is the grandparent example group line number" do
55
+ example_metadata.filter_applies?(condition_key, parent_group_condition).should be_true
56
+ end
57
+
58
+ it "matches the example when the line_number is the parent example group line number" do
59
+ example_metadata.filter_applies?(condition_key, group_condition).should be_true
60
+ end
61
+
62
+ it "matches the example when the line_number is the example line number" do
63
+ example_metadata.filter_applies?(condition_key, example_condition).should be_true
64
+ end
48
65
 
49
- it "matches the example when the line_number is the parent example group line number" do
50
- world.should_receive(:preceding_declaration_line).and_return(group_line_number)
51
- example_metadata.apply_condition(:line_number, group_line_number).should be_true
66
+ it "matches when the line number is between this example and the next" do
67
+ example_metadata.filter_applies?(condition_key, between_examples_condition).should be_true
68
+ end
69
+
70
+ it "does not match when the line number matches the next example" do
71
+ example_metadata.filter_applies?(condition_key, next_example_condition).should be_false
72
+ end
52
73
  end
53
74
 
54
- it "matches the example when the line_number is the example line number" do
55
- world.should_receive(:preceding_declaration_line).and_return(example_line_number)
56
- example_metadata.apply_condition(:line_number, example_line_number).should be_true
75
+ context "with a single line number" do
76
+ let(:condition_key){ :line_numbers }
77
+ let(:parent_group_condition) { [parent_group_metadata[:example_group][:line_number]] }
78
+ let(:group_condition) { [group_metadata[:example_group][:line_number]] }
79
+ let(:example_condition) { [example_metadata[:line_number]] }
80
+ let(:between_examples_condition) { [group_metadata[:example_group][:line_number] + 1] }
81
+ let(:next_example_condition) { [example_metadata[:line_number] + 2] }
82
+
83
+ it_has_behavior "matching by line number"
57
84
  end
58
85
 
59
- it "matches when the line number is between this example and the next" do
60
- world.should_receive(:preceding_declaration_line).and_return(example_line_number)
61
- example_metadata.apply_condition(:line_number, example_line_number + 1).should be_true
86
+ context "with multiple line numbers" do
87
+ let(:condition_key){ :line_numbers }
88
+ let(:parent_group_condition) { [-1, parent_group_metadata[:example_group][:line_number]] }
89
+ let(:group_condition) { [-1, group_metadata[:example_group][:line_number]] }
90
+ let(:example_condition) { [-1, example_metadata[:line_number]] }
91
+ let(:between_examples_condition) { [-1, group_metadata[:example_group][:line_number] + 1] }
92
+ let(:next_example_condition) { [-1, example_metadata[:line_number] + 2] }
93
+
94
+ it_has_behavior "matching by line number"
62
95
  end
63
96
 
64
- it "does not match when the line number matches the next example" do
65
- world.should_receive(:preceding_declaration_line).and_return(example_line_number + 2)
66
- example_metadata.apply_condition(:line_number, example_line_number + 2).should be_false
97
+ context "with locations" do
98
+ let(:condition_key){ :locations }
99
+ let(:parent_group_condition) do
100
+ {File.expand_path(parent_group_metadata[:example_group][:file_path]) => [parent_group_metadata[:example_group][:line_number]]}
101
+ end
102
+ let(:group_condition) do
103
+ {File.expand_path(group_metadata[:example_group][:file_path]) => [group_metadata[:example_group][:line_number]]}
104
+ end
105
+ let(:example_condition) do
106
+ {File.expand_path(example_metadata[:file_path]) => [example_metadata[:line_number]]}
107
+ end
108
+ let(:between_examples_condition) do
109
+ {File.expand_path(group_metadata[:example_group][:file_path]) => [group_metadata[:example_group][:line_number] + 1]}
110
+ end
111
+ let(:next_example_condition) do
112
+ {File.expand_path(example_metadata[:file_path]) => [example_metadata[:line_number] + 2]}
113
+ end
114
+
115
+ it_has_behavior "matching by line number"
116
+
117
+ it "ignores location filters for other files" do
118
+ example_metadata.filter_applies?(:locations, {"/path/to/other_spec.rb" => [3,5,7]}).should be_true
119
+ end
67
120
  end
68
121
 
69
122
  it "matches a proc that evaluates to true" do
70
- example_metadata.apply_condition(:if, lambda { |v| v }).should be_true
123
+ example_metadata.filter_applies?(:if, lambda { |v| v }).should be_true
71
124
  end
72
125
 
73
126
  it "does not match a proc that evaluates to false" do
74
- example_metadata.apply_condition(:if, lambda { |v| !v }).should be_false
127
+ example_metadata.filter_applies?(:if, lambda { |v| !v }).should be_false
75
128
  end
76
129
 
77
130
  it "passes the metadata hash as the second argument if a given proc expects 2 args" do
78
131
  passed_metadata = nil
79
- example_metadata.apply_condition(:if, lambda { |v, m| passed_metadata = m })
80
- passed_metadata.should == example_metadata
132
+ example_metadata.filter_applies?(:if, lambda { |v, m| passed_metadata = m })
133
+ passed_metadata.should eq(example_metadata)
81
134
  end
82
135
  end
83
136
 
@@ -87,43 +140,43 @@ module RSpec
87
140
  let(:line_number) { __LINE__ - 1 }
88
141
 
89
142
  it "stores the description" do
90
- mfe[:description].should == "example description"
143
+ mfe[:description].should eq("example description")
91
144
  end
92
145
 
93
146
  it "stores the full_description (group description + example description)" do
94
- mfe[:full_description].should == "group description example description"
147
+ mfe[:full_description].should eq("group description example description")
95
148
  end
96
149
 
97
150
  it "creates an empty execution result" do
98
- mfe[:execution_result].should == {}
151
+ mfe[:execution_result].should eq({})
99
152
  end
100
153
 
101
154
  it "extracts file path from caller" do
102
- mfe[:file_path].should == __FILE__
155
+ mfe[:file_path].should eq(__FILE__)
103
156
  end
104
157
 
105
158
  it "extracts line number from caller" do
106
- mfe[:line_number].should == line_number
159
+ mfe[:line_number].should eq(line_number)
107
160
  end
108
161
 
109
162
  it "extracts location from caller" do
110
- mfe[:location].should == "#{__FILE__}:#{line_number}"
163
+ mfe[:location].should eq("#{__FILE__}:#{line_number}")
111
164
  end
112
165
 
113
166
  it "uses :caller if passed as an option" do
114
167
  example_metadata = metadata.for_example('example description', {:caller => ['example_file:42']})
115
- example_metadata[:location].should == 'example_file:42'
168
+ example_metadata[:location].should eq("example_file:42")
116
169
  end
117
170
 
118
171
  it "merges arbitrary options" do
119
- mfe[:arbitrary].should == :options
172
+ mfe[:arbitrary].should eq(:options)
120
173
  end
121
174
 
122
175
  it "points :example_group to the same hash object" do
123
176
  a = metadata.for_example("foo", {})[:example_group]
124
177
  b = metadata.for_example("bar", {})[:example_group]
125
178
  a[:description] = "new description"
126
- b[:description].should == "new description"
179
+ b[:description].should eq("new description")
127
180
  end
128
181
  end
129
182
 
@@ -133,7 +186,6 @@ module RSpec
133
186
  m = Metadata.new
134
187
  m.process('group')
135
188
 
136
- m = m.for_example("example", {})
137
189
  m[:example_group][:describes].should be_nil
138
190
  end
139
191
  end
@@ -143,7 +195,6 @@ module RSpec
143
195
  m = Metadata.new
144
196
  m.process(:group)
145
197
 
146
- m = m.for_example("example", {})
147
198
  m[:example_group][:describes].should be_nil
148
199
  end
149
200
  end
@@ -153,49 +204,73 @@ module RSpec
153
204
  m = Metadata.new
154
205
  m.process(String)
155
206
 
156
- m = m.for_example("example", {})
157
207
  m[:example_group][:describes].should be(String)
158
208
  end
159
209
  end
160
210
 
161
- context "with describes from a superclass metadata" do
162
- it "returns the superclass' described class" do
211
+ context "in a nested group" do
212
+ it "returns the parent group's described class" do
163
213
  sm = Metadata.new
164
214
  sm.process(String)
165
215
 
166
216
  m = Metadata.new(sm)
167
217
  m.process(Array)
168
218
 
169
- m = m.for_example("example", {})
170
219
  m[:example_group][:describes].should be(String)
171
220
  end
221
+
222
+ it "returns own described class if parent doesn't have one" do
223
+ sm = Metadata.new
224
+ sm.process("foo")
225
+
226
+ m = Metadata.new(sm)
227
+ m.process(Array)
228
+
229
+ m[:example_group][:describes].should be(Array)
230
+ end
231
+
232
+ it "can override a parent group's described class" do
233
+ parent = Metadata.new
234
+ parent.process(String)
235
+
236
+ child = Metadata.new(parent)
237
+ child.process(Fixnum)
238
+ child[:example_group][:describes] = Hash
239
+
240
+ grandchild = Metadata.new(child)
241
+ grandchild.process(Array)
242
+
243
+ grandchild[:example_group][:describes].should be(Hash)
244
+ child[:example_group][:describes].should be(Hash)
245
+ parent[:example_group][:describes].should be(String)
246
+ end
172
247
  end
173
248
  end
174
249
 
175
250
  describe ":description" do
176
251
  it "just has the example description" do
177
252
  m = Metadata.new
178
- m.process('group')
253
+ m.process("group")
179
254
 
180
255
  m = m.for_example("example", {})
181
- m[:description].should == "example"
256
+ m[:description].should eq("example")
182
257
  end
183
258
 
184
259
  context "with a string" do
185
260
  it "provides the submitted description" do
186
261
  m = Metadata.new
187
- m.process('group')
262
+ m.process("group")
188
263
 
189
- m[:example_group][:description].should == "group"
264
+ m[:example_group][:description].should eq("group")
190
265
  end
191
266
  end
192
267
 
193
268
  context "with a non-string" do
194
269
  it "provides the submitted description" do
195
270
  m = Metadata.new
196
- m.process('group')
271
+ m.process("group")
197
272
 
198
- m[:example_group][:description].should == "group"
273
+ m[:example_group][:description].should eq("group")
199
274
  end
200
275
  end
201
276
 
@@ -204,7 +279,16 @@ module RSpec
204
279
  m = Metadata.new
205
280
  m.process(Object, 'group')
206
281
 
207
- m[:example_group][:description].should == "Object group"
282
+ m[:example_group][:description].should eq("Object group")
283
+ end
284
+ end
285
+
286
+ context "with empty args" do
287
+ it "returns empty string for [:example_group][:description]" do
288
+ m = Metadata.new
289
+ m.process()
290
+
291
+ m[:example_group][:description].should eq("")
208
292
  end
209
293
  end
210
294
  end
@@ -215,17 +299,18 @@ module RSpec
215
299
  group_metadata.process('group')
216
300
 
217
301
  example_metadata = group_metadata.for_example("example", {})
218
- example_metadata[:full_description].should == "group example"
302
+ example_metadata[:full_description].should eq("group example")
219
303
  end
220
304
 
221
305
  it "concats nested example group descriptions" do
222
306
  parent = Metadata.new
223
- parent.process(Object, 'parent')
307
+ parent.process('parent')
224
308
 
225
309
  child = Metadata.new(parent)
226
310
  child.process('child')
227
311
 
228
- child[:example_group][:full_description].should == "Object parent child"
312
+ child[:example_group][:full_description].should eq("parent child")
313
+ child.for_example('example', child)[:full_description].should eq("parent child example")
229
314
  end
230
315
 
231
316
  %w[# . ::].each do |char|
@@ -258,7 +343,7 @@ module RSpec
258
343
  "./lib/rspec/core/foo.rb",
259
344
  "#{__FILE__}:#{__LINE__}"
260
345
  ])
261
- m[:example_group][:file_path].should == __FILE__
346
+ m[:example_group][:file_path].should eq(__FILE__)
262
347
  end
263
348
  end
264
349
 
@@ -266,19 +351,19 @@ module RSpec
266
351
  it "finds the line number with the first non-rspec lib file in the backtrace" do
267
352
  m = Metadata.new
268
353
  m.process({})
269
- m[:example_group][:line_number].should == __LINE__ - 1
354
+ m[:example_group][:line_number].should eq(__LINE__ - 1)
270
355
  end
271
356
 
272
357
  it "finds the line number with the first spec file with drive letter" do
273
358
  m = Metadata.new
274
359
  m.process(:caller => [ "C:/path/to/file_spec.rb:#{__LINE__}" ])
275
- m[:example_group][:line_number].should == __LINE__ - 1
360
+ m[:example_group][:line_number].should eq(__LINE__ - 1)
276
361
  end
277
362
 
278
363
  it "uses the number after the first : for ruby 1.9" do
279
364
  m = Metadata.new
280
365
  m.process(:caller => [ "#{__FILE__}:#{__LINE__}:999" ])
281
- m[:example_group][:line_number].should == __LINE__ - 1
366
+ m[:example_group][:line_number].should eq(__LINE__ - 1)
282
367
  end
283
368
  end
284
369
 
@@ -290,7 +375,7 @@ module RSpec
290
375
  child = Metadata.new(parent)
291
376
  child.process()
292
377
 
293
- child[:example_group][:example_group].should == parent[:example_group]
378
+ child[:example_group][:example_group].should eq(parent[:example_group])
294
379
  end
295
380
  end
296
381
  end