rspec-core 2.5.2 → 2.6.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. data/.travis.yml +7 -0
  2. data/Gemfile +10 -13
  3. data/README.md +4 -1
  4. data/Rakefile +29 -12
  5. data/cucumber.yml +1 -1
  6. data/features/.nav +10 -4
  7. data/features/Autotest.md +31 -7
  8. data/features/Changelog.md +36 -6
  9. data/features/command_line/configure.feature +2 -2
  10. data/features/command_line/example_name_option.feature +10 -10
  11. data/features/command_line/exit_status.feature +4 -4
  12. data/features/command_line/format_option.feature +4 -4
  13. data/features/command_line/line_number_appended_to_path.feature +11 -11
  14. data/features/command_line/line_number_option.feature +2 -2
  15. data/features/command_line/rake_task.feature +3 -3
  16. data/features/command_line/tag.feature +26 -10
  17. data/features/configuration/alias_example_to.feature +48 -0
  18. data/features/configuration/custom_settings.feature +3 -3
  19. data/features/configuration/fail_fast.feature +3 -3
  20. data/features/configuration/read_options_from_file.feature +4 -4
  21. data/features/example_groups/basic_structure.feature +11 -15
  22. data/features/example_groups/shared_context.feature +74 -0
  23. data/features/example_groups/shared_example_group.feature +21 -17
  24. data/features/expectation_framework_integration/configure_expectation_framework.feature +15 -4
  25. data/features/filtering/exclusion_filters.feature +28 -4
  26. data/features/filtering/{implicit_filters.feature → if_and_unless.feature} +9 -7
  27. data/features/filtering/inclusion_filters.feature +26 -3
  28. data/features/filtering/run_all_when_everything_filtered.feature +1 -1
  29. data/features/formatters/custom_formatter.feature +1 -1
  30. data/features/formatters/text_formatter.feature +45 -0
  31. data/features/helper_methods/arbitrary_methods.feature +2 -2
  32. data/features/helper_methods/let.feature +2 -2
  33. data/features/helper_methods/modules.feature +149 -0
  34. data/features/hooks/around_hooks.feature +11 -11
  35. data/features/hooks/before_and_after_hooks.feature +15 -19
  36. data/features/hooks/filtering.feature +160 -124
  37. data/features/metadata/current_example.feature +17 -0
  38. data/features/metadata/described_class.feature +2 -2
  39. data/features/metadata/user_defined.feature +111 -0
  40. data/features/mock_framework_integration/use_any_framework.feature +1 -1
  41. data/features/mock_framework_integration/use_flexmock.feature +83 -10
  42. data/features/mock_framework_integration/use_mocha.feature +84 -10
  43. data/features/mock_framework_integration/use_rr.feature +85 -10
  44. data/features/mock_framework_integration/use_rspec.feature +84 -10
  45. data/features/pending/pending_examples.feature +8 -8
  46. data/features/spec_files/arbitrary_file_suffix.feature +1 -1
  47. data/features/step_definitions/additional_cli_steps.rb +11 -1
  48. data/features/subject/attribute_of_subject.feature +24 -4
  49. data/features/subject/explicit_subject.feature +5 -5
  50. data/features/subject/implicit_receiver.feature +2 -2
  51. data/features/subject/implicit_subject.feature +2 -2
  52. data/features/support/env.rb +6 -1
  53. data/lib/rspec/core.rb +22 -0
  54. data/lib/rspec/core/backward_compatibility.rb +12 -2
  55. data/lib/rspec/core/command_line.rb +1 -4
  56. data/lib/rspec/core/configuration.rb +25 -17
  57. data/lib/rspec/core/configuration_options.rb +6 -23
  58. data/lib/rspec/core/drb_command_line.rb +5 -11
  59. data/lib/rspec/core/example.rb +29 -21
  60. data/lib/rspec/core/example_group.rb +36 -4
  61. data/lib/rspec/core/formatters/base_formatter.rb +6 -0
  62. data/lib/rspec/core/formatters/base_text_formatter.rb +1 -1
  63. data/lib/rspec/core/formatters/helpers.rb +0 -4
  64. data/lib/rspec/core/hooks.rb +14 -4
  65. data/lib/rspec/core/metadata.rb +1 -1
  66. data/lib/rspec/core/metadata_hash_builder.rb +93 -0
  67. data/lib/rspec/core/mocking/with_flexmock.rb +2 -0
  68. data/lib/rspec/core/mocking/with_mocha.rb +2 -0
  69. data/lib/rspec/core/mocking/with_rr.rb +2 -0
  70. data/lib/rspec/core/mocking/with_rspec.rb +3 -1
  71. data/lib/rspec/core/option_parser.rb +5 -2
  72. data/lib/rspec/core/pending.rb +10 -3
  73. data/lib/rspec/core/reporter.rb +2 -2
  74. data/lib/rspec/core/runner.rb +7 -1
  75. data/lib/rspec/core/shared_example_group.rb +18 -4
  76. data/lib/rspec/core/subject.rb +4 -6
  77. data/lib/rspec/core/version.rb +1 -1
  78. data/lib/rspec/core/world.rb +16 -4
  79. data/rspec-core.gemspec +4 -3
  80. data/spec.txt +1126 -0
  81. data/spec/autotest/failed_results_re_spec.rb +2 -2
  82. data/spec/rspec/core/command_line_spec.rb +0 -2
  83. data/spec/rspec/core/configuration_spec.rb +84 -1
  84. data/spec/rspec/core/deprecations_spec.rb +21 -0
  85. data/spec/rspec/core/drb_command_line_spec.rb +3 -11
  86. data/spec/rspec/core/example_group_spec.rb +213 -56
  87. data/spec/rspec/core/example_spec.rb +110 -0
  88. data/spec/rspec/core/formatters/base_formatter_spec.rb +23 -2
  89. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +9 -0
  90. data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
  91. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +5 -5
  92. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +8 -10
  93. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +5 -5
  94. data/spec/rspec/core/formatters/html_formatted-1.9.1.html +5 -5
  95. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +5 -5
  96. data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -1
  97. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +5 -5
  98. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +8 -10
  99. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +5 -5
  100. data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +5 -5
  101. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +5 -5
  102. data/spec/rspec/core/hooks_spec.rb +86 -0
  103. data/spec/rspec/core/metadata_spec.rb +7 -7
  104. data/spec/rspec/core/option_parser_spec.rb +8 -0
  105. data/spec/rspec/core/pending_example_spec.rb +12 -51
  106. data/spec/rspec/core/reporter_spec.rb +19 -3
  107. data/spec/rspec/core/resources/formatter_specs.rb +7 -1
  108. data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
  109. data/spec/rspec/core/runner_spec.rb +35 -10
  110. data/spec/rspec/core/shared_example_group_spec.rb +57 -21
  111. data/spec/rspec/core/subject_spec.rb +32 -11
  112. data/spec/rspec/core/world_spec.rb +38 -15
  113. data/spec/rspec/core_spec.rb +28 -0
  114. data/spec/spec_helper.rb +22 -2
  115. data/spec/support/matchers.rb +44 -13
  116. data/spec/support/shared_example_groups.rb +41 -0
  117. metadata +39 -16
