rspec-core 2.0.0.beta.22 → 2.6.4

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.
Files changed (173) hide show
  1. data/.gitignore +1 -0
  2. data/.rspec +0 -1
  3. data/.travis.yml +9 -0
  4. data/Changelog.md +305 -0
  5. data/Gemfile +45 -20
  6. data/Guardfile +5 -0
  7. data/License.txt +2 -1
  8. data/{README.markdown → README.md} +23 -5
  9. data/Rakefile +63 -32
  10. data/bin/autospec +13 -0
  11. data/bin/rspec +24 -2
  12. data/cucumber.yml +1 -1
  13. data/features/.nav +57 -0
  14. data/features/Autotest.md +38 -0
  15. data/features/README.md +17 -0
  16. data/features/Upgrade.md +320 -0
  17. data/features/command_line/README.md +28 -0
  18. data/features/command_line/configure.feature +18 -15
  19. data/features/command_line/example_name_option.feature +37 -23
  20. data/features/command_line/exit_status.feature +16 -31
  21. data/features/command_line/format_option.feature +73 -0
  22. data/features/command_line/line_number_appended_to_path.feature +25 -27
  23. data/features/command_line/line_number_option.feature +11 -10
  24. data/features/command_line/rake_task.feature +68 -0
  25. data/features/command_line/tag.feature +90 -0
  26. data/features/configuration/alias_example_to.feature +48 -0
  27. data/features/configuration/custom_settings.feature +8 -10
  28. data/features/configuration/fail_fast.feature +77 -0
  29. data/features/configuration/read_options_from_file.feature +42 -26
  30. data/features/example_groups/basic_structure.feature +55 -0
  31. data/features/example_groups/shared_context.feature +74 -0
  32. data/features/example_groups/shared_example_group.feature +56 -41
  33. data/features/expectation_framework_integration/configure_expectation_framework.feature +73 -0
  34. data/features/filtering/exclusion_filters.feature +69 -9
  35. data/features/filtering/if_and_unless.feature +168 -0
  36. data/features/filtering/inclusion_filters.feature +58 -26
  37. data/features/filtering/run_all_when_everything_filtered.feature +46 -0
  38. data/features/formatters/custom_formatter.feature +17 -13
  39. data/features/formatters/text_formatter.feature +43 -0
  40. data/features/helper_methods/arbitrary_methods.feature +40 -0
  41. data/features/helper_methods/let.feature +50 -0
  42. data/features/helper_methods/modules.feature +149 -0
  43. data/features/hooks/around_hooks.feature +99 -69
  44. data/features/hooks/before_and_after_hooks.feature +74 -40
  45. data/features/hooks/filtering.feature +227 -0
  46. data/features/metadata/current_example.feature +17 -0
  47. data/features/metadata/described_class.feature +17 -0
  48. data/features/metadata/user_defined.feature +111 -0
  49. data/features/mock_framework_integration/use_any_framework.feature +106 -0
  50. data/features/mock_framework_integration/use_flexmock.feature +84 -11
  51. data/features/mock_framework_integration/use_mocha.feature +85 -11
  52. data/features/mock_framework_integration/use_rr.feature +86 -11
  53. data/features/mock_framework_integration/use_rspec.feature +85 -11
  54. data/features/pending/pending_examples.feature +143 -5
  55. data/features/spec_files/arbitrary_file_suffix.feature +2 -2
  56. data/features/step_definitions/additional_cli_steps.rb +30 -0
  57. data/features/subject/attribute_of_subject.feature +93 -15
  58. data/features/subject/explicit_subject.feature +28 -17
  59. data/features/subject/implicit_receiver.feature +29 -0
  60. data/features/subject/implicit_subject.feature +9 -10
  61. data/features/support/env.rb +6 -1
  62. data/lib/autotest/discover.rb +1 -0
  63. data/lib/autotest/rspec2.rb +15 -11
  64. data/lib/rspec/autorun.rb +2 -0
  65. data/lib/rspec/core/backward_compatibility.rb +32 -3
  66. data/lib/rspec/core/command_line.rb +4 -28
  67. data/lib/rspec/core/command_line_configuration.rb +16 -16
  68. data/lib/rspec/core/configuration.rb +286 -89
  69. data/lib/rspec/core/configuration_options.rb +74 -40
  70. data/lib/rspec/core/deprecation.rb +1 -1
  71. data/lib/rspec/core/drb_command_line.rb +5 -11
  72. data/lib/rspec/core/dsl.rb +11 -0
  73. data/lib/rspec/core/example.rb +63 -39
  74. data/lib/rspec/core/example_group.rb +109 -59
  75. data/lib/rspec/core/expecting/with_rspec.rb +9 -0
  76. data/lib/rspec/core/expecting/with_stdlib.rb +9 -0
  77. data/lib/rspec/core/extensions/kernel.rb +1 -1
  78. data/lib/rspec/core/extensions.rb +0 -1
  79. data/lib/rspec/core/formatters/base_formatter.rb +30 -15
  80. data/lib/rspec/core/formatters/base_text_formatter.rb +68 -40
  81. data/lib/rspec/core/formatters/documentation_formatter.rb +4 -2
  82. data/lib/rspec/core/formatters/helpers.rb +0 -4
  83. data/lib/rspec/core/formatters/html_formatter.rb +146 -41
  84. data/lib/rspec/core/formatters/progress_formatter.rb +1 -0
  85. data/lib/rspec/core/formatters/snippet_extractor.rb +1 -1
  86. data/lib/rspec/core/formatters/text_mate_formatter.rb +3 -1
  87. data/lib/rspec/core/hooks.rb +56 -17
  88. data/lib/rspec/core/metadata.rb +75 -64
  89. data/lib/rspec/core/metadata_hash_builder.rb +93 -0
  90. data/lib/rspec/core/mocking/with_flexmock.rb +2 -0
  91. data/lib/rspec/core/mocking/with_mocha.rb +2 -0
  92. data/lib/rspec/core/mocking/with_rr.rb +2 -0
  93. data/lib/rspec/core/mocking/with_rspec.rb +3 -1
  94. data/lib/rspec/core/option_parser.rb +49 -7
  95. data/lib/rspec/core/pending.rb +22 -4
  96. data/lib/rspec/core/rake_task.rb +64 -28
  97. data/lib/rspec/core/reporter.rb +6 -5
  98. data/lib/rspec/core/ruby_project.rb +2 -2
  99. data/lib/rspec/core/runner.rb +50 -6
  100. data/lib/rspec/core/shared_context.rb +16 -0
  101. data/lib/rspec/core/shared_example_group.rb +19 -4
  102. data/lib/rspec/core/subject.rb +92 -65
  103. data/lib/rspec/core/version.rb +1 -1
  104. data/lib/rspec/core/world.rb +85 -27
  105. data/lib/rspec/core.rb +55 -24
  106. data/lib/rspec/monkey/spork/test_framework/rspec.rb +1 -0
  107. data/rspec-core.gemspec +4 -25
  108. data/script/FullBuildRakeFile +63 -0
  109. data/script/cucumber +1 -0
  110. data/script/full_build +1 -0
  111. data/script/spec +1 -0
  112. data/spec/autotest/discover_spec.rb +19 -0
  113. data/spec/autotest/failed_results_re_spec.rb +25 -9
  114. data/spec/autotest/rspec_spec.rb +32 -41
  115. data/spec/rspec/core/command_line_spec.rb +62 -7
  116. data/spec/rspec/core/configuration_options_spec.rb +216 -148
  117. data/spec/rspec/core/configuration_spec.rb +419 -108
  118. data/spec/rspec/core/deprecations_spec.rb +38 -1
  119. data/spec/rspec/core/drb_command_line_spec.rb +21 -56
  120. data/spec/rspec/core/example_group_spec.rb +366 -127
  121. data/spec/rspec/core/example_spec.rb +125 -45
  122. data/spec/rspec/core/formatters/base_formatter_spec.rb +61 -1
  123. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +134 -97
  124. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +7 -6
  125. data/spec/rspec/core/formatters/helpers_spec.rb +1 -1
  126. data/spec/rspec/core/formatters/html_formatted-1.8.6.html +199 -81
  127. data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +195 -83
  128. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +199 -81
  129. data/spec/rspec/core/formatters/html_formatted-1.9.1.html +206 -81
  130. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +206 -61
  131. data/spec/rspec/core/formatters/html_formatter_spec.rb +17 -9
  132. data/spec/rspec/core/formatters/progress_formatter_spec.rb +1 -1
  133. data/spec/rspec/core/formatters/text_mate_formatted-1.8.6.html +199 -81
  134. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +195 -81
  135. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +199 -81
  136. data/spec/rspec/core/formatters/text_mate_formatted-1.9.1.html +206 -81
  137. data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +206 -81
  138. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +22 -7
  139. data/spec/rspec/core/hooks_filtering_spec.rb +128 -5
  140. data/spec/rspec/core/hooks_spec.rb +90 -4
  141. data/spec/rspec/core/metadata_spec.rb +176 -163
  142. data/spec/rspec/core/option_parser_spec.rb +73 -6
  143. data/spec/rspec/core/pending_example_spec.rb +137 -35
  144. data/spec/rspec/core/rake_task_spec.rb +62 -29
  145. data/spec/rspec/core/reporter_spec.rb +20 -4
  146. data/spec/rspec/core/resources/formatter_specs.rb +25 -1
  147. data/spec/rspec/core/rspec_matchers_spec.rb +45 -0
  148. data/spec/rspec/core/runner_spec.rb +60 -10
  149. data/spec/rspec/core/shared_context_spec.rb +30 -0
  150. data/spec/rspec/core/shared_example_group_spec.rb +59 -23
  151. data/spec/rspec/core/subject_spec.rb +136 -0
  152. data/spec/rspec/core/world_spec.rb +211 -68
  153. data/spec/rspec/core_spec.rb +28 -0
  154. data/spec/spec_helper.rb +41 -24
  155. data/spec/support/matchers.rb +44 -13
  156. data/spec/support/shared_example_groups.rb +41 -0
  157. data/spec/support/spec_files.rb +44 -0
  158. data/spec.txt +1126 -0
  159. metadata +100 -170
  160. data/.treasure_map.rb +0 -23
  161. data/History.md +0 -30
  162. data/Upgrade.markdown +0 -150
  163. data/autotest/discover.rb +0 -2
  164. data/features/README.markdown +0 -12
  165. data/features/example_groups/describe_aliases.feature +0 -25
  166. data/features/example_groups/nested_groups.feature +0 -44
  167. data/features/hooks/described_class.feature +0 -14
  168. data/features/hooks/halt.feature +0 -26
  169. data/lib/rspec/core/around_proxy.rb +0 -14
  170. data/lib/rspec/core/extensions/object.rb +0 -15
  171. data/lib/rspec/core/formatters.rb +0 -8
  172. data/spec/ruby_forker.rb +0 -13
  173. data/specs.watchr +0 -59
