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
|
@@ -30,7 +30,7 @@ Feature: around hooks
|
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
"""
|
|
33
|
-
When I run
|
|
33
|
+
When I run `rspec example_spec.rb`
|
|
34
34
|
Then the output should contain:
|
|
35
35
|
"""
|
|
36
36
|
open transaction
|
|
@@ -53,7 +53,7 @@ Feature: around hooks
|
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
"""
|
|
56
|
-
When I run
|
|
56
|
+
When I run `rspec example_spec.rb`
|
|
57
57
|
Then the output should contain:
|
|
58
58
|
"""
|
|
59
59
|
around each before
|
|
@@ -74,7 +74,7 @@ Feature: around hooks
|
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
"""
|
|
77
|
-
When I run
|
|
77
|
+
When I run `rspec example_spec.rb`
|
|
78
78
|
Then the output should contain "this should show up in the output"
|
|
79
79
|
|
|
80
80
|
Scenario: define a global around hook
|
|
@@ -94,7 +94,7 @@ Feature: around hooks
|
|
|
94
94
|
end
|
|
95
95
|
end
|
|
96
96
|
"""
|
|
97
|
-
When I run
|
|
97
|
+
When I run `rspec example_spec.rb`
|
|
98
98
|
Then the output should contain:
|
|
99
99
|
"""
|
|
100
100
|
around each before
|
|
@@ -125,7 +125,7 @@ Feature: around hooks
|
|
|
125
125
|
end
|
|
126
126
|
end
|
|
127
127
|
"""
|
|
128
|
-
When I run
|
|
128
|
+
When I run `rspec example_spec.rb`
|
|
129
129
|
Then the output should contain:
|
|
130
130
|
"""
|
|
131
131
|
around each before
|
|
@@ -158,7 +158,7 @@ Feature: around hooks
|
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
160
|
"""
|
|
161
|
-
When I run
|
|
161
|
+
When I run `rspec example_spec.rb`
|
|
162
162
|
Then the output should contain:
|
|
163
163
|
"""
|
|
164
164
|
before all
|
|
@@ -189,7 +189,7 @@ Feature: around hooks
|
|
|
189
189
|
end
|
|
190
190
|
end
|
|
191
191
|
"""
|
|
192
|
-
When I run
|
|
192
|
+
When I run `rspec example_spec.rb`
|
|
193
193
|
Then the output should contain "1 example, 0 failure"
|
|
194
194
|
|
|
195
195
|
Scenario: implicitly pending examples are detected as Not Yet Implemented
|
|
@@ -203,7 +203,7 @@ Feature: around hooks
|
|
|
203
203
|
it "should be detected as Not Yet Implemented"
|
|
204
204
|
end
|
|
205
205
|
"""
|
|
206
|
-
When I run
|
|
206
|
+
When I run `rspec example_spec.rb`
|
|
207
207
|
Then the output should contain "1 example, 0 failures, 1 pending"
|
|
208
208
|
And the output should contain:
|
|
209
209
|
"""
|
|
@@ -226,7 +226,7 @@ Feature: around hooks
|
|
|
226
226
|
end
|
|
227
227
|
end
|
|
228
228
|
"""
|
|
229
|
-
When I run
|
|
229
|
+
When I run `rspec example_spec.rb`
|
|
230
230
|
Then the output should contain "1 example, 0 failures, 1 pending"
|
|
231
231
|
And the output should contain:
|
|
232
232
|
"""
|
|
@@ -256,7 +256,7 @@ Feature: around hooks
|
|
|
256
256
|
end
|
|
257
257
|
end
|
|
258
258
|
"""
|
|
259
|
-
When I run
|
|
259
|
+
When I run `rspec example_spec.rb`
|
|
260
260
|
Then the output should contain "1 example, 0 failure"
|
|
261
261
|
And the output should contain:
|
|
262
262
|
"""
|
|
@@ -316,7 +316,7 @@ Feature: around hooks
|
|
|
316
316
|
end
|
|
317
317
|
end
|
|
318
318
|
"""
|
|
319
|
-
When I run
|
|
319
|
+
When I run `rspec example_spec.rb`
|
|
320
320
|
Then the output should contain "1 example, 0 failure"
|
|
321
321
|
And the output should contain:
|
|
322
322
|
"""
|
|
@@ -52,7 +52,7 @@ Feature: before and after hooks
|
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
"""
|
|
55
|
-
When I run
|
|
55
|
+
When I run `rspec before_each_spec.rb`
|
|
56
56
|
Then the examples should all pass
|
|
57
57
|
|
|
58
58
|
Scenario: define before(:all) block in example group
|
|
@@ -86,10 +86,10 @@ Feature: before and after hooks
|
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
"""
|
|
89
|
-
When I run
|
|
89
|
+
When I run `rspec before_all_spec.rb`
|
|
90
90
|
Then the examples should all pass
|
|
91
91
|
|
|
92
|
-
When I run
|
|
92
|
+
When I run `rspec before_all_spec.rb:15`
|
|
93
93
|
Then the examples should all pass
|
|
94
94
|
|
|
95
95
|
Scenario: failure in before(:all) block
|
|
@@ -124,7 +124,7 @@ Feature: before and after hooks
|
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
126
|
"""
|
|
127
|
-
When I run
|
|
127
|
+
When I run `rspec before_all_spec.rb --format documentation`
|
|
128
128
|
Then the output should contain "5 examples, 5 failures"
|
|
129
129
|
And the output should contain:
|
|
130
130
|
"""
|
|
@@ -139,15 +139,12 @@ Feature: before and after hooks
|
|
|
139
139
|
after all ran
|
|
140
140
|
"""
|
|
141
141
|
|
|
142
|
-
When I run
|
|
142
|
+
When I run `rspec before_all_spec.rb:9 --format documentation`
|
|
143
143
|
Then the output should contain "1 example, 1 failure"
|
|
144
144
|
And the output should contain:
|
|
145
145
|
"""
|
|
146
146
|
an error in before(:all)
|
|
147
147
|
fails this example, too (FAILED - 1)
|
|
148
|
-
nested group
|
|
149
|
-
yet another level deep
|
|
150
|
-
after all ran
|
|
151
148
|
"""
|
|
152
149
|
|
|
153
150
|
Scenario: failure in after(:all) block
|
|
@@ -165,7 +162,7 @@ Feature: before and after hooks
|
|
|
165
162
|
end
|
|
166
163
|
end
|
|
167
164
|
"""
|
|
168
|
-
When I run
|
|
165
|
+
When I run `rspec after_all_spec.rb`
|
|
169
166
|
Then the examples should all pass
|
|
170
167
|
And the output should contain:
|
|
171
168
|
"""
|
|
@@ -200,7 +197,7 @@ Feature: before and after hooks
|
|
|
200
197
|
end
|
|
201
198
|
end
|
|
202
199
|
"""
|
|
203
|
-
When I run
|
|
200
|
+
When I run `rspec befores_in_configuration_spec.rb`
|
|
204
201
|
Then the examples should all pass
|
|
205
202
|
|
|
206
203
|
Scenario: before/after blocks are run in order
|
|
@@ -230,7 +227,7 @@ Feature: before and after hooks
|
|
|
230
227
|
end
|
|
231
228
|
end
|
|
232
229
|
"""
|
|
233
|
-
When I run
|
|
230
|
+
When I run `rspec ensure_block_order_spec.rb`
|
|
234
231
|
Then the output should contain:
|
|
235
232
|
"""
|
|
236
233
|
before all
|
|
@@ -275,7 +272,7 @@ Feature: before and after hooks
|
|
|
275
272
|
end
|
|
276
273
|
end
|
|
277
274
|
"""
|
|
278
|
-
When I run
|
|
275
|
+
When I run `rspec configuration_spec.rb`
|
|
279
276
|
Then the output should contain:
|
|
280
277
|
"""
|
|
281
278
|
before suite
|
|
@@ -316,7 +313,7 @@ Feature: before and after hooks
|
|
|
316
313
|
|
|
317
314
|
end
|
|
318
315
|
"""
|
|
319
|
-
When I run
|
|
316
|
+
When I run `rspec before_and_after_all_spec.rb`
|
|
320
317
|
Then the examples should all pass
|
|
321
318
|
And the output should contain:
|
|
322
319
|
"""
|
|
@@ -326,7 +323,7 @@ Feature: before and after hooks
|
|
|
326
323
|
outer after all
|
|
327
324
|
"""
|
|
328
325
|
|
|
329
|
-
When I run
|
|
326
|
+
When I run `rspec before_and_after_all_spec.rb:14`
|
|
330
327
|
Then the examples should all pass
|
|
331
328
|
And the output should contain:
|
|
332
329
|
"""
|
|
@@ -336,7 +333,7 @@ Feature: before and after hooks
|
|
|
336
333
|
outer after all
|
|
337
334
|
"""
|
|
338
335
|
|
|
339
|
-
When I run
|
|
336
|
+
When I run `rspec before_and_after_all_spec.rb:6`
|
|
340
337
|
Then the examples should all pass
|
|
341
338
|
And the output should contain:
|
|
342
339
|
"""
|
|
@@ -371,7 +368,7 @@ Feature: before and after hooks
|
|
|
371
368
|
end
|
|
372
369
|
end
|
|
373
370
|
"""
|
|
374
|
-
When I run
|
|
371
|
+
When I run `rspec before_all_spec.rb`
|
|
375
372
|
Then the examples should all pass
|
|
376
373
|
|
|
377
374
|
Scenario: before/after all blocks have access to state
|
|
@@ -402,12 +399,11 @@ Feature: before and after hooks
|
|
|
402
399
|
end
|
|
403
400
|
|
|
404
401
|
after(:all) do
|
|
405
|
-
# p @outer_state.nil?
|
|
406
402
|
@outer_state.should eq("set in outer before all")
|
|
407
403
|
end
|
|
408
404
|
end
|
|
409
405
|
"""
|
|
410
|
-
When I run
|
|
406
|
+
When I run `rspec before_and_after_all_spec.rb`
|
|
411
407
|
Then the examples should all pass
|
|
412
408
|
|
|
413
409
|
Scenario: exception in before(:each) is captured and reported as failure
|
|
@@ -422,6 +418,6 @@ Feature: before and after hooks
|
|
|
422
418
|
end
|
|
423
419
|
end
|
|
424
420
|
"""
|
|
425
|
-
When I run
|
|
421
|
+
When I run `rspec error_in_before_each_spec.rb`
|
|
426
422
|
Then the output should contain "1 example, 1 failure"
|
|
427
423
|
And the output should contain "this error"
|
|
@@ -5,187 +5,223 @@ Feature: filters
|
|
|
5
5
|
or example group, and used to make a hook only apply to examples with the
|
|
6
6
|
given metadata.
|
|
7
7
|
|
|
8
|
+
If you set the `treat_symbols_as_metadata_keys_with_true_values` config option
|
|
9
|
+
to `true`, you can specify metadata using only symbols.
|
|
10
|
+
|
|
8
11
|
Scenario: filter `before(:each)` hooks using arbitrary metadata
|
|
9
12
|
Given a file named "filter_before_each_hooks_spec.rb" with:
|
|
10
13
|
"""
|
|
11
14
|
RSpec.configure do |config|
|
|
12
|
-
config.before(:each, :foo => :bar)
|
|
15
|
+
config.before(:each, :foo => :bar) do
|
|
16
|
+
invoked_hooks << :before_each_foo_bar
|
|
17
|
+
end
|
|
13
18
|
end
|
|
14
19
|
|
|
15
|
-
describe "
|
|
16
|
-
|
|
17
|
-
it("example 2", :foo => :bar) { }
|
|
18
|
-
end
|
|
20
|
+
describe "a filtered before :each hook" do
|
|
21
|
+
let(:invoked_hooks) { [] }
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"""
|
|
25
|
-
When I run "rspec filter_before_each_hooks_spec.rb --format documentation"
|
|
26
|
-
Then the output should contain:
|
|
27
|
-
"""
|
|
28
|
-
group 1
|
|
29
|
-
example 1
|
|
30
|
-
In hook
|
|
31
|
-
example 2
|
|
23
|
+
describe "group without matching metadata" do
|
|
24
|
+
it "does not run the hook" do
|
|
25
|
+
invoked_hooks.should be_empty
|
|
26
|
+
end
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
it "runs the hook for an example with matching metadata", :foo => :bar do
|
|
29
|
+
invoked_hooks.should == [:before_each_foo_bar]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "group with matching metadata", :foo => :bar do
|
|
34
|
+
it "runs the hook" do
|
|
35
|
+
invoked_hooks.should == [:before_each_foo_bar]
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
38
39
|
"""
|
|
40
|
+
When I run `rspec filter_before_each_hooks_spec.rb`
|
|
41
|
+
Then the examples should all pass
|
|
39
42
|
|
|
40
43
|
Scenario: filter `after(:each)` hooks using arbitrary metadata
|
|
41
44
|
Given a file named "filter_after_each_hooks_spec.rb" with:
|
|
42
45
|
"""
|
|
43
46
|
RSpec.configure do |config|
|
|
44
|
-
config.after(:each, :foo => :bar)
|
|
47
|
+
config.after(:each, :foo => :bar) do
|
|
48
|
+
raise "boom!"
|
|
49
|
+
end
|
|
45
50
|
end
|
|
46
51
|
|
|
47
|
-
describe "
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
describe "a filtered after :each hook" do
|
|
53
|
+
describe "group without matching metadata" do
|
|
54
|
+
it "does not run the hook" do
|
|
55
|
+
# should pass
|
|
56
|
+
end
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"""
|
|
57
|
-
When I run "rspec filter_after_each_hooks_spec.rb --format documentation"
|
|
58
|
-
Then the output should contain:
|
|
59
|
-
"""
|
|
60
|
-
group 1
|
|
61
|
-
example 1
|
|
62
|
-
In hook
|
|
63
|
-
example 2
|
|
58
|
+
it "runs the hook for an example with matching metadata", :foo => :bar do
|
|
59
|
+
# should fail
|
|
60
|
+
end
|
|
61
|
+
end
|
|
64
62
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
describe "group with matching metadata", :foo => :bar do
|
|
64
|
+
it "runs the hook" do
|
|
65
|
+
# should fail
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
70
69
|
"""
|
|
70
|
+
When I run `rspec filter_after_each_hooks_spec.rb`
|
|
71
|
+
Then the output should contain "3 examples, 2 failures"
|
|
71
72
|
|
|
72
73
|
Scenario: filter around(:each) hooks using arbitrary metadata
|
|
73
74
|
Given a file named "filter_around_each_hooks_spec.rb" with:
|
|
74
75
|
"""
|
|
75
76
|
RSpec.configure do |config|
|
|
76
77
|
config.around(:each, :foo => :bar) do |example|
|
|
77
|
-
|
|
78
|
+
order << :before_around_each_foo_bar
|
|
78
79
|
example.run
|
|
79
|
-
|
|
80
|
+
order.should == [:before_around_each_foo_bar, :example]
|
|
80
81
|
end
|
|
81
82
|
end
|
|
82
83
|
|
|
83
|
-
describe "
|
|
84
|
-
|
|
85
|
-
it("example 2", :foo => :bar) { }
|
|
86
|
-
end
|
|
84
|
+
describe "a filtered around(:each) hook" do
|
|
85
|
+
let(:order) { [] }
|
|
87
86
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"""
|
|
93
|
-
When I run "rspec filter_around_each_hooks_spec.rb --format documentation"
|
|
94
|
-
Then the output should contain:
|
|
95
|
-
"""
|
|
96
|
-
group 1
|
|
97
|
-
example 1
|
|
98
|
-
Start hook
|
|
99
|
-
End hook
|
|
100
|
-
example 2
|
|
87
|
+
describe "a group without matching metadata" do
|
|
88
|
+
it "does not run the hook" do
|
|
89
|
+
order.should be_empty
|
|
90
|
+
end
|
|
101
91
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
92
|
+
it "runs the hook for an example with matching metadata", :foo => :bar do
|
|
93
|
+
order.should == [:before_around_each_foo_bar]
|
|
94
|
+
order << :example
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe "a group with matching metadata", :foo => :bar do
|
|
99
|
+
it "runs the hook for an example with matching metadata", :foo => :bar do
|
|
100
|
+
order.should == [:before_around_each_foo_bar]
|
|
101
|
+
order << :example
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
109
105
|
"""
|
|
106
|
+
When I run `rspec filter_around_each_hooks_spec.rb`
|
|
107
|
+
Then the examples should all pass
|
|
110
108
|
|
|
111
109
|
Scenario: filter before(:all) hooks using arbitrary metadata
|
|
112
110
|
Given a file named "filter_before_all_hooks_spec.rb" with:
|
|
113
111
|
"""
|
|
114
112
|
RSpec.configure do |config|
|
|
115
|
-
config.before(:all, :foo => :bar) {
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
describe "group 1" do
|
|
119
|
-
it("example 1") { }
|
|
120
|
-
it("example 2") { }
|
|
113
|
+
config.before(:all, :foo => :bar) { @hook = :before_all_foo_bar }
|
|
121
114
|
end
|
|
122
115
|
|
|
123
|
-
describe "
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
116
|
+
describe "a filtered before(:all) hook" do
|
|
117
|
+
describe "a group without matching metadata" do
|
|
118
|
+
it "does not run the hook" do
|
|
119
|
+
@hook.should be_nil
|
|
120
|
+
end
|
|
127
121
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
describe "a nested subgroup with matching metadata", :foo => :bar do
|
|
123
|
+
it "runs the hook" do
|
|
124
|
+
@hook.should == :before_all_foo_bar
|
|
125
|
+
end
|
|
126
|
+
end
|
|
131
127
|
end
|
|
132
|
-
end
|
|
133
|
-
"""
|
|
134
|
-
When I run "rspec filter_before_all_hooks_spec.rb --format documentation"
|
|
135
|
-
Then the output should contain:
|
|
136
|
-
"""
|
|
137
|
-
group 1
|
|
138
|
-
example 1
|
|
139
|
-
example 2
|
|
140
128
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
129
|
+
describe "a group with matching metadata", :foo => :bar do
|
|
130
|
+
it "runs the hook" do
|
|
131
|
+
@hook.should == :before_all_foo_bar
|
|
132
|
+
end
|
|
145
133
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
134
|
+
describe "a nested subgroup" do
|
|
135
|
+
it "runs the hook" do
|
|
136
|
+
@hook.should == :before_all_foo_bar
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
150
141
|
"""
|
|
142
|
+
When I run `rspec filter_before_all_hooks_spec.rb`
|
|
143
|
+
Then the examples should all pass
|
|
151
144
|
|
|
152
145
|
Scenario: filter after(:all) hooks using arbitrary metadata
|
|
153
146
|
Given a file named "filter_after_all_hooks_spec.rb" with:
|
|
154
147
|
"""
|
|
148
|
+
example_msgs = []
|
|
149
|
+
|
|
155
150
|
RSpec.configure do |config|
|
|
156
|
-
config.after(:all, :foo => :bar)
|
|
151
|
+
config.after(:all, :foo => :bar) do
|
|
152
|
+
puts "after :all"
|
|
153
|
+
end
|
|
157
154
|
end
|
|
158
155
|
|
|
159
|
-
describe "
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
describe "a filtered after(:all) hook" do
|
|
157
|
+
describe "a group without matching metadata" do
|
|
158
|
+
it "does not run the hook" do
|
|
159
|
+
puts "unfiltered"
|
|
160
|
+
end
|
|
161
|
+
end
|
|
163
162
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
describe "a group with matching metadata", :foo => :bar do
|
|
164
|
+
it "runs the hook" do
|
|
165
|
+
puts "filtered 1"
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
describe "another group without matching metadata" do
|
|
170
|
+
describe "a nested subgroup with matching metadata", :foo => :bar do
|
|
171
|
+
it "runs the hook" do
|
|
172
|
+
puts "filtered 2"
|
|
173
|
+
end
|
|
174
|
+
end
|
|
172
175
|
end
|
|
173
176
|
end
|
|
174
177
|
"""
|
|
175
|
-
When I run
|
|
176
|
-
Then the
|
|
178
|
+
When I run `rspec filter_after_all_hooks_spec.rb`
|
|
179
|
+
Then the examples should all pass
|
|
180
|
+
And the output should contain:
|
|
181
|
+
"""
|
|
182
|
+
unfiltered
|
|
183
|
+
.filtered 1
|
|
184
|
+
.after :all
|
|
185
|
+
filtered 2
|
|
186
|
+
.after :all
|
|
177
187
|
"""
|
|
178
|
-
group 1
|
|
179
|
-
example 1
|
|
180
|
-
example 2
|
|
181
188
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
189
|
+
Scenario: Use symbols as metadata
|
|
190
|
+
Given a file named "less_verbose_metadata_filter.rb" with:
|
|
191
|
+
"""
|
|
192
|
+
RSpec.configure do |c|
|
|
193
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
|
194
|
+
c.before(:each, :before_each) { puts "before each" }
|
|
195
|
+
c.after(:each, :after_each) { puts "after each" }
|
|
196
|
+
c.around(:each, :around_each) do |example|
|
|
197
|
+
puts "around each (before)"
|
|
198
|
+
example.run
|
|
199
|
+
puts "around each (after)"
|
|
200
|
+
end
|
|
201
|
+
c.before(:all, :before_all) { puts "before all" }
|
|
202
|
+
c.after(:all, :after_all) { puts "after all" }
|
|
203
|
+
end
|
|
186
204
|
|
|
187
|
-
group
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
205
|
+
describe "group 1", :before_all, :after_all do
|
|
206
|
+
it("") { puts "example 1" }
|
|
207
|
+
it("", :before_each) { puts "example 2" }
|
|
208
|
+
it("", :after_each) { puts "example 3" }
|
|
209
|
+
it("", :around_each) { puts "example 4" }
|
|
210
|
+
end
|
|
191
211
|
"""
|
|
212
|
+
When I run `rspec less_verbose_metadata_filter.rb`
|
|
213
|
+
Then the examples should all pass
|
|
214
|
+
And the output should contain:
|
|
215
|
+
"""
|
|
216
|
+
before all
|
|
217
|
+
example 1
|
|
218
|
+
.before each
|
|
219
|
+
example 2
|
|
220
|
+
.example 3
|
|
221
|
+
after each
|
|
222
|
+
.around each (before)
|
|
223
|
+
example 4
|
|
224
|
+
around each (after)
|
|
225
|
+
.after all
|
|
226
|
+
"""
|
|
227
|
+
|