rspec-core 2.5.2 → 2.6.0.rc2
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 +10 -13
- data/README.md +4 -1
- data/Rakefile +29 -12
- data/cucumber.yml +1 -1
- data/features/.nav +10 -4
- data/features/Autotest.md +31 -7
- data/features/Changelog.md +36 -6
- 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 +26 -10
- 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 +1 -1
- data/features/formatters/custom_formatter.feature +1 -1
- data/features/formatters/text_formatter.feature +45 -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 +11 -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.rb +22 -0
- data/lib/rspec/core/backward_compatibility.rb +12 -2
- data/lib/rspec/core/command_line.rb +1 -4
- data/lib/rspec/core/configuration.rb +25 -17
- 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 +36 -4
- 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 +5 -2
- data/lib/rspec/core/pending.rb +10 -3
- data/lib/rspec/core/reporter.rb +2 -2
- data/lib/rspec/core/runner.rb +7 -1
- 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 +16 -4
- data/rspec-core.gemspec +4 -3
- data/spec.txt +1126 -0
- data/spec/autotest/failed_results_re_spec.rb +2 -2
- data/spec/rspec/core/command_line_spec.rb +0 -2
- data/spec/rspec/core/configuration_spec.rb +84 -1
- data/spec/rspec/core/deprecations_spec.rb +21 -0
- data/spec/rspec/core/drb_command_line_spec.rb +3 -11
- 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 +8 -0
- 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 +35 -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 +38 -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
- metadata +39 -16
|
@@ -9,6 +9,66 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
|
|
|
9
9
|
example_group.example('example description')
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
it_behaves_like "metadata hash builder" do
|
|
13
|
+
def metadata_hash(*args)
|
|
14
|
+
example = example_group.example('example description', *args)
|
|
15
|
+
example.metadata
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe "auto-generated example descriptions" do
|
|
20
|
+
let(:generated_description) { "the generated description" }
|
|
21
|
+
let(:rspec_example) { example_group.specify { 5.should == 5 } }
|
|
22
|
+
before(:each) { RSpec::Matchers.stub(:generated_description => generated_description) }
|
|
23
|
+
|
|
24
|
+
def expect_with(*frameworks)
|
|
25
|
+
RSpec.configuration.stub(:expecting_with_rspec?).and_return(frameworks.include?(:rspec))
|
|
26
|
+
|
|
27
|
+
if frameworks.include?(:stdlib)
|
|
28
|
+
example_group.class_eval do
|
|
29
|
+
def assert(val)
|
|
30
|
+
raise "Expected #{val} to be true" unless val
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "when `expect_with :rspec` is configured" do
|
|
37
|
+
before(:each) { expect_with :rspec }
|
|
38
|
+
|
|
39
|
+
it "generates a description for an example with no description" do
|
|
40
|
+
expect {
|
|
41
|
+
example_group.run
|
|
42
|
+
}.to change { rspec_example.metadata[:description] }.from("").to(generated_description)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context "when `expect_with :rspec, :stdlib` is configured" do
|
|
47
|
+
before(:each) { expect_with :rspec, :stdlib }
|
|
48
|
+
|
|
49
|
+
it "generates a description for an example with no description" do
|
|
50
|
+
expect {
|
|
51
|
+
example_group.run
|
|
52
|
+
}.to change { rspec_example.metadata[:description] }.from("").to(generated_description)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context "when `expect_with :stdlib` is configured" do
|
|
57
|
+
let!(:stdlib_example) { example_group.specify { assert 5 == 5 } }
|
|
58
|
+
before(:each) { expect_with :stdlib }
|
|
59
|
+
|
|
60
|
+
it "does not attempt to get the generated description from RSpec::Matchers" do
|
|
61
|
+
RSpec::Matchers.should_not_receive(:generated_description)
|
|
62
|
+
example_group.run
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "fails an example with no description" do
|
|
66
|
+
example_group.run
|
|
67
|
+
stdlib_example.should have_failed_with(NotImplementedError)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
12
72
|
describe '#described_class' do
|
|
13
73
|
it "returns the class (if any) of the outermost example group" do
|
|
14
74
|
described_class.should == RSpec::Core::Example
|
|
@@ -33,6 +93,14 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
|
|
|
33
93
|
end
|
|
34
94
|
|
|
35
95
|
describe "#run" do
|
|
96
|
+
it "sets its reference to the example group instance to nil" do
|
|
97
|
+
group = RSpec::Core::ExampleGroup.describe do
|
|
98
|
+
example('example') { 1.should eq(1) }
|
|
99
|
+
end
|
|
100
|
+
group.run
|
|
101
|
+
group.examples.first.instance_variable_get("@example_group_instance").should be_nil
|
|
102
|
+
end
|
|
103
|
+
|
|
36
104
|
it "runs after(:each) when the example passes" do
|
|
37
105
|
after_run = false
|
|
38
106
|
group = RSpec::Core::ExampleGroup.describe do
|
|
@@ -108,6 +176,35 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
|
|
|
108
176
|
"around (after)"
|
|
109
177
|
])
|
|
110
178
|
end
|
|
179
|
+
|
|
180
|
+
context "clearing ivars" do
|
|
181
|
+
it "sets ivars to nil to prep them for GC" do
|
|
182
|
+
group = RSpec::Core::ExampleGroup.describe do
|
|
183
|
+
before(:all) { @before_all = :before_all }
|
|
184
|
+
before(:each) { @before_each = :before_each }
|
|
185
|
+
after(:each) { @after_each = :after_each }
|
|
186
|
+
after(:all) { @after_all = :after_all }
|
|
187
|
+
end
|
|
188
|
+
example = group.example("does something") do
|
|
189
|
+
@in_example = :in_example
|
|
190
|
+
end
|
|
191
|
+
example_group_instance = group.new
|
|
192
|
+
example.run(example_group_instance, double('reporter').as_null_object)
|
|
193
|
+
|
|
194
|
+
%w[@before_all @before_each @after_each @after_all].each do |ivar|
|
|
195
|
+
example_group_instance.instance_variable_get(ivar).should be_nil
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
it "does not impact the before_all_ivars which are copied to each example" do
|
|
200
|
+
group = RSpec::Core::ExampleGroup.describe do
|
|
201
|
+
before(:all) { @before_all = "abc" }
|
|
202
|
+
example("first") { @before_all.should_not be_nil }
|
|
203
|
+
example("second") { @before_all.should_not be_nil }
|
|
204
|
+
end
|
|
205
|
+
group.run.should be_true
|
|
206
|
+
end
|
|
207
|
+
end
|
|
111
208
|
end
|
|
112
209
|
|
|
113
210
|
describe "#pending" do
|
|
@@ -119,6 +216,19 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
|
|
|
119
216
|
group.run
|
|
120
217
|
group.examples.first.should be_pending
|
|
121
218
|
end
|
|
219
|
+
|
|
220
|
+
it "allows post-example processing in around hooks (see https://github.com/rspec/rspec-core/issues/322)" do
|
|
221
|
+
blah = nil
|
|
222
|
+
group = RSpec::Core::ExampleGroup.describe do
|
|
223
|
+
around do |example|
|
|
224
|
+
example.run
|
|
225
|
+
blah = :success
|
|
226
|
+
end
|
|
227
|
+
example { pending }
|
|
228
|
+
end
|
|
229
|
+
group.run
|
|
230
|
+
blah.should be(:success)
|
|
231
|
+
end
|
|
122
232
|
end
|
|
123
233
|
|
|
124
234
|
context "in before(:each)" do
|
|
@@ -34,18 +34,19 @@ describe RSpec::Core::Formatters::BaseFormatter do
|
|
|
34
34
|
|
|
35
35
|
context "when String alias to_int to_i" do
|
|
36
36
|
before do
|
|
37
|
-
|
|
37
|
+
String.class_eval do
|
|
38
38
|
alias :to_int :to_i
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
after do
|
|
43
|
-
|
|
43
|
+
String.class_eval do
|
|
44
44
|
undef to_int
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
it "doesn't hang when file exists" do
|
|
49
|
+
pending("This issue still exists on JRuby, but should be resolved shortly: https://github.com/rspec/rspec-core/issues/295", :if => RUBY_PLATFORM == 'java')
|
|
49
50
|
exception = mock(:Exception, :backtrace => [ "#{__FILE__}:#{__LINE__}"])
|
|
50
51
|
|
|
51
52
|
example = mock(:Example, :file_path => __FILE__)
|
|
@@ -56,4 +57,24 @@ describe RSpec::Core::Formatters::BaseFormatter do
|
|
|
56
57
|
end
|
|
57
58
|
end
|
|
58
59
|
|
|
60
|
+
describe "#format_backtrace" do
|
|
61
|
+
let(:rspec_expectations_dir) { "/path/to/rspec-expectations/lib" }
|
|
62
|
+
let(:rspec_core_dir) { "/path/to/rspec-core/lib" }
|
|
63
|
+
let(:backtrace) do
|
|
64
|
+
[
|
|
65
|
+
"#{rspec_expectations_dir}/rspec/matchers/operator_matcher.rb:51:in `eval_match'",
|
|
66
|
+
"#{rspec_expectations_dir}/rspec/matchers/operator_matcher.rb:29:in `=='",
|
|
67
|
+
"./my_spec.rb:5",
|
|
68
|
+
"#{rspec_core_dir}/rspec/core/example.rb:52:in `run'",
|
|
69
|
+
"#{rspec_core_dir}/rspec/core/runner.rb:37:in `run'",
|
|
70
|
+
RSpec::Core::Runner::AT_EXIT_HOOK_BACKTRACE_LINE,
|
|
71
|
+
"./my_spec.rb:3"
|
|
72
|
+
]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "removes lines from rspec and lines that come before the invocation of the at_exit autorun hook" do
|
|
76
|
+
formatter.format_backtrace(backtrace, stub.as_null_object).should == ["./my_spec.rb:5"]
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
59
80
|
end
|
|
@@ -46,6 +46,15 @@ module RSpec::Core::Formatters
|
|
|
46
46
|
output.string.should =~ /(\s+)expected \"that\"\n\1 got \"this\"/m
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
+
context "with an exception without a message" do
|
|
50
|
+
it "does not throw NoMethodError" do
|
|
51
|
+
exception_without_message = Exception.new()
|
|
52
|
+
exception_without_message.stub(:message) { nil }
|
|
53
|
+
group.example("example name") { raise exception_without_message }
|
|
54
|
+
expect { run_all_and_dump_failures }.not_to raise_error(NoMethodError)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
49
58
|
context "with an exception class other than RSpec" do
|
|
50
59
|
it "does not show the error class" do
|
|
51
60
|
group.example("example name") { raise NameError.new('foo') }
|
|
@@ -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>
|
|
@@ -318,13 +318,12 @@ a {
|
|
|
318
318
|
./spec/rspec/core/formatters/html_formatter_spec.rb:46:in `open'
|
|
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
|
-
./spec/rspec/core/formatters/html_formatter_spec.rb:45
|
|
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
|
+
./spec/rspec/core/formatters/html_formatter_spec.rb:45</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
|
./spec/rspec/core/formatters/html_formatter_spec.rb:46:in `open'
|
|
358
357
|
./spec/rspec/core/formatters/html_formatter_spec.rb:46
|
|
359
358
|
./spec/rspec/core/formatters/html_formatter_spec.rb:45:in `chdir'
|
|
360
|
-
./spec/rspec/core/formatters/html_formatter_spec.rb:45
|
|
361
|
-
:1</pre></div>
|
|
359
|
+
./spec/rspec/core/formatters/html_formatter_spec.rb:45</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>/foo.html.erb:1: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
|
./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
|