@@ -1,52 +1,66 @@
1
1
  Feature: around hooks
2
2
 
3
- As a developer using RSpec
4
- I want to run the examples as part of a block given to a an arbitary function
5
- So that I can control the environment in which it is run
3
+ Around hooks receive the example as a block argument, extended to behave like
4
+ a proc. This lets you define code that should be executed before and after
5
+ the example. Of course, you can do the same thing with before and after hooks,
6
+ and it's often cleaner to do so.
6
7
 
7
- Scenario: around hooks defined in a group are run
8
- Given a file named "ensure_around_blocks_are_run.rb" with:
8
+ Where around hooks shine is when you want to run an example in a block. For
9
+ example, if your database library offers a transaction method that receives
10
+ a block, you can use an around hook as described in the first scenario:
11
+
12
+ WARNING: around hooks do not share state with the example the way before and
13
+ after hooks do. This means that you can not share instance variables between
14
+ around hooks and examples.
15
+
16
+ Also, mock frameworks are set up and torn down within the context of running
17
+ the example, so you can not interact with them directly in around hooks.
18
+
19
+ Scenario: use the example as a proc within the block passed to around()
20
+ Given a file named "example_spec.rb" with:
9
21
  """
22
+ class Database
23
+ def self.transaction
24
+ puts "open transaction"
25
+ yield
26
+ puts "close transaction"
27
+ end
28
+ end
29
+
10
30
  describe "around filter" do
11
31
  around(:each) do |example|
12
- puts "around each before"
13
- example.run
14
- puts "around each after"
32
+ Database.transaction(&example)
15
33
  end
16
34
 
17
35
  it "gets run in order" do
18
- puts "in the example"
36
+ puts "run the example"
19
37
  end
20
38
  end
21
39
  """
