@@ -19,6 +19,82 @@ Feature: Aggregating Failures
1919 end
2020 """
2121
22+ @skip-when-diff-lcs-1.3
23+ Scenario : Use `aggregate_failures` block form
24+ Given a file named "spec/use_block_form_spec.rb" with:
25+ """ruby
26+ require 'client'
27+
28+ RSpec.describe Client do
29+ after do
30+ # this should be appended to failure list
31+ expect(false).to be(true), "after hook failure"
32+ end
33+
34+ around do |ex|
35+ ex.run
36+ # this should also be appended to failure list
37+ expect(false).to be(true), "around hook failure"
38+ end
39+
40+ it "returns a successful response" do
41+ response = Client.make_request
42+
43+ aggregate_failures "testing response" do
44+ expect(response.status).to eq(200)
45+ expect(response.headers).to include("Content-Type" => "application/json")
46+ expect(response.body).to eq('{"message":"Success"}')
47+ end
48+ end
49+ end
50+ """
51+ When I run `rspec spec/use_block_form_spec.rb`
52+ Then it should fail and list all the failures:
53+ """
54+ Failures:
55+
56+ 1) Client returns a successful response
57+ Got 3 failures:
58+
59+ 1.1) Got 3 failures from failure aggregation block "testing response".
60+ # ./spec/use_block_form_spec.rb:18
61+ # ./spec/use_block_form_spec.rb:10
62+
63+ 1.1.1) Failure/Error: expect(response.status).to eq(200)
64+
65+ expected: 200
66+ got: 404
67+
68+ (compared using ==)
69+ # ./spec/use_block_form_spec.rb:19
70+
71+ 1.1.2) Failure/Error: expect(response.headers).to include("Content-Type" => "application/json")
72+ expected {"Content-Type" => "text/plain"} to include {"Content-Type" => "application/json"}
73+ Diff:
74+ @@ -1 +1 @@
75+ -"Content-Type" => "application/json",
76+ +"Content-Type" => "text/plain",
77+ # ./spec/use_block_form_spec.rb:20
78+
79+ 1.1.3) Failure/Error: expect(response.body).to eq('{"message":"Success"}')
80+
81+ expected: "{\"message\":\"Success\"}"
82+ got: "Not Found"
83+
84+ (compared using ==)
85+ # ./spec/use_block_form_spec.rb:21
86+
87+ 1.2) Failure/Error: expect(false).to be(true), "after hook failure"
88+ after hook failure
89+ # ./spec/use_block_form_spec.rb:6
90+ # ./spec/use_block_form_spec.rb:10
91+
92+ 1.3) Failure/Error: expect(false).to be(true), "around hook failure"
93+ around hook failure
94+ # ./spec/use_block_form_spec.rb:12
95+ """
96+
97+ @skip-when-diff-lcs-1.4
2298 Scenario : Use `aggregate_failures` block form
2399 Given a file named "spec/use_block_form_spec.rb" with:
24100 """ruby
@@ -143,6 +219,62 @@ Feature: Aggregating Failures
143219 # ./spec/use_metadata_spec.rb:10
144220 """
145221
222+ @skip-when-diff-lcs-1.3
223+ Scenario : Enable failure aggregation globally using `define_derived_metadata`
224+ Given a file named "spec/enable_globally_spec.rb" with:
225+ """ruby
226+ require 'client'
227+
228+ RSpec.configure do |c|
229+ c.define_derived_metadata do |meta|
230+ meta[:aggregate_failures] = true
231+ end
232+ end
233+
234+ RSpec.describe Client do
235+ it "returns a successful response" do
236+ response = Client.make_request
237+
238+ expect(response.status).to eq(200)
239+ expect(response.headers).to include("Content-Type" => "application/json")
240+ expect(response.body).to eq('{"message":"Success"}')
241+ end
242+ end
243+ """
244+ When I run `rspec spec/enable_globally_spec.rb`
245+ Then it should fail and list all the failures:
246+ """
247+ Failures:
248+
249+ 1) Client returns a successful response
250+ Got 3 failures:
251+
252+ 1.1) Failure/Error: expect(response.status).to eq(200)
253+
254+ expected: 200
255+ got: 404
256+
257+ (compared using ==)
258+ # ./spec/enable_globally_spec.rb:13
259+
260+ 1.2) Failure/Error: expect(response.headers).to include("Content-Type" => "application/json")
261+ expected {"Content-Type" => "text/plain"} to include {"Content-Type" => "application/json"}
262+ Diff:
263+ @@ -1 +1 @@
264+ -"Content-Type" => "application/json",
265+ +"Content-Type" => "text/plain",
266+ # ./spec/enable_globally_spec.rb:14
267+
268+ 1.3) Failure/Error: expect(response.body).to eq('{"message":"Success"}')
269+
270+ expected: "{\"message\":\"Success\"}"
271+ got: "Not Found"
272+
273+ (compared using ==)
274+ # ./spec/enable_globally_spec.rb:15
275+ """
276+
277+ @skip-when-diff-lcs-1.4
146278 Scenario : Enable failure aggregation globally using `define_derived_metadata`
147279 Given a file named "spec/enable_globally_spec.rb" with:
148280 """ruby
@@ -197,6 +329,72 @@ Feature: Aggregating Failures
197329 # ./spec/enable_globally_spec.rb:15
198330 """
199331
332+ @skip-when-diff-lcs-1.3
333+ Scenario : Nested failure aggregation works
334+ Given a file named "spec/nested_failure_aggregation_spec.rb" with:
335+ """ruby
336+ require 'client'
337+
338+ RSpec.describe Client do
339+ it "returns a successful response", :aggregate_failures do
340+ response = Client.make_request
341+
342+ expect(response.status).to eq(200)
343+
344+ aggregate_failures "testing headers" do
345+ expect(response.headers).to include("Content-Type" => "application/json")
346+ expect(response.headers).to include("Content-Length" => "21")
347+ end
348+
349+ expect(response.body).to eq('{"message":"Success"}')
350+ end
351+ end
352+ """
353+ When I run `rspec spec/nested_failure_aggregation_spec.rb`
354+ Then it should fail and list all the failures:
355+ """
356+ Failures:
357+
358+ 1) Client returns a successful response
359+ Got 3 failures:
360+
361+ 1.1) Failure/Error: expect(response.status).to eq(200)
362+
363+ expected: 200
364+ got: 404
365+
366+ (compared using ==)
367+ # ./spec/nested_failure_aggregation_spec.rb:7
368+
369+ 1.2) Got 2 failures from failure aggregation block "testing headers".
370+ # ./spec/nested_failure_aggregation_spec.rb:9
371+
372+ 1.2.1) Failure/Error: expect(response.headers).to include("Content-Type" => "application/json")
373+ expected {"Content-Type" => "text/plain"} to include {"Content-Type" => "application/json"}
374+ Diff:
375+ @@ -1 +1 @@
376+ -"Content-Type" => "application/json",
377+ +"Content-Type" => "text/plain",
378+ # ./spec/nested_failure_aggregation_spec.rb:10
379+
380+ 1.2.2) Failure/Error: expect(response.headers).to include("Content-Length" => "21")
381+ expected {"Content-Type" => "text/plain"} to include {"Content-Length" => "21"}
382+ Diff:
383+ @@ -1 +1 @@
384+ -"Content-Length" => "21",
385+ +"Content-Type" => "text/plain",
386+ # ./spec/nested_failure_aggregation_spec.rb:11
387+
388+ 1.3) Failure/Error: expect(response.body).to eq('{"message":"Success"}')
389+
390+ expected: "{\"message\":\"Success\"}"
391+ got: "Not Found"
392+
393+ (compared using ==)
394+ # ./spec/nested_failure_aggregation_spec.rb:14
395+ """
396+
397+ @skip-when-diff-lcs-1.4
200398 Scenario : Nested failure aggregation works
201399 Given a file named "spec/nested_failure_aggregation_spec.rb" with:
202400 """ruby
@@ -301,6 +499,58 @@ Feature: Aggregating Failures
301499
302500 """
303501
502+ @skip-when-diff-lcs-1.3
503+ Scenario : Pending integrates properly with aggregated failures
504+ Given a file named "spec/pending_spec.rb" with:
505+ """ruby
506+ require 'client'
507+
508+ RSpec.describe Client do
509+ it "returns a successful response", :aggregate_failures do
510+ pending "Not yet ready"
511+ response = Client.make_request
512+
513+ expect(response.status).to eq(200)
514+ expect(response.headers).to include("Content-Type" => "application/json")
515+ expect(response.body).to eq('{"message":"Success"}')
516+ end
517+ end
518+ """
519+ When I run `rspec spec/pending_spec.rb`
520+ Then it should pass and list all the pending examples:
521+ """
522+ Pending: (Failures listed here are expected and do not affect your suite's status)
523+
524+ 1) Client returns a successful response
525+ # Not yet ready
526+ Got 3 failures:
527+
528+ 1.1) Failure/Error: expect(response.status).to eq(200)
529+
530+ expected: 200
531+ got: 404
532+
533+ (compared using ==)
534+ # ./spec/pending_spec.rb:8
535+
536+ 1.2) Failure/Error: expect(response.headers).to include("Content-Type" => "application/json")
537+ expected {"Content-Type" => "text/plain"} to include {"Content-Type" => "application/json"}
538+ Diff:
539+ @@ -1 +1 @@
540+ -"Content-Type" => "application/json",
541+ +"Content-Type" => "text/plain",
542+ # ./spec/pending_spec.rb:9
543+
544+ 1.3) Failure/Error: expect(response.body).to eq('{"message":"Success"}')
545+
546+ expected: "{\"message\":\"Success\"}"
547+ got: "Not Found"
548+
549+ (compared using ==)
550+ # ./spec/pending_spec.rb:10
551+ """
552+
553+ @skip-when-diff-lcs-1.4
304554 Scenario : Pending integrates properly with aggregated failures
305555 Given a file named "spec/pending_spec.rb" with:
306556 """ruby
0 commit comments