rspec-core 2.5.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +7 -0
- data/Gemfile +12 -14
- data/README.md +4 -1
- data/Rakefile +29 -12
- data/cucumber.yml +1 -1
- data/features/.nav +15 -9
- data/features/Autotest.md +31 -7
- data/features/Changelog.md +46 -3
- data/features/Upgrade.md +35 -2
- data/features/command_line/README.md +22 -0
- data/features/command_line/configure.feature +2 -2
- data/features/command_line/example_name_option.feature +10 -10
- data/features/command_line/exit_status.feature +4 -4
- data/features/command_line/format_option.feature +4 -4
- data/features/command_line/line_number_appended_to_path.feature +11 -11
- data/features/command_line/line_number_option.feature +2 -2
- data/features/command_line/rake_task.feature +3 -3
- data/features/command_line/tag.feature +30 -14
- data/features/configuration/alias_example_to.feature +48 -0
- data/features/configuration/custom_settings.feature +3 -3
- data/features/configuration/fail_fast.feature +3 -3
- data/features/configuration/read_options_from_file.feature +4 -4
- data/features/example_groups/basic_structure.feature +11 -15
- data/features/example_groups/shared_context.feature +74 -0
- data/features/example_groups/shared_example_group.feature +21 -17
- data/features/expectation_framework_integration/configure_expectation_framework.feature +15 -4
- data/features/filtering/exclusion_filters.feature +28 -4
- data/features/filtering/{implicit_filters.feature → if_and_unless.feature} +9 -7
- data/features/filtering/inclusion_filters.feature +26 -3
- data/features/filtering/run_all_when_everything_filtered.feature +2 -2
- data/features/formatters/custom_formatter.feature +1 -1
- data/features/formatters/text_formatter.feature +43 -0
- data/features/helper_methods/arbitrary_methods.feature +2 -2
- data/features/helper_methods/let.feature +2 -2
- data/features/helper_methods/modules.feature +149 -0
- data/features/hooks/around_hooks.feature +18 -11
- data/features/hooks/before_and_after_hooks.feature +15 -19
- data/features/hooks/filtering.feature +160 -124
- data/features/metadata/current_example.feature +17 -0
- data/features/metadata/described_class.feature +2 -2
- data/features/metadata/user_defined.feature +111 -0
- data/features/mock_framework_integration/use_any_framework.feature +1 -1
- data/features/mock_framework_integration/use_flexmock.feature +83 -10
- data/features/mock_framework_integration/use_mocha.feature +84 -10
- data/features/mock_framework_integration/use_rr.feature +85 -10
- data/features/mock_framework_integration/use_rspec.feature +84 -10
- data/features/pending/pending_examples.feature +8 -8
- data/features/spec_files/arbitrary_file_suffix.feature +1 -1
- data/features/step_definitions/additional_cli_steps.rb +11 -1
- data/features/subject/attribute_of_subject.feature +24 -4
- data/features/subject/explicit_subject.feature +5 -5
- data/features/subject/implicit_receiver.feature +2 -2
- data/features/subject/implicit_subject.feature +2 -2
- data/features/support/env.rb +6 -1
- data/lib/rspec/core/backward_compatibility.rb +12 -2
- data/lib/rspec/core/command_line.rb +2 -5
- data/lib/rspec/core/configuration.rb +70 -38
- data/lib/rspec/core/configuration_options.rb +6 -23
- data/lib/rspec/core/drb_command_line.rb +5 -11
- data/lib/rspec/core/example.rb +29 -21
- data/lib/rspec/core/example_group.rb +40 -8
- data/lib/rspec/core/extensions/object.rb +0 -1
- data/lib/rspec/core/formatters/base_formatter.rb +6 -0
- data/lib/rspec/core/formatters/base_text_formatter.rb +1 -1
- data/lib/rspec/core/formatters/helpers.rb +0 -4
- data/lib/rspec/core/hooks.rb +14 -4
- data/lib/rspec/core/metadata.rb +1 -1
- data/lib/rspec/core/metadata_hash_builder.rb +93 -0
- data/lib/rspec/core/mocking/with_flexmock.rb +2 -0
- data/lib/rspec/core/mocking/with_mocha.rb +2 -0
- data/lib/rspec/core/mocking/with_rr.rb +2 -0
- data/lib/rspec/core/mocking/with_rspec.rb +3 -1
- data/lib/rspec/core/option_parser.rb +9 -2
- data/lib/rspec/core/pending.rb +10 -3
- data/lib/rspec/core/reporter.rb +2 -2
- data/lib/rspec/core/runner.rb +38 -13
- data/lib/rspec/core/shared_example_group.rb +18 -4
- data/lib/rspec/core/subject.rb +4 -6
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +70 -18
- data/lib/rspec/core.rb +29 -0
- data/lib/rspec/monkey/spork/test_framework/rspec.rb +1 -0
- data/rspec-core.gemspec +3 -5
- data/spec/autotest/failed_results_re_spec.rb +2 -2
- data/spec/rspec/core/command_line_spec.rb +36 -2
- data/spec/rspec/core/configuration_spec.rb +150 -70
- data/spec/rspec/core/deprecations_spec.rb +21 -0
- data/spec/rspec/core/drb_command_line_spec.rb +21 -56
- data/spec/rspec/core/example_group_spec.rb +213 -56
- data/spec/rspec/core/example_spec.rb +110 -0
- data/spec/rspec/core/formatters/base_formatter_spec.rb +23 -2
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +9 -0
- data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
- data/spec/rspec/core/formatters/html_formatted-1.8.6.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +8 -10
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.9.1.html +5 -5
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +5 -5
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -1
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +8 -10
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +5 -5
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +5 -5
- data/spec/rspec/core/hooks_spec.rb +86 -0
- data/spec/rspec/core/metadata_spec.rb +7 -7
- data/spec/rspec/core/option_parser_spec.rb +26 -15
- data/spec/rspec/core/pending_example_spec.rb +12 -51
- data/spec/rspec/core/reporter_spec.rb +19 -3
- data/spec/rspec/core/resources/formatter_specs.rb +7 -1
- data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
- data/spec/rspec/core/runner_spec.rb +42 -10
- data/spec/rspec/core/shared_example_group_spec.rb +57 -21
- data/spec/rspec/core/subject_spec.rb +32 -11
- data/spec/rspec/core/world_spec.rb +147 -15
- data/spec/rspec/core_spec.rb +28 -0
- data/spec/spec_helper.rb +22 -2
- data/spec/support/matchers.rb +44 -13
- data/spec/support/shared_example_groups.rb +41 -0
- data/spec/support/spec_files.rb +44 -0
- data/spec.txt +1126 -0
- metadata +35 -16
- data/spec/ruby_forker.rb +0 -13
|
@@ -319,11 +319,11 @@ a {
|
|
|
319
319
|
./spec/rspec/core/formatters/html_formatter_spec.rb:46
|
|
320
320
|
./spec/rspec/core/formatters/html_formatter_spec.rb:45:in `chdir'
|
|
321
321
|
./spec/rspec/core/formatters/html_formatter_spec.rb:45</pre></div>
|
|
322
|
-
<pre class="ruby"><code><span class="linenum">
|
|
323
|
-
<span class="linenum">
|
|
324
|
-
<span class="offending"><span class="linenum">
|
|
325
|
-
<span class="linenum">
|
|
326
|
-
<span class="linenum">
|
|
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>
|
|
327
327
|
</div>
|
|
328
328
|
</dd>
|
|
329
329
|
</dl>
|
|
@@ -319,11 +319,11 @@ a {
|
|
|
319
319
|
./spec/rspec/core/formatters/html_formatter_spec.rb:46:in `block (4 levels) in <module:Formatters>'
|
|
320
320
|
./spec/rspec/core/formatters/html_formatter_spec.rb:45:in `chdir'
|
|
321
321
|
./spec/rspec/core/formatters/html_formatter_spec.rb:45:in `block (3 levels) in <module:Formatters>'</pre></div>
|
|
322
|
-
<pre class="ruby"><code><span class="linenum">
|
|
323
|
-
<span class="linenum">
|
|
324
|
-
<span class="offending"><span class="linenum">
|
|
325
|
-
<span class="linenum">
|
|
326
|
-
<span class="linenum">
|
|
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>
|
|
327
327
|
</div>
|
|
328
328
|
</dd>
|
|
329
329
|
</dl>
|
|
@@ -319,11 +319,11 @@ a {
|
|
|
319
319
|
./spec/rspec/core/formatters/html_formatter_spec.rb:46:in `block (4 levels) in <module:Formatters>'
|
|
320
320
|
./spec/rspec/core/formatters/html_formatter_spec.rb:45:in `chdir'
|
|
321
321
|
./spec/rspec/core/formatters/html_formatter_spec.rb:45:in `block (3 levels) in <module:Formatters>'</pre></div>
|
|
322
|
-
<pre class="ruby"><code><span class="linenum">
|
|
323
|
-
<span class="linenum">
|
|
324
|
-
<span class="offending"><span class="linenum">
|
|
325
|
-
<span class="linenum">
|
|
326
|
-
<span class="linenum">
|
|
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>
|
|
327
327
|
</div>
|
|
328
328
|
</dd>
|
|
329
329
|
</dl>
|
|
@@ -319,11 +319,11 @@ a {
|
|
|
319
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>
|
|
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
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> </pre></div>
|
|
322
|
-
<pre class="ruby"><code><span class="linenum">
|
|
323
|
-
<span class="linenum">
|
|
324
|
-
<span class="offending"><span class="linenum">
|
|
325
|
-
<span class="linenum">
|
|
326
|
-
<span class="linenum">
|
|
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>
|
|
327
327
|
</div>
|
|
328
328
|
</dd>
|
|
329
329
|
</dl>
|
|
@@ -318,13 +318,12 @@ a {
|
|
|
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
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>
|
|
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>
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
<span class="linenum">
|
|
325
|
-
<span class="
|
|
326
|
-
<span class="linenum">
|
|
327
|
-
<span class="linenum">26</span> <span class="ident">throw</span> <span class="symbol">:pending_declared_in_example</span><span class="punct">,</span> <span class="ident">message</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> </pre></div>
|
|
322
|
+
<pre class="ruby"><code><span class="linenum">24</span> <span class="keyword">rescue</span> <span class="constant">Exception</span>
|
|
323
|
+
<span class="linenum">25</span> <span class="keyword">end</span>
|
|
324
|
+
<span class="offending"><span class="linenum">26</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">27</span> <span class="keyword">end</span>
|
|
326
|
+
<span class="linenum">28</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>
|
|
328
327
|
</div>
|
|
329
328
|
</dd>
|
|
330
329
|
</dl>
|
|
@@ -357,8 +356,7 @@ expected 2
|
|
|
357
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'
|
|
358
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>
|
|
359
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'
|
|
360
|
-
<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>
|
|
361
|
-
:1</pre></div>
|
|
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> </pre></div>
|
|
362
360
|
<pre class="ruby"><code><span class="linenum">27</span> <span class="keyword">end</span>
|
|
363
361
|
<span class="linenum">28</span>
|
|
364
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>
|
|
@@ -385,7 +383,7 @@ expected 2
|
|
|
385
383
|
<dd class="example failed">
|
|
386
384
|
<span class="failed_spec_name">fails with a backtrace containing an erb file</span>
|
|
387
385
|
<div class="failure" id="failure_4">
|
|
388
|
-
<div class="message"><pre
|
|
386
|
+
<div class="message"><pre>Exception</pre></div>
|
|
389
387
|
<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>
|
|
390
388
|
<pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for /foo.html.erb</span></code></pre>
|
|
391
389
|
</div>
|
|
@@ -319,11 +319,11 @@ a {
|
|
|
319
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>
|
|
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
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> </pre></div>
|
|
322
|
-
<pre class="ruby"><code><span class="linenum">
|
|
323
|
-
<span class="linenum">
|
|
324
|
-
<span class="offending"><span class="linenum">
|
|
325
|
-
<span class="linenum">
|
|
326
|
-
<span class="linenum">
|
|
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>
|
|
327
327
|
</div>
|
|
328
328
|
</dd>
|
|
329
329
|
</dl>
|
|
@@ -319,11 +319,11 @@ a {
|
|
|
319
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>'
|
|
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
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">
|
|
323
|
-
<span class="linenum">
|
|
324
|
-
<span class="offending"><span class="linenum">
|
|
325
|
-
<span class="linenum">
|
|
326
|
-
<span class="linenum">
|
|
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>
|
|
327
327
|
</div>
|
|
328
328
|
</dd>
|
|
329
329
|
</dl>
|
|
@@ -319,11 +319,11 @@ a {
|
|
|
319
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>'
|
|
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
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">
|
|
323
|
-
<span class="linenum">
|
|
324
|
-
<span class="offending"><span class="linenum">
|
|
325
|
-
<span class="linenum">
|
|
326
|
-
<span class="linenum">
|
|
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>
|
|
327
327
|
</div>
|
|
328
328
|
</dd>
|
|
329
329
|
</dl>
|
|
@@ -2,6 +2,84 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
module RSpec::Core
|
|
4
4
|
describe Hooks do
|
|
5
|
+
class HooksHost
|
|
6
|
+
include Hooks
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
[:before, :after, :around].each do |type|
|
|
10
|
+
[:each, :all].each do |scope|
|
|
11
|
+
next if type == :around && scope == :all
|
|
12
|
+
|
|
13
|
+
describe "##{type}(#{scope})" do
|
|
14
|
+
it_behaves_like "metadata hash builder" do
|
|
15
|
+
define_method :metadata_hash do |*args|
|
|
16
|
+
instance = HooksHost.new
|
|
17
|
+
args.unshift scope if scope
|
|
18
|
+
hooks = instance.send(type, *args) { }
|
|
19
|
+
hooks.first.options
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
[true, false].each do |config_value|
|
|
26
|
+
context "when RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values is set to #{config_value}" do
|
|
27
|
+
before(:each) do
|
|
28
|
+
Kernel.stub(:warn)
|
|
29
|
+
RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = config_value }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe "##{type}(no scope)" do
|
|
33
|
+
let(:instance) { HooksHost.new }
|
|
34
|
+
|
|
35
|
+
it "defaults to :each scope if no arguments are given" do
|
|
36
|
+
hooks = instance.send(type) { }
|
|
37
|
+
hook = hooks.first
|
|
38
|
+
instance.hooks[type][:each].should include(hook)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "defaults to :each scope if the only argument is a metadata hash" do
|
|
42
|
+
hooks = instance.send(type, :foo => :bar) { }
|
|
43
|
+
hook = hooks.first
|
|
44
|
+
instance.hooks[type][:each].should include(hook)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "raises an error if only metadata symbols are given as arguments" do
|
|
48
|
+
expect { instance.send(type, :foo, :bar) { } }.to raise_error(ArgumentError)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
[:before, :after].each do |type|
|
|
56
|
+
[:each, :all, :suite].each do |scope|
|
|
57
|
+
[true, false].each do |config_value|
|
|
58
|
+
context "when RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values is set to #{config_value}" do
|
|
59
|
+
before(:each) do
|
|
60
|
+
RSpec.configure { |c| c.treat_symbols_as_metadata_keys_with_true_values = config_value }
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe "##{type}(#{scope.inspect})" do
|
|
64
|
+
let(:instance) { HooksHost.new }
|
|
65
|
+
let!(:hook) do
|
|
66
|
+
hooks = instance.send(type, scope) { }
|
|
67
|
+
hooks.first
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "does not make #{scope.inspect} a metadata key" do
|
|
71
|
+
hook.options.should be_empty
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "is scoped to #{scope.inspect}" do
|
|
75
|
+
instance.hooks[type][scope].should include(hook)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
5
83
|
describe "#around" do
|
|
6
84
|
context "when not running the example within the around block" do
|
|
7
85
|
it "does not run the example" do
|
|
@@ -52,6 +130,14 @@ module RSpec::Core
|
|
|
52
130
|
examples.should have(1).example
|
|
53
131
|
end
|
|
54
132
|
end
|
|
133
|
+
|
|
134
|
+
describe Hooks::Hook do
|
|
135
|
+
it "requires a block" do
|
|
136
|
+
lambda {
|
|
137
|
+
Hooks::BeforeHook.new :foo => :bar
|
|
138
|
+
}.should raise_error("no block given for before hook")
|
|
139
|
+
end
|
|
140
|
+
end
|
|
55
141
|
end
|
|
56
142
|
end
|
|
57
143
|
end
|
|
@@ -240,13 +240,13 @@ module RSpec
|
|
|
240
240
|
|
|
241
241
|
%w[# . ::].each do |char|
|
|
242
242
|
context "with a nested description starting with #{char}" do
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
243
|
+
it "removes the space" do
|
|
244
|
+
parent = Metadata.new
|
|
245
|
+
parent.process("Object")
|
|
246
|
+
child = Metadata.new(parent)
|
|
247
|
+
child.process("#{char}method")
|
|
248
|
+
child[:example_group][:full_description].should eq("Object#{char}method")
|
|
249
|
+
end
|
|
250
250
|
end
|
|
251
251
|
end
|
|
252
252
|
end
|
|
@@ -2,13 +2,10 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
module RSpec::Core
|
|
4
4
|
describe OptionParser do
|
|
5
|
-
before do
|
|
6
|
-
RSpec.stub(:deprecate)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
5
|
let(:output_file){ mock File }
|
|
10
6
|
|
|
11
7
|
before do
|
|
8
|
+
RSpec.stub(:deprecate)
|
|
12
9
|
File.stub(:open).with("foo.txt",'w') { (output_file) }
|
|
13
10
|
end
|
|
14
11
|
|
|
@@ -30,17 +27,12 @@ module RSpec::Core
|
|
|
30
27
|
end
|
|
31
28
|
end
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
describe "-f" do
|
|
41
|
-
it "defines the formatter" do
|
|
42
|
-
options = Parser.parse!(%w[-f doc])
|
|
43
|
-
options[:formatters].first.should eq(["doc"])
|
|
30
|
+
%w[--format -f].each do |option|
|
|
31
|
+
describe option do
|
|
32
|
+
it "defines the formatter" do
|
|
33
|
+
options = Parser.parse!([option, 'doc'])
|
|
34
|
+
options[:formatters].first.should eq(["doc"])
|
|
35
|
+
end
|
|
44
36
|
end
|
|
45
37
|
end
|
|
46
38
|
|
|
@@ -71,5 +63,24 @@ module RSpec::Core
|
|
|
71
63
|
end
|
|
72
64
|
end
|
|
73
65
|
end
|
|
66
|
+
|
|
67
|
+
%w[--example -e].each do |option|
|
|
68
|
+
describe option do
|
|
69
|
+
it "escapes the arg" do
|
|
70
|
+
options = Parser.parse!([option, "this (and that)"])
|
|
71
|
+
"this (and that)".should match(options[:full_description])
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
%w[--pattern -P].each do |option|
|
|
77
|
+
describe option do
|
|
78
|
+
it "sets the filename pattern" do
|
|
79
|
+
options = Parser.parse!([option, 'spec/**/*.spec'])
|
|
80
|
+
options[:pattern].should eq('spec/**/*.spec')
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
74
85
|
end
|
|
75
86
|
end
|
|
@@ -1,54 +1,5 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
RSpec::Matchers.define :be_pending_with do |message|
|
|
4
|
-
match do |example|
|
|
5
|
-
example.metadata[:pending] && example.metadata[:execution_result][:pending_message] == message
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
failure_message_for_should do |example|
|
|
9
|
-
"expected example to pending with #{message.inspect}, got #{example.metadata[:execution_result][:pending_message].inspect}"
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
RSpec::Matchers.define :fail_with do |exception_klass|
|
|
14
|
-
match do |example|
|
|
15
|
-
failure_reason(example, exception_klass).nil?
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
failure_message_for_should do |example|
|
|
19
|
-
"expected example to fail with a #{exception_klass} exception, but #{failure_reason(example, exception_klass)}"
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def failure_reason(example, exception_klass)
|
|
23
|
-
result = example.metadata[:execution_result]
|
|
24
|
-
case
|
|
25
|
-
when example.metadata[:pending] then "was pending"
|
|
26
|
-
when result[:status] != 'failed' then result[:status]
|
|
27
|
-
when !result[:exception].is_a?(exception_klass) then "failed with a #{result[:exception].class}"
|
|
28
|
-
else nil
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
RSpec::Matchers.define :pass do
|
|
34
|
-
match do |example|
|
|
35
|
-
failure_reason(example).nil?
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
failure_message_for_should do |example|
|
|
39
|
-
"expected example to pass, but #{failure_reason(example)}"
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def failure_reason(example)
|
|
43
|
-
result = example.metadata[:execution_result]
|
|
44
|
-
case
|
|
45
|
-
when example.metadata[:pending] then "was pending"
|
|
46
|
-
when result[:status] != 'passed' then result[:status]
|
|
47
|
-
else nil
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
3
|
describe "an example" do
|
|
53
4
|
context "with no block" do
|
|
54
5
|
it "is listed as pending with 'Not Yet Implemented'" do
|
|
@@ -121,10 +72,10 @@ describe "an example" do
|
|
|
121
72
|
end
|
|
122
73
|
|
|
123
74
|
context "with a block" do
|
|
124
|
-
def run_example(*pending_args)
|
|
75
|
+
def run_example(*pending_args, &block)
|
|
125
76
|
group = RSpec::Core::ExampleGroup.describe('group') do
|
|
126
77
|
it "does something" do
|
|
127
|
-
pending(*pending_args) {
|
|
78
|
+
pending(*pending_args) { block.call if block }
|
|
128
79
|
end
|
|
129
80
|
end
|
|
130
81
|
example = group.examples.first
|
|
@@ -182,6 +133,16 @@ describe "an example" do
|
|
|
182
133
|
end
|
|
183
134
|
end
|
|
184
135
|
|
|
136
|
+
context "that fails due to a failed message expectation" do
|
|
137
|
+
def run_example(*pending_args)
|
|
138
|
+
super(*pending_args) { "foo".should_receive(:bar) }
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it "passes" do
|
|
142
|
+
run_example("just because").should be_pending
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
185
146
|
context "that passes" do
|
|
186
147
|
def run_example(*pending_args)
|
|
187
148
|
super(*pending_args) { 3.should == 3 }
|
|
@@ -30,13 +30,17 @@ module RSpec::Core
|
|
|
30
30
|
it "passes example_group_started and example_group_finished messages to that formatter in that order" do
|
|
31
31
|
order = []
|
|
32
32
|
|
|
33
|
-
formatter = stub("formatter")
|
|
33
|
+
formatter = stub("formatter").as_null_object
|
|
34
34
|
formatter.stub(:example_group_started) { |group| order << "Started: #{group.description}" }
|
|
35
35
|
formatter.stub(:example_group_finished) { |group| order << "Finished: #{group.description}" }
|
|
36
36
|
|
|
37
37
|
group = ExampleGroup.describe("root")
|
|
38
|
-
group.describe("context 1")
|
|
39
|
-
|
|
38
|
+
group.describe("context 1") do
|
|
39
|
+
example("ignore") {}
|
|
40
|
+
end
|
|
41
|
+
group.describe("context 2") do
|
|
42
|
+
example("ignore") {}
|
|
43
|
+
end
|
|
40
44
|
|
|
41
45
|
group.run(Reporter.new(formatter))
|
|
42
46
|
|
|
@@ -51,6 +55,18 @@ module RSpec::Core
|
|
|
51
55
|
end
|
|
52
56
|
end
|
|
53
57
|
|
|
58
|
+
context "given an example group with no examples" do
|
|
59
|
+
it "does not pass example_group_started or example_group_finished to formatter" do
|
|
60
|
+
formatter = stub("formatter").as_null_object
|
|
61
|
+
formatter.should_not_receive(:example_group_started)
|
|
62
|
+
formatter.should_not_receive(:example_group_finished)
|
|
63
|
+
|
|
64
|
+
group = ExampleGroup.describe("root")
|
|
65
|
+
|
|
66
|
+
group.run(Reporter.new(formatter))
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
54
70
|
context "given multiple formatters" do
|
|
55
71
|
it "passes messages to all formatters" do
|
|
56
72
|
formatters = [double("formatter"), double("formatter")]
|
|
@@ -48,7 +48,13 @@ describe "a failing spec with odd backtraces" do
|
|
|
48
48
|
["/foo.html.erb:1:in `<main>': foo (RuntimeError)",
|
|
49
49
|
" from /lib/ruby/1.9.1/erb.rb:753:in `eval'"]
|
|
50
50
|
end
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
def e.message
|
|
53
|
+
# Redefining message steps around this behaviour
|
|
54
|
+
# on JRuby: http://jira.codehaus.org/browse/JRUBY-5637
|
|
55
|
+
self.class.name
|
|
56
|
+
end
|
|
57
|
+
|
|
52
58
|
raise e
|
|
53
59
|
end
|
|
54
60
|
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module RSpec::Matchers
|
|
4
|
+
def __method_with_super
|
|
5
|
+
super
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
module ModThatIncludesMatchers
|
|
9
|
+
include RSpec::Matchers
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
RSpec.configure do |c|
|
|
13
|
+
c.include RSpec::Matchers, :include_rspec_matchers => true
|
|
14
|
+
c.include ModThatIncludesMatchers, :include_mod_that_includes_rspec_matchers => true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe self do
|
|
18
|
+
shared_examples_for "a normal module with a method that supers" do
|
|
19
|
+
it "raises the expected error (and not SystemStackError)" do
|
|
20
|
+
expect { __method_with_super }.to raise_error(NoMethodError) # there is no __method_with_super in an ancestor
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it_behaves_like "a normal module with a method that supers"
|
|
25
|
+
|
|
26
|
+
context "when RSpec::Matchers has been included in an example group" do
|
|
27
|
+
include RSpec::Matchers
|
|
28
|
+
it_behaves_like "a normal module with a method that supers"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "when a module that includes RSpec::Matchers has been included in an example group" do
|
|
32
|
+
include RSpec::Matchers::ModThatIncludesMatchers
|
|
33
|
+
it_behaves_like "a normal module with a method that supers"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "when RSpec::Matchers is included via configuration", :include_rspec_matchers => true do
|
|
37
|
+
it_behaves_like "a normal module with a method that supers"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context "when RSpec::Matchers is included in a module that is included via configuration", :include_mod_that_includes_rspec_matchers => true do
|
|
41
|
+
it_behaves_like "a normal module with a method that supers"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|