22
- When I run "rspec ./ensure_around_blocks_are_run.rb"
40
+ When I run `rspec example_spec.rb`
23
41
  Then the output should contain:
24
42
  """
25
- around each before
26
- in the example
27
- around each after
43
+ open transaction
44
+ run the example
45
+ close transaction
28
46
  """
29
47
 
30
- Scenario: argument passed to around hook can be treated as a proc
31
- Given a file named "treat_around_hook_arg_as_a_proc.rb" with:
48
+ Scenario: invoke the example using run()
49
+ Given a file named "example_spec.rb" with:
32
50
  """
33
- describe "around filter" do
34
- def perform_around
51
+ describe "around hook" do
52
+ around(:each) do |example|
35
53
  puts "around each before"
36
- yield
54
+ example.run
37
55
  puts "around each after"
38
56
  end
39
57
 
40
- around(:each) do |example|
41
- perform_around(&example)
42
- end
43
-
44
58
  it "gets run in order" do
45
59
  puts "in the example"
46
60
  end
47
61
  end
48
62
  """
49
- When I run "rspec ./treat_around_hook_arg_as_a_proc.rb"
63
+ When I run `rspec example_spec.rb`
50
64
  Then the output should contain:
51
65
  """
52
66
  around each before
@@ -54,8 +68,24 @@ Feature: around hooks
54
68
  around each after
55
69
  """