@@ -30,7 +30,7 @@ Feature: around hooks
30
30
  end
31
31
  end
32
32
  """
33
- When I run "rspec example_spec.rb"
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 "rspec example_spec.rb"
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 "rspec example_spec.rb"
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 "rspec example_spec.rb"
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 "rspec example_spec.rb"
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 "rspec example_spec.rb"
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 "rspec example_spec.rb"
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 "rspec example_spec.rb"
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 "rspec example_spec.rb"
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 "rspec example_spec.rb"
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 "rspec example_spec.rb"
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 "rspec ./before_each_spec.rb"
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 "rspec ./before_all_spec.rb"
89
+ When I run `rspec before_all_spec.rb`
90
90
  Then the examples should all pass
91
91
 
92
- When I run "rspec ./before_all_spec.rb:15"
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 "rspec ./before_all_spec.rb --format documentation"
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 "rspec ./before_all_spec.rb:9 --format documentation"
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 "rspec after_all_spec.rb"
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 "rspec ./befores_in_configuration_spec.rb"
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 "rspec ./ensure_block_order_spec.rb"
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 "rspec configuration_spec.rb"
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 "rspec ./before_and_after_all_spec.rb"
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 "rspec ./before_and_after_all_spec.rb:14"
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 "rspec ./before_and_after_all_spec.rb:6"
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 "rspec before_all_spec.rb"
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 "rspec ./before_and_after_all_spec.rb"
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 "rspec ./error_in_before_each_spec.rb"
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) { puts "In hook" }
15
+ config.before(:each, :foo => :bar) do
16
+ invoked_hooks << :before_each_foo_bar
17
+ end
13
18
  end
14
19
 
15
- describe "group 1" do
16
- it("example 1") { }
17
- it("example 2", :foo => :bar) { }
18
- end
20
+ describe "a filtered before :each hook" do
21
+ let(:invoked_hooks) { [] }
19
22
 
20
- describe "group 2", :foo => :bar do
21
- it("example 1") { }
22
- it("example 2", :foo => :bar) { }
23
- end
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
- group 2
34
- In hook
35
- example 1
36
- In hook
37
- example 2
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) { puts "In hook" }
47
+ config.after(:each, :foo => :bar) do
48
+ raise "boom!"
49
+ end
45
50
  end
46
51
 
47
- describe "group 1" do
48
- it("example 1") { }
49
- it("example 2", :foo => :bar) { }
50
- end
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
- describe "group 2", :foo => :bar do
53
- it("example 1") { }
54
- it("example 2", :foo => :bar) { }
55
- end
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
- group 2
66
- In hook
67
- example 1
68
- In hook
69
- example 2
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
- puts "Start hook"
78
+ order << :before_around_each_foo_bar
78
79
  example.run
79
- puts "End hook"
80
+ order.should == [:before_around_each_foo_bar, :example]
80
81
  end
81
82
  end
82
83
 
83
- describe "group 1" do
84
- it("example 1") { }
85
- it("example 2", :foo => :bar) { }
86
- end
84
+ describe "a filtered around(:each) hook" do
85
+ let(:order) { [] }
87
86
 
88
- describe "group 2", :foo => :bar do
89
- it("example 1") { }
90
- it("example 2", :foo => :bar) { }
91
- end
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
- group 2
103
- Start hook
104
- End hook
105
- example 1
106
- Start hook
107
- End hook
108
- example 2
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) { puts "In hook" }
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 "group 2", :foo => :bar do
124
- it("example 1") { }
125
- it("example 2") { }
126
- end
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
- describe "group 3" do
129
- describe "subgroup 1", :foo => :bar do
130
- it("example 1") { }
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
- group 2
142
- In hook
143
- example 1
144
- example 2
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
- group 3
147
- subgroup 1
148
- In hook
149
- example 1
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) { puts "In hook" }
151
+ config.after(:all, :foo => :bar) do
152
+ puts "after :all"
153
+ end
157
154
  end
158
155
 
159
- describe "group 1" do
160
- it("example 1") { }
161
- it("example 2") { }
162
- end
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
- describe "group 2", :foo => :bar do
165
- it("example 1") { }
166
- it("example 2") { }
167
- end
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
- describe "group 3" do
170
- describe "subgroup 1", :foo => :bar do
171
- it("example 1") { }
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 "rspec filter_after_all_hooks_spec.rb --format documentation"
176
- Then the output should contain:
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
- group 2
183
- example 1
184
- example 2
185
- In hook
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 3
188
- subgroup 1
189
- example 1
190
- In hook
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
+