56
70
 
57
- Scenario: around hooks defined globally are run
58
- Given a file named "ensure_around_blocks_are_run.rb" with:
71
+ Scenario: access the example metadata
72
+ Given a file named "example_spec.rb" with:
73
+ """
74
+ describe "something" do
75
+ around(:each) do |example|
76
+ puts example.metadata[:foo]
77
+ example.run
78
+ end
79
+
80
+ it "does something", :foo => "this should show up in the output" do
81
+ end
82
+ end
83
+ """
84
+ When I run `rspec example_spec.rb`
85
+ Then the output should contain "this should show up in the output"
86
+
87
+ Scenario: define a global around hook
88
+ Given a file named "example_spec.rb" with:
59
89
  """
60
90
  RSpec.configure do |c|
61
91
  c.around(:each) do |example|
@@ -71,7 +101,7 @@ Feature: around hooks
71
101
  end
72
102
  end
73
103
  """
74
- When I run "rspec ./ensure_around_blocks_are_run.rb"
104
+ When I run `rspec example_spec.rb`
75
105
  Then the output should contain:
76
106
  """
77
107
  around each before
@@ -80,7 +110,7 @@ Feature: around hooks
80
110
  """
81
111
 
82
112
  Scenario: before/after(:each) hooks are wrapped by the around hook
83
- Given a file named "ensure_around_blocks_are_run.rb" with:
113
+ Given a file named "example_spec.rb" with:
84
114
  """
85
115
  describe "around filter" do
86
116
  around(:each) do |example|
@@ -102,7 +132,7 @@ Feature: around hooks
102
132
  end
103
133
  end
104
134
  """
105
- When I run "rspec ./ensure_around_blocks_are_run.rb"
135
+ When I run `rspec example_spec.rb`
106
136
  Then the output should contain:
107
137
  """
108
138
  around each before
@@ -113,7 +143,7 @@ Feature: around hooks
113
143
  """
114
144
 
115
145
  Scenario: before/after(:all) hooks are NOT wrapped by the around hook
116
- Given a file named "ensure_around_blocks_are_run.rb" with:
146
+ Given a file named "example_spec.rb" with:
117
147
  """
118
148
  describe "around filter" do
119
149
  around(:each) do |example|
@@ -135,7 +165,7 @@ Feature: around hooks
135
165
  end
136
166
  end
137
167
  """
138
- When I run "rspec ./ensure_around_blocks_are_run.rb"
168
+ When I run `rspec example_spec.rb`
139
169
  Then the output should contain:
140
170
  """
141
171
  before all
@@ -145,8 +175,8 @@ Feature: around hooks
145
175
  .after all
146
176
  """
147
177
 
148
- Scenario: examples run by an around block should run in the configured context
149
- Given a file named "around_block_with_context.rb" with:
178
+ Scenario: examples run by an around block are run in the configured context
179
+ Given a file named "example_spec.rb" with:
150
180
  """
151
181
  module IncludedInConfigureBlock
152
182
  def included_in_configure_block; true; end
@@ -166,11 +196,11 @@ Feature: around hooks
166
196
  end
167
197
  end
168
198
  """
169
- When I run "rspec ./around_block_with_context.rb"
199
+ When I run `rspec example_spec.rb`
170
200
  Then the output should contain "1 example, 0 failure"
171
201
 
172
- Scenario: implicitly pending examples should be detected as Not Yet Implemented
173
- Given a file named "around_block_with_implicit_pending_example.rb" with:
202
+ Scenario: implicitly pending examples are detected as Not Yet Implemented
203
+ Given a file named "example_spec.rb" with:
174
204
  """
175
205
  describe "implicit pending example" do
176
206
  around(:each) do |example|
@@ -180,7 +210,7 @@ Feature: around hooks
180
210
  it "should be detected as Not Yet Implemented"
181
211
  end
182
212
  """
183
- When I run "rspec ./around_block_with_implicit_pending_example.rb"
213
+ When I run `rspec example_spec.rb`
184
214
  Then the output should contain "1 example, 0 failures, 1 pending"
185
215
  And the output should contain:
186
216
  """
@@ -190,8 +220,8 @@ Feature: around hooks
190
220
  """
191
221
 
192
222
 
193
- Scenario: explicitly pending examples should be detected as pending
194
- Given a file named "around_block_with_explicit_pending_example.rb" with:
223
+ Scenario: explicitly pending examples are detected as pending
224
+ Given a file named "example_spec.rb" with:
195
225
  """
196
226
  describe "explicit pending example" do
197
227
  around(:each) do |example|
@@ -203,7 +233,7 @@ Feature: around hooks
203
233
  end
204
234
  end
205
235
  """
206
- When I run "rspec ./around_block_with_explicit_pending_example.rb"
236
+ When I run `rspec example_spec.rb`
207
237
  Then the output should contain "1 example, 0 failures, 1 pending"
208
238
  And the output should contain:
209
239
  """
@@ -211,41 +241,41 @@ Feature: around hooks
211
241
  # No reason given
212
242
  """
213
243
 
214
- Scenario: multiple around hooks in the same scope are all run
215
- Given a file named "around_hooks_in_same_scope.rb" with:
216
- """
217
- describe "if there are multiple around hooks in the same scope" do
218
- around(:each) do |example|
219
- puts "first around hook before"
220
- example.run
221
- puts "first around hook after"
222
- end
244
+ Scenario: multiple around hooks in the same scope
245
+ Given a file named "example_spec.rb" with:
246
+ """
247
+ describe "if there are multiple around hooks in the same scope" do
248
+ around(:each) do |example|
249
+ puts "first around hook before"
250
+ example.run
251
+ puts "first around hook after"
252
+ end
223
253
 
224
- around(:each) do |example|
225
- puts "second around hook before"
226
- example.run
227
- puts "second around hook after"
228
- end
254
+ around(:each) do |example|
255
+ puts "second around hook before"
256
+ example.run
257
+ puts "second around hook after"
258
+ end
229
259
 
230
- it "they should all be run" do
231
- puts "in the example"
232
- 1.should == 1
260
+ it "they should all be run" do
261
+ puts "in the example"
262
+ 1.should == 1
263
+ end
233
264
  end
234
- end
235
- """
236
- When I run "rspec ./around_hooks_in_same_scope.rb"
265
+ """
266
+ When I run `rspec example_spec.rb`
237
267
  Then the output should contain "1 example, 0 failure"
238
268
  And the output should contain:
239
- """
240
- first around hook before
241
- second around hook before
242
- in the example
243
- second around hook after
244
- first around hook after
245
- """
269
+ """
270
+ first around hook before
271
+ second around hook before
272
+ in the example
273
+ second around hook after
274
+ first around hook after
275
+ """
246
276
 
247
- Scenario: around hooks in outer scopes are run
248
- Given a file named "around_hooks_in_outer_scope.rb" with:
277
+ Scenario: around hooks in multiple scopes
278
+ Given a file named "example_spec.rb" with:
249
279
  """
250
280
  describe "if there are around hooks in an outer scope" do
251
281
  around(:each) do |example|
@@ -293,7 +323,7 @@ Feature: around hooks
293
323
  end
294
324
  end
295
325
  """
296
- When I run "rspec ./around_hooks_in_outer_scope.rb"
326
+ When I run `rspec example_spec.rb`
297
327
  Then the output should contain "1 example, 0 failure"
298
328
  And the output should contain:
299
329
  """
@@ -1,19 +1,16 @@
1
1
  Feature: before and after hooks
2
2
 
3
- As a developer using RSpec
4
- I want to execute arbitrary code before and after each example
5
- So that I can control the environment in which it is run
3
+ Use `before` and `after` hooks to execute arbitrary code before and/or
4
+ after the body of an example is run:
6
5
 
7
- This is supported by the before and after methods which each take a symbol
8
- indicating the scope, and a block of code to execute.
6
+ before(:each) # run before each example
7
+ before(:all) # run one time only, before all of the examples in a group
9
8
 
10
- before(:each) blocks are run before each example
11
- before(:all) blocks are run once before all of the examples in a group
9
+ after(:each) # run after each example
10
+ after(:all) # run one time only, after all of the examples in a group
12
11
 
13
- after(:each) blocks are run after each example
14
- after(:all) blocks are run once after all of the examples in a group
12
+ Before and after blocks are called in the following order:
15
13
 
16
- Before and after blocks are called in the following order:
17
14
  before suite
18
15
  before all
19
16
  before each
@@ -21,10 +18,8 @@ Feature: before and after hooks
21
18
  after all
22
19
  after suite
23
20
 
24
- Before and after blocks can be defined in the example groups to which they
25
- apply or in a configuration. When defined in a configuration, they can be
26
- applied to all groups or subsets of all groups defined by example group
27
- types.
21
+ `before` and `after` hooks can be defined directly in the example groups they
22
+ should run in, or in a global RSpec.configure block.
28
23
 
29
24
  Scenario: define before(:each) block
30
25
  Given a file named "before_each_spec.rb" with:
@@ -57,8 +52,8 @@ Feature: before and after hooks
57
52
  end
58
53
  end
59
54
  """
60
- When I run "rspec ./before_each_spec.rb"
61
- Then the output should contain "3 examples, 0 failures"
55
+ When I run `rspec before_each_spec.rb`
56
+ Then the examples should all pass
62
57
 
63
58
  Scenario: define before(:all) block in example group
64
59
  Given a file named "before_all_spec.rb" with:
@@ -91,11 +86,11 @@ Feature: before and after hooks
91
86
  end
92
87
  end
93
88
  """
94
- When I run "rspec ./before_all_spec.rb"
95
- Then the output should contain "3 examples, 0 failures"
89
+ When I run `rspec before_all_spec.rb`
90
+ Then the examples should all pass
96
91
 
97
- When I run "rspec ./before_all_spec.rb:15"
98
- Then the output should contain "1 example, 0 failures"
92
+ When I run `rspec before_all_spec.rb:15`
93
+ Then the examples should all pass
99
94
 
100
95
  Scenario: failure in before(:all) block
101
96
  Given a file named "before_all_spec.rb" with:
@@ -114,25 +109,65 @@ Feature: before and after hooks
114
109
  after(:all) do
115
110
  puts "after all ran"
116
111
  end
112
+
113
+ describe "nested group" do
114
+ it "fails this third example" do
115
+ end
116
+
117
+ it "fails this fourth example" do
118
+ end
119
+
120
+ describe "yet another level deep" do
121
+ it "fails this last example" do
122
+ end
123
+ end
124
+ end
117
125
  end
118
126
  """
119
- When I run "rspec ./before_all_spec.rb --format documentation"
120
- Then the output should contain "2 examples, 2 failures"
127
+ When I run `rspec before_all_spec.rb --format documentation`
128
+ Then the output should contain "5 examples, 5 failures"
121
129
  And the output should contain:
122
130
  """
123
131
  an error in before(:all)
124
132
  fails this example (FAILED - 1)
125
133
  fails this example, too (FAILED - 2)
134
+ nested group
135
+ fails this third example (FAILED - 3)
136
+ fails this fourth example (FAILED - 4)
137
+ yet another level deep
138
+ fails this last example (FAILED - 5)
126
139
  after all ran
127
140
  """
128
141
 
129
- When I run "rspec ./before_all_spec.rb:9 --format documentation"
142
+ When I run `rspec before_all_spec.rb:9 --format documentation`
130
143
  Then the output should contain "1 example, 1 failure"
131
144
  And the output should contain:
132
145
  """
133
146
  an error in before(:all)
134
147
  fails this example, too (FAILED - 1)
135
- after all ran
148
+ """
149
+
150
+ Scenario: failure in after(:all) block
151
+ Given a file named "after_all_spec.rb" with:
152
+ """
153
+ describe "an error in after(:all)" do
154
+ after(:all) do
155
+ raise StandardError.new("Boom!")
156
+ end
157
+
158
+ it "passes this example" do
159
+ end
160
+
161
+ it "passes this example, too" do
162
+ end
163
+ end
164
+ """
165
+ When I run `rspec after_all_spec.rb`
166
+ Then the examples should all pass
167
+ And the output should contain:
168
+ """
169
+ An error occurred in an after(:all) hook.
170
+ StandardError: Boom!
136
171
  """
137
172
 
138
173
  Scenario: define before and after blocks in configuration
@@ -162,8 +197,8 @@ Feature: before and after hooks
162
197
  end
163
198
  end
164
199
  """
165
- When I run "rspec ./befores_in_configuration_spec.rb"
166
- Then the output should contain "2 examples, 0 failures"
200
+ When I run `rspec befores_in_configuration_spec.rb`
201
+ Then the examples should all pass
167
202
 
168
203
  Scenario: before/after blocks are run in order
169
204
  Given a file named "ensure_block_order_spec.rb" with:
@@ -192,7 +227,7 @@ Feature: before and after hooks
192
227
  end
193
228
  end
194
229
  """
195
- When I run "rspec ./ensure_block_order_spec.rb"
230
+ When I run `rspec ensure_block_order_spec.rb`
196
231
  Then the output should contain:
197
232
  """
198
233
  before all
@@ -237,7 +272,7 @@ Feature: before and after hooks
237
272
  end
238
273
  end
239
274
  """
240
- When I run "rspec configuration_spec.rb"
275
+ When I run `rspec configuration_spec.rb`
241
276
  Then the output should contain:
242
277
  """
243
278
  before suite
@@ -278,8 +313,8 @@ Feature: before and after hooks
278
313
 
279
314
  end
280
315
  """
281
- When I run "rspec ./before_and_after_all_spec.rb"
282
- Then the output should contain "2 examples, 0 failures"
316
+ When I run `rspec before_and_after_all_spec.rb`
317
+ Then the examples should all pass
283
318
  And the output should contain:
284
319
  """
285
320
  outer before all
@@ -288,8 +323,8 @@ Feature: before and after hooks
288
323
  outer after all
289
324
  """
290
325
 
291
- When I run "rspec ./before_and_after_all_spec.rb:14"
292
- Then the output should contain "1 example, 0 failures"
326
+ When I run `rspec before_and_after_all_spec.rb:14`
327
+ Then the examples should all pass
293
328
  And the output should contain:
294
329
  """
295
330
  outer before all
@@ -298,8 +333,8 @@ Feature: before and after hooks
298
333
  outer after all
299
334
  """
300
335
 
301
- When I run "rspec ./before_and_after_all_spec.rb:6"
302
- Then the output should contain "1 example, 0 failures"
336
+ When I run `rspec before_and_after_all_spec.rb:6`
337
+ Then the examples should all pass
303
338
  And the output should contain:
304
339
  """
305
340
  outer before all
@@ -333,8 +368,8 @@ Feature: before and after hooks
333
368
  end
334
369
  end
335
370
  """
336
- When I run "rspec before_all_spec.rb"
337
- Then the output should contain "3 examples, 0 failures"
371
+ When I run `rspec before_all_spec.rb`
372
+ Then the examples should all pass
338
373
 
339
374
  Scenario: before/after all blocks have access to state
340
375
  Given a file named "before_and_after_all_spec.rb" with:
@@ -364,13 +399,12 @@ Feature: before and after hooks
364
399
  end
365
400
 
366
401
  after(:all) do
367
- # p @outer_state.nil?
368
402
  @outer_state.should eq("set in outer before all")
369
403
  end
370
404
  end
371
405
  """
372
- When I run "rspec ./before_and_after_all_spec.rb"
373
- Then the output should contain "2 examples, 0 failures"
406
+ When I run `rspec before_and_after_all_spec.rb`
407
+ Then the examples should all pass
374
408
 
375
409
  Scenario: exception in before(:each) is captured and reported as failure
376
410
  Given a file named "error_in_before_each_spec.rb" with:
@@ -384,6 +418,6 @@ Feature: before and after hooks
384
418
  end
385
419
  end
386
420
  """
387
- When I run "rspec ./error_in_before_each_spec.rb"
421
+ When I run `rspec error_in_before_each_spec.rb`
388
422
  Then the output should contain "1 example, 1 failure"
389
423
  And the output should contain "this error"