super_diff 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/lib/super_diff/active_record.rb +2 -0
  4. data/lib/super_diff/active_record/monkey_patches.rb +9 -0
  5. data/lib/super_diff/csi.rb +4 -0
  6. data/lib/super_diff/equality_matchers/default.rb +1 -1
  7. data/lib/super_diff/operation_sequences/base.rb +14 -0
  8. data/lib/super_diff/rspec.rb +9 -9
  9. data/lib/super_diff/rspec/differ.rb +6 -6
  10. data/lib/super_diff/rspec/differs.rb +9 -3
  11. data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +1 -1
  12. data/lib/super_diff/rspec/differs/{partial_hash.rb → collection_including.rb} +4 -3
  13. data/lib/super_diff/rspec/differs/{partial_array.rb → hash_including.rb} +4 -3
  14. data/lib/super_diff/rspec/differs/{partial_object.rb → object_having_attributes.rb} +3 -3
  15. data/lib/super_diff/rspec/matcher_text_builders.rb +4 -0
  16. data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +26 -7
  17. data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +61 -0
  18. data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +13 -1
  19. data/lib/super_diff/rspec/monkey_patches.rb +218 -111
  20. data/lib/super_diff/rspec/object_inspection/inspectors.rb +6 -6
  21. data/lib/super_diff/rspec/object_inspection/inspectors/{partial_array.rb → collection_including.rb} +2 -2
  22. data/lib/super_diff/rspec/object_inspection/inspectors/{partial_hash.rb → hash_including.rb} +1 -1
  23. data/lib/super_diff/rspec/object_inspection/inspectors/object_having_attributes.rb +22 -0
  24. data/lib/super_diff/rspec/object_inspection/map_extension.rb +7 -7
  25. data/lib/super_diff/rspec/operational_sequencers.rb +6 -6
  26. data/lib/super_diff/rspec/operational_sequencers/collection_containing_exactly.rb +1 -1
  27. data/lib/super_diff/rspec/operational_sequencers/{partial_array.rb → collection_including.rb} +3 -2
  28. data/lib/super_diff/rspec/operational_sequencers/{partial_hash.rb → hash_including.rb} +3 -2
  29. data/lib/super_diff/rspec/operational_sequencers/{partial_object.rb → object_having_attributes.rb} +2 -4
  30. data/lib/super_diff/version.rb +1 -1
  31. data/spec/integration/rails/active_record_spec.rb +1 -1
  32. data/spec/integration/rails/hash_with_indifferent_access_spec.rb +1 -1
  33. data/spec/integration/rspec/be_predicate_matcher_spec.rb +111 -59
  34. data/spec/integration/rspec/eq_matcher_spec.rb +1 -1
  35. data/spec/integration/rspec/have_predicate_matcher_spec.rb +484 -0
  36. data/spec/integration/rspec/match_array_matcher_spec.rb +372 -0
  37. data/spec/integration/rspec/match_matcher_spec.rb +8 -8
  38. data/spec/integration/rspec/raise_error_matcher_spec.rb +605 -226
  39. data/spec/integration/rspec/third_party_matcher_spec.rb +241 -0
  40. data/spec/integration/rspec/unhandled_errors_spec.rb +56 -81
  41. data/spec/spec_helper.rb +18 -7
  42. data/spec/support/integration/helpers.rb +10 -2
  43. data/spec/support/integration/matchers.rb +143 -0
  44. data/spec/support/models/active_record/query.rb +15 -0
  45. data/spec/support/object_id.rb +26 -0
  46. data/spec/support/ruby_versions.rb +4 -0
  47. data/spec/support/shared_examples/active_record.rb +71 -0
  48. data/spec/unit/equality_matcher_spec.rb +8 -8
  49. data/spec/unit/object_inspection_spec.rb +17 -17
  50. data/spec/unit/rspec/matchers/have_predicate_spec.rb +21 -0
  51. data/spec/unit/rspec/matchers/match_array_spec.rb +11 -0
  52. data/super_diff.gemspec +0 -1
  53. metadata +30 -34
  54. data/lib/super_diff/rspec/object_inspection/inspectors/partial_object.rb +0 -21
  55. data/spec/examples.txt +0 -350
@@ -0,0 +1,372 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Integration with RSpec's #match_array matcher", type: :integration do
4
+ context "when a few number of values are given" do
5
+ it "produces the correct failure message when used in the positive" do
6
+ as_both_colored_and_uncolored do |color_enabled|
7
+ snippet = <<~TEST.strip
8
+ expected = ["Einie", "Marty"]
9
+ actual = ["Marty", "Jennifer", "Doc"]
10
+ expect(actual).to match_array(expected)
11
+ TEST
12
+ program = make_plain_test_program(
13
+ snippet,
14
+ color_enabled: color_enabled,
15
+ )
16
+
17
+ expected_output = build_expected_output(
18
+ color_enabled: color_enabled,
19
+ snippet: %|expect(actual).to match_array(expected)|,
20
+ expectation: proc {
21
+ line do
22
+ plain "Expected "
23
+ beta %|["Marty", "Jennifer", "Doc"]|
24
+ plain " to match array with "
25
+ alpha %|"Einie"|
26
+ plain " and "
27
+ alpha %|"Marty"|
28
+ plain "."
29
+ end
30
+ },
31
+ diff: proc {
32
+ plain_line %| [|
33
+ plain_line %| "Marty",|
34
+ plain_line %| "Jennifer",|
35
+ plain_line %| "Doc",|
36
+ alpha_line %|- "Einie"|
37
+ plain_line %| ]|
38
+ },
39
+ )
40
+
41
+ expect(program).
42
+ to produce_output_when_run(expected_output).
43
+ in_color(color_enabled)
44
+ end
45
+ end
46
+
47
+ it "produces the correct failure message when used in the negative" do
48
+ as_both_colored_and_uncolored do |color_enabled|
49
+ snippet = <<~TEST.strip
50
+ values = ["Einie", "Marty"]
51
+ expect(values).not_to match_array(values)
52
+ TEST
53
+ program = make_plain_test_program(
54
+ snippet,
55
+ color_enabled: color_enabled,
56
+ )
57
+
58
+ expected_output = build_expected_output(
59
+ color_enabled: color_enabled,
60
+ snippet: %|expect(values).not_to match_array(values)|,
61
+ expectation: proc {
62
+ line do
63
+ plain "Expected "
64
+ beta %|["Einie", "Marty"]|
65
+ plain " not to match array with "
66
+ alpha %|"Einie"|
67
+ plain " and "
68
+ alpha %|"Marty"|
69
+ plain "."
70
+ end
71
+ },
72
+ )
73
+
74
+ expect(program).
75
+ to produce_output_when_run(expected_output).
76
+ in_color(color_enabled)
77
+ end
78
+ end
79
+ end
80
+
81
+ context "when a large number of values are given" do
82
+ context "and they are only simple strings" do
83
+ it "produces the correct failure message when used in the positive" do
84
+ as_both_colored_and_uncolored do |color_enabled|
85
+ snippet = <<~TEST.strip
86
+ expected = [
87
+ "Doc Brown",
88
+ "Marty McFly",
89
+ "Biff Tannen",
90
+ "George McFly",
91
+ "Lorraine McFly"
92
+ ]
93
+ actual = [
94
+ "Marty McFly",
95
+ "Doc Brown",
96
+ "Einie",
97
+ "Lorraine McFly"
98
+ ]
99
+ expect(actual).to match_array(expected)
100
+ TEST
101
+ program = make_plain_test_program(
102
+ snippet,
103
+ color_enabled: color_enabled,
104
+ )
105
+
106
+ expected_output = build_expected_output(
107
+ color_enabled: color_enabled,
108
+ snippet: %|expect(actual).to match_array(expected)|,
109
+ expectation: proc {
110
+ line do
111
+ plain " Expected "
112
+ beta %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
113
+ end
114
+
115
+ line do
116
+ plain "to match array with "
117
+ alpha %|"Doc Brown"|
118
+ plain ", "
119
+ alpha %|"Marty McFly"|
120
+ plain ", "
121
+ alpha %|"Biff Tannen"|
122
+ plain ", "
123
+ alpha %|"George McFly"|
124
+ plain " and "
125
+ alpha %|"Lorraine McFly"|
126
+ end
127
+ },
128
+ diff: proc {
129
+ plain_line %| [|
130
+ plain_line %| "Marty McFly",|
131
+ plain_line %| "Doc Brown",|
132
+ plain_line %| "Einie",|
133
+ plain_line %| "Lorraine McFly",|
134
+ alpha_line %|- "Biff Tannen",|
135
+ alpha_line %|- "George McFly"|
136
+ plain_line %| ]|
137
+ },
138
+ )
139
+
140
+ expect(program).
141
+ to produce_output_when_run(expected_output).
142
+ in_color(color_enabled)
143
+ end
144
+ end
145
+
146
+ it "produces the correct failure message when used in the negative" do
147
+ as_both_colored_and_uncolored do |color_enabled|
148
+ snippet = <<~TEST.strip
149
+ values = [
150
+ "Marty McFly",
151
+ "Doc Brown",
152
+ "Einie",
153
+ "Lorraine McFly"
154
+ ]
155
+ expect(values).not_to match_array(values)
156
+ TEST
157
+ program = make_plain_test_program(
158
+ snippet,
159
+ color_enabled: color_enabled,
160
+ )
161
+
162
+ expected_output = build_expected_output(
163
+ color_enabled: color_enabled,
164
+ snippet: %|expect(values).not_to match_array(values)|,
165
+ newline_before_expectation: true,
166
+ expectation: proc {
167
+ line do
168
+ plain " Expected "
169
+ beta %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
170
+ end
171
+
172
+ line do
173
+ plain "not to match array with "
174
+ alpha %|"Marty McFly"|
175
+ plain ", "
176
+ alpha %|"Doc Brown"|
177
+ plain ", "
178
+ alpha %|"Einie"|
179
+ plain " and "
180
+ alpha %|"Lorraine McFly"|
181
+ end
182
+ },
183
+ )
184
+
185
+ expect(program).
186
+ to produce_output_when_run(expected_output).
187
+ in_color(color_enabled)
188
+ end
189
+ end
190
+ end
191
+
192
+ context "and some of them are regexen" do
193
+ it "produces the correct failure message when used in the positive" do
194
+ as_both_colored_and_uncolored do |color_enabled|
195
+ snippet = <<~TEST
196
+ expected = [
197
+ / Brown$/,
198
+ "Marty McFly",
199
+ "Biff Tannen",
200
+ /Georg McFly/,
201
+ /Lorrain McFly/
202
+ ]
203
+ actual = [
204
+ "Marty McFly",
205
+ "Doc Brown",
206
+ "Einie",
207
+ "Lorraine McFly"
208
+ ]
209
+ expect(actual).to match_array(expected)
210
+ TEST
211
+ program = make_plain_test_program(
212
+ snippet,
213
+ color_enabled: color_enabled,
214
+ )
215
+
216
+ expected_output = build_expected_output(
217
+ color_enabled: color_enabled,
218
+ snippet: %|expect(actual).to match_array(expected)|,
219
+ expectation: proc {
220
+ line do
221
+ plain " Expected "
222
+ beta %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
223
+ end
224
+
225
+ line do
226
+ plain "to match array with "
227
+ alpha %|/ Brown$/|
228
+ plain ", "
229
+ alpha %|"Marty McFly"|
230
+ plain ", "
231
+ alpha %|"Biff Tannen"|
232
+ plain ", "
233
+ alpha %|/Georg McFly/|
234
+ plain " and "
235
+ alpha %|/Lorrain McFly/|
236
+ end
237
+ },
238
+ diff: proc {
239
+ plain_line %| [|
240
+ plain_line %| "Marty McFly",|
241
+ plain_line %| "Doc Brown",|
242
+ plain_line %| "Einie",|
243
+ plain_line %| "Lorraine McFly",|
244
+ alpha_line %|- "Biff Tannen",|
245
+ alpha_line %|- /Georg McFly/,|
246
+ alpha_line %|- /Lorrain McFly/|
247
+ plain_line %| ]|
248
+ },
249
+ )
250
+
251
+ expect(program).
252
+ to produce_output_when_run(expected_output).
253
+ in_color(color_enabled)
254
+ end
255
+ end
256
+
257
+ it "produces the correct failure message when used in the negative" do
258
+ as_both_colored_and_uncolored do |color_enabled|
259
+ snippet = <<~TEST
260
+ values = [
261
+ / Brown$/,
262
+ "Marty McFly",
263
+ "Biff Tannen",
264
+ /Georg McFly/,
265
+ /Lorrain McFly/
266
+ ]
267
+ expect(values).not_to match_array(values)
268
+ TEST
269
+ program = make_plain_test_program(
270
+ snippet,
271
+ color_enabled: color_enabled,
272
+ )
273
+
274
+ expected_output = build_expected_output(
275
+ color_enabled: color_enabled,
276
+ snippet: %|expect(values).not_to match_array(values)|,
277
+ newline_before_expectation: true,
278
+ expectation: proc {
279
+ line do
280
+ plain " Expected "
281
+ # rubocop:disable Metrics/LineLength
282
+ beta %|[/ Brown$/, "Marty McFly", "Biff Tannen", /Georg McFly/, /Lorrain McFly/]|
283
+ # rubocop:enable Metrics/LineLength
284
+ end
285
+
286
+ line do
287
+ plain "not to match array with "
288
+ alpha %|/ Brown$/|
289
+ plain ", "
290
+ alpha %|"Marty McFly"|
291
+ plain ", "
292
+ alpha %|"Biff Tannen"|
293
+ plain ", "
294
+ alpha %|/Georg McFly/|
295
+ plain " and "
296
+ alpha %|/Lorrain McFly/|
297
+ end
298
+ },
299
+ )
300
+
301
+ expect(program).
302
+ to produce_output_when_run(expected_output).
303
+ in_color(color_enabled)
304
+ end
305
+ end
306
+ end
307
+
308
+ context "and some of them are fuzzy objects" do
309
+ it "produces the correct failure message" do
310
+ as_both_colored_and_uncolored do |color_enabled|
311
+ snippet = <<~TEST.strip
312
+ expected = [
313
+ a_hash_including(foo: "bar"),
314
+ a_collection_containing_exactly("zing"),
315
+ an_object_having_attributes(baz: "qux"),
316
+ ]
317
+ actual = [
318
+ { foo: "bar" },
319
+ double(baz: "qux"),
320
+ { blargh: "riddle" }
321
+ ]
322
+ expect(actual).to match_array(expected)
323
+ TEST
324
+ program = make_plain_test_program(
325
+ snippet,
326
+ color_enabled: color_enabled,
327
+ )
328
+
329
+ expected_output = build_expected_output(
330
+ color_enabled: color_enabled,
331
+ snippet: %|expect(actual).to match_array(expected)|,
332
+ expectation: proc {
333
+ line do
334
+ plain " Expected "
335
+ # rubocop:disable Metrics/LineLength
336
+ beta %|[{ foo: "bar" }, #<Double (anonymous)>, { blargh: "riddle" }]|
337
+ # rubocop:enable Metrics/LineLength
338
+ end
339
+
340
+ line do
341
+ plain "to match array with "
342
+ alpha %|#<a hash including (foo: "bar")>|
343
+ plain ", "
344
+ alpha %|#<a collection containing exactly ("zing")>|
345
+ plain " and "
346
+ alpha %|#<an object having attributes (baz: "qux")>|
347
+ end
348
+ },
349
+ diff: proc {
350
+ plain_line %| [|
351
+ plain_line %| {|
352
+ plain_line %| foo: "bar"|
353
+ plain_line %| },|
354
+ plain_line %| #<Double (anonymous)>,|
355
+ plain_line %| {|
356
+ plain_line %| blargh: "riddle"|
357
+ plain_line %| },|
358
+ alpha_line %|- #<a collection containing exactly (|
359
+ alpha_line %|- "zing"|
360
+ alpha_line %|- )>|
361
+ plain_line %| ]|
362
+ },
363
+ )
364
+
365
+ expect(program).
366
+ to produce_output_when_run(expected_output).
367
+ in_color(color_enabled)
368
+ end
369
+ end
370
+ end
371
+ end
372
+ end
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
4
- context "when the expected value is a partial hash" do
4
+ context "when the expected value is a hash-including-<something>" do
5
5
  context "that is small" do
6
6
  it "produces the correct failure message when used in the positive" do
7
7
  as_both_colored_and_uncolored do |color_enabled|
@@ -172,7 +172,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
172
172
  end
173
173
  end
174
174
 
175
- context "when the expected value includes a partial hash" do
175
+ context "when the expected value includes a hash-including-<something>" do
176
176
  context "and the corresponding actual value is a hash" do
177
177
  it "produces the correct failure message when used in the positive" do
178
178
  as_both_colored_and_uncolored do |color_enabled|
@@ -341,7 +341,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
341
341
  end
342
342
  end
343
343
 
344
- context "when the expected value is a partial array" do
344
+ context "when the expected value is a collection-including-<something>" do
345
345
  context "that is small" do
346
346
  it "produces the correct failure message when used in the positive" do
347
347
  as_both_colored_and_uncolored do |color_enabled|
@@ -498,7 +498,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
498
498
  end
499
499
  end
500
500
 
501
- context "when the expected value includes a partial array" do
501
+ context "when the expected value includes a collection-including-<something>" do
502
502
  context "and the corresponding actual value is an array" do
503
503
  it "produces the correct failure message when used in the positive" do
504
504
  as_both_colored_and_uncolored do |color_enabled|
@@ -647,7 +647,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
647
647
  end
648
648
  end
649
649
 
650
- context "when the expected value is a partial object" do
650
+ context "when the expected value is an object-having-attributes" do
651
651
  context "that is small" do
652
652
  it "produces the correct failure message when used in the positive" do
653
653
  as_both_colored_and_uncolored do |color_enabled|
@@ -830,7 +830,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
830
830
  end
831
831
  end
832
832
 
833
- context "when the expected value includes a partial object" do
833
+ context "when the expected value includes an object-having-attributes" do
834
834
  it "produces the correct failure message when used in the positive" do
835
835
  as_both_colored_and_uncolored do |color_enabled|
836
836
  snippet = <<~TEST.strip
@@ -953,7 +953,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
953
953
  end
954
954
  end
955
955
 
956
- context "when the expected value is an order-independent array" do
956
+ context "when the expected value is a collection-containing-exactly-<something>" do
957
957
  context "that is small" do
958
958
  it "produces the correct failure message when used in the positive" do
959
959
  as_both_colored_and_uncolored do |color_enabled|
@@ -1108,7 +1108,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1108
1108
  end
1109
1109
  end
1110
1110
 
1111
- context "when the expected value includes an order-independent array" do
1111
+ context "when the expected value includes a collection-containing-exactly-<something>" do
1112
1112
  context "and the corresponding actual value is an array" do
1113
1113
  it "produces the correct failure message when used in the positive" do
1114
1114
  as_both_colored_and_uncolored do |color_enabled|
@@ -2,138 +2,113 @@ require "spec_helper"
2
2
 
3
3
  RSpec.describe "Integration with RSpec's #raise_error matcher", type: :integration do
4
4
  context "given only an exception class" do
5
- it "produces the correct failure message when used in the positive" do
6
- as_both_colored_and_uncolored do |color_enabled|
7
- snippet = <<~TEST.strip
8
- expect { raise StandardError.new('boo') }.to raise_error(RuntimeError)
9
- TEST
10
- program = make_plain_test_program(
11
- snippet,
12
- color_enabled: color_enabled,
13
- )
14
-
15
- expected_output = build_expected_output(
16
- color_enabled: color_enabled,
17
- snippet: %|expect { raise StandardError.new('boo') }.to raise_error(RuntimeError)|,
18
- expectation: proc {
19
- line do
20
- plain "Expected raised exception "
21
- beta %|#<StandardError "boo">|
22
- plain " to match "
23
- alpha %|#<RuntimeError>|
24
- plain "."
5
+ context "when used in the positive" do
6
+ context "when the block raises a different error than what is given" do
7
+ context "when the message is short" do
8
+ it "produces the correct failure message" do
9
+ as_both_colored_and_uncolored do |color_enabled|
10
+ snippet = <<~TEST.strip
11
+ expect { raise StandardError.new('boo') }.to raise_error(RuntimeError)
12
+ TEST
13
+ program = make_plain_test_program(
14
+ snippet,
15
+ color_enabled: color_enabled,
16
+ )
17
+
18
+ expected_output = build_expected_output(
19
+ color_enabled: color_enabled,
20
+ snippet: %|expect { raise StandardError.new('boo') }.to raise_error(RuntimeError)|,
21
+ expectation: proc {
22
+ line do
23
+ plain "Expected raised exception "
24
+ beta %|#<StandardError "boo">|
25
+ plain " to match "
26
+ alpha %|#<RuntimeError>|
27
+ plain "."
28
+ end
29
+ },
30
+ )
31
+
32
+ expect(program).
33
+ to produce_output_when_run(expected_output).
34
+ in_color(color_enabled)
25
35
  end
26
- },
27
- )
28
-
29
- expect(program).
30
- to produce_output_when_run(expected_output).
31
- in_color(color_enabled)
32
- end
33
- end
36
+ end
37
+ end
34
38
 
35
- it "produces the correct failure message when used in the negative" do
36
- as_both_colored_and_uncolored do |color_enabled|
37
- snippet = <<~TEST.strip
38
- expect { raise StandardError.new('boo') }.not_to raise_error(StandardError)
39
- TEST
40
- program = make_plain_test_program(
41
- snippet,
42
- color_enabled: color_enabled,
43
- )
44
-
45
- expected_output = build_expected_output(
46
- color_enabled: color_enabled,
47
- snippet: %|expect { raise StandardError.new('boo') }.not_to raise_error(StandardError)|,
48
- expectation: proc {
49
- line do
50
- plain "Expected raised exception "
51
- beta %|#<StandardError "boo">|
52
- plain " not to match "
53
- alpha %|#<StandardError>|
54
- plain "."
39
+ context "when the message is long" do
40
+ it "produces the correct failure message" do
41
+ as_both_colored_and_uncolored do |color_enabled|
42
+ snippet = <<~TEST.strip
43
+ expect { raise StandardError.new('this is a super super super long message') }.to raise_error(RuntimeError)
44
+ TEST
45
+ program = make_plain_test_program(
46
+ snippet,
47
+ color_enabled: color_enabled,
48
+ )
49
+
50
+ expected_output = build_expected_output(
51
+ color_enabled: color_enabled,
52
+ snippet: %|expect { raise StandardError.new('this is a super super super long message') }.to raise_error(RuntimeError)|,
53
+ newline_before_expectation: true,
54
+ expectation: proc {
55
+ line do
56
+ plain "Expected raised exception "
57
+ beta %|#<StandardError "this is a super super super long message">|
58
+ end
59
+
60
+ line do
61
+ plain " to match "
62
+ alpha %|#<RuntimeError>|
63
+ end
64
+ },
65
+ )
66
+
67
+ expect(program).
68
+ to produce_output_when_run(expected_output).
69
+ in_color(color_enabled)
55
70
  end
56
- },
57
- )
58
-
59
- expect(program).
60
- to produce_output_when_run(expected_output).
61
- in_color(color_enabled)
62
- end
63
- end
64
- end
65
-
66
- context "with only a message (and assuming a RuntimeError)" do
67
- context "when the message is short" do
68
- it "produces the correct failure message when used in the positive" do
69
- as_both_colored_and_uncolored do |color_enabled|
70
- snippet = <<~TEST.strip
71
- expect { raise 'boo' }.to raise_error('hell')
72
- TEST
73
- program = make_plain_test_program(
74
- snippet,
75
- color_enabled: color_enabled,
76
- )
77
-
78
- expected_output = build_expected_output(
79
- color_enabled: color_enabled,
80
- snippet: %|expect { raise 'boo' }.to raise_error('hell')|,
81
- expectation: proc {
82
- line do
83
- plain "Expected raised exception "
84
- beta %|#<RuntimeError "boo">|
85
- plain " to match "
86
- alpha %|#<Exception "hell">|
87
- plain "."
88
- end
89
- },
90
- )
91
-
92
- expect(program).
93
- to produce_output_when_run(expected_output).
94
- in_color(color_enabled)
71
+ end
95
72
  end
96
73
  end
97
74
 
98
- it "produces the correct failure message when used in the negative" do
99
- as_both_colored_and_uncolored do |color_enabled|
100
- snippet = <<~TEST.strip
101
- expect { raise 'boo' }.not_to raise_error('boo')
102
- TEST
103
- program = make_plain_test_program(
104
- snippet,
105
- color_enabled: color_enabled,
106
- )
107
-
108
- expected_output = build_expected_output(
109
- color_enabled: color_enabled,
110
- snippet: %|expect { raise 'boo' }.not_to raise_error('boo')|,
111
- expectation: proc {
112
- line do
113
- plain "Expected raised exception "
114
- beta %|#<RuntimeError "boo">|
115
- plain " not to match "
116
- alpha %|#<Exception "boo">|
117
- plain "."
118
- end
119
- },
120
- )
75
+ context "when the block raises no error" do
76
+ it "produces the correct failure message" do
77
+ as_both_colored_and_uncolored do |color_enabled|
78
+ snippet = <<~TEST.strip
79
+ expect { }.to raise_error(RuntimeError)
80
+ TEST
81
+ program = make_plain_test_program(
82
+ snippet,
83
+ color_enabled: color_enabled,
84
+ )
121
85
 
122
- expect(program).
123
- to produce_output_when_run(expected_output).
124
- in_color(color_enabled)
86
+ expected_output = build_expected_output(
87
+ color_enabled: color_enabled,
88
+ snippet: %|expect { }.to raise_error(RuntimeError)|,
89
+ expectation: proc {
90
+ line do
91
+ plain "Expected block to raise error "
92
+ alpha %|#<RuntimeError>|
93
+ plain "."
94
+ end
95
+ },
96
+ )
97
+
98
+ expect(program).
99
+ to produce_output_when_run(expected_output).
100
+ in_color(color_enabled)
101
+ end
125
102
  end
126
103
  end
127
104
  end
128
105
 
129
- context "when the message is long" do
130
- context "but contains no line breaks" do
131
- it "produces the correct failure message when used in the positive" do
106
+ context "when used in the negative" do
107
+ context "when the message is short" do
108
+ it "produces the correct failure message" do
132
109
  as_both_colored_and_uncolored do |color_enabled|
133
110
  snippet = <<~TEST.strip
134
- actual_message = "some really really really long message"
135
- expected_message = "whatever"
136
- expect { raise(actual_message) }.to raise_error(expected_message)
111
+ expect { raise StandardError.new('boo') }.not_to raise_error(StandardError)
137
112
  TEST
138
113
  program = make_plain_test_program(
139
114
  snippet,
@@ -142,17 +117,14 @@ RSpec.describe "Integration with RSpec's #raise_error matcher", type: :integrati
142
117
 
143
118
  expected_output = build_expected_output(
144
119
  color_enabled: color_enabled,
145
- snippet: %|expect { raise(actual_message) }.to raise_error(expected_message)|,
146
- newline_before_expectation: true,
120
+ snippet: %|expect { raise StandardError.new('boo') }.not_to raise_error(StandardError)|,
147
121
  expectation: proc {
148
122
  line do
149
123
  plain "Expected raised exception "
150
- beta %|#<RuntimeError "some really really really long message">|
151
- end
152
-
153
- line do
154
- plain " to match "
155
- alpha %|#<Exception "whatever">|
124
+ beta %|#<StandardError "boo">|
125
+ plain " not to match "
126
+ alpha %|#<StandardError>|
127
+ plain "."
156
128
  end
157
129
  },
158
130
  )
@@ -162,12 +134,13 @@ RSpec.describe "Integration with RSpec's #raise_error matcher", type: :integrati
162
134
  in_color(color_enabled)
163
135
  end
164
136
  end
137
+ end
165
138
 
166
- it "produces the correct failure message when used in the negative" do
139
+ context "when the message is long" do
140
+ it "produces the correct failure message" do
167
141
  as_both_colored_and_uncolored do |color_enabled|
168
142
  snippet = <<~TEST.strip
169
- message = "some really long message"
170
- expect { raise(message) }.not_to raise_error(message)
143
+ expect { raise StandardError.new('this is a super super long message') }.not_to raise_error(StandardError)
171
144
  TEST
172
145
  program = make_plain_test_program(
173
146
  snippet,
@@ -176,17 +149,17 @@ RSpec.describe "Integration with RSpec's #raise_error matcher", type: :integrati
176
149
 
177
150
  expected_output = build_expected_output(
178
151
  color_enabled: color_enabled,
179
- snippet: %|expect { raise(message) }.not_to raise_error(message)|,
152
+ snippet: %|expect { raise StandardError.new('this is a super super long message') }.not_to raise_error(StandardError)|,
180
153
  newline_before_expectation: true,
181
154
  expectation: proc {
182
155
  line do
183
156
  plain "Expected raised exception "
184
- beta %|#<RuntimeError "some really long message">|
157
+ beta %|#<StandardError "this is a super super long message">|
185
158
  end
186
159
 
187
160
  line do
188
161
  plain " not to match "
189
- alpha %|#<Exception "some really long message">|
162
+ alpha %|#<StandardError>|
190
163
  end
191
164
  },
192
165
  )
@@ -197,20 +170,244 @@ RSpec.describe "Integration with RSpec's #raise_error matcher", type: :integrati
197
170
  end
198
171
  end
199
172
  end
173
+ end
174
+ end
175
+
176
+ context "with only a message (and assuming a RuntimeError)" do
177
+ context "when used in the positive" do
178
+ context "when the block raises a different error than what is given" do
179
+ context "when the message is short" do
180
+ it "produces the correct failure message" do
181
+ as_both_colored_and_uncolored do |color_enabled|
182
+ snippet = <<~TEST.strip
183
+ expect { raise 'boo' }.to raise_error('hell')
184
+ TEST
185
+ program = make_plain_test_program(
186
+ snippet,
187
+ color_enabled: color_enabled,
188
+ )
189
+
190
+ expected_output = build_expected_output(
191
+ color_enabled: color_enabled,
192
+ snippet: %|expect { raise 'boo' }.to raise_error('hell')|,
193
+ expectation: proc {
194
+ line do
195
+ plain "Expected raised exception "
196
+ beta %|#<RuntimeError "boo">|
197
+ plain " to match "
198
+ alpha %|#<Exception "hell">|
199
+ plain "."
200
+ end
201
+ },
202
+ )
203
+
204
+ expect(program).
205
+ to produce_output_when_run(expected_output).
206
+ in_color(color_enabled)
207
+ end
208
+ end
209
+ end
210
+
211
+ context "when the message is long" do
212
+ context "but contains no line breaks" do
213
+ it "produces the correct failure message when used in the positive" do
214
+ as_both_colored_and_uncolored do |color_enabled|
215
+ snippet = <<~TEST.strip
216
+ actual_message = "some really really really long message"
217
+ expected_message = "whatever"
218
+ expect { raise(actual_message) }.to raise_error(expected_message)
219
+ TEST
220
+ program = make_plain_test_program(
221
+ snippet,
222
+ color_enabled: color_enabled,
223
+ )
224
+
225
+ expected_output = build_expected_output(
226
+ color_enabled: color_enabled,
227
+ snippet: %|expect { raise(actual_message) }.to raise_error(expected_message)|,
228
+ newline_before_expectation: true,
229
+ expectation: proc {
230
+ line do
231
+ plain "Expected raised exception "
232
+ beta %|#<RuntimeError "some really really really long message">|
233
+ end
234
+
235
+ line do
236
+ plain " to match "
237
+ alpha %|#<Exception "whatever">|
238
+ end
239
+ },
240
+ )
241
+
242
+ expect(program).
243
+ to produce_output_when_run(expected_output).
244
+ in_color(color_enabled)
245
+ end
246
+ end
247
+ end
248
+
249
+ context "but contains line breaks" do
250
+ it "produces the correct failure message when used in the positive" do
251
+ as_both_colored_and_uncolored do |color_enabled|
252
+ snippet = <<~TEST.strip
253
+ actual_message = <<\~MESSAGE.rstrip
254
+ This is fun
255
+ So is this
256
+ MESSAGE
257
+ expected_message = <<\~MESSAGE.rstrip
258
+ This is fun
259
+ And so is this
260
+ MESSAGE
261
+ expect { raise(actual_message) }.to raise_error(expected_message)
262
+ TEST
263
+ program = make_plain_test_program(
264
+ snippet,
265
+ color_enabled: color_enabled,
266
+ )
267
+
268
+ expected_output = build_expected_output(
269
+ color_enabled: color_enabled,
270
+ snippet: %|expect { raise(actual_message) }.to raise_error(expected_message)|,
271
+ expectation: proc {
272
+ line do
273
+ plain "Expected raised exception "
274
+ beta %|#<RuntimeError "This is fun\\nSo is this">|
275
+ end
276
+
277
+ line do
278
+ plain " to match "
279
+ alpha %|#<Exception "This is fun\\nAnd so is this">|
280
+ end
281
+ },
282
+ diff: proc {
283
+ plain_line %| This is fun\\n|
284
+ alpha_line %|- And so is this|
285
+ beta_line %|+ So is this|
286
+ },
287
+ )
288
+
289
+ expect(program).
290
+ to produce_output_when_run(expected_output).
291
+ in_color(color_enabled)
292
+ end
293
+ end
294
+ end
295
+ end
296
+ end
297
+
298
+ context "when the block raises no error" do
299
+ context "when the message is short" do
300
+ it "produces the correct failure message" do
301
+ as_both_colored_and_uncolored do |color_enabled|
302
+ snippet = <<~TEST.strip
303
+ expect { }.to raise_error('hell')
304
+ TEST
305
+ program = make_plain_test_program(
306
+ snippet,
307
+ color_enabled: color_enabled,
308
+ )
309
+
310
+ expected_output = build_expected_output(
311
+ color_enabled: color_enabled,
312
+ snippet: %|expect { }.to raise_error('hell')|,
313
+ expectation: proc {
314
+ line do
315
+ plain "Expected block to raise error "
316
+ alpha %|#<Exception "hell">|
317
+ plain "."
318
+ end
319
+ },
320
+ )
321
+
322
+ expect(program).
323
+ to produce_output_when_run(expected_output).
324
+ in_color(color_enabled)
325
+ end
326
+ end
327
+
328
+ end
329
+
330
+ context "when the message is long" do
331
+ context "but contains no line breaks" do
332
+ it "produces the correct failure message" do
333
+ as_both_colored_and_uncolored do |color_enabled|
334
+ snippet = <<~TEST.strip
335
+ expect { }.to raise_error("this is a super super super super super super long message")
336
+ TEST
337
+ program = make_plain_test_program(
338
+ snippet,
339
+ color_enabled: color_enabled,
340
+ )
341
+
342
+ expected_output = build_expected_output(
343
+ color_enabled: color_enabled,
344
+ snippet: %|expect { }.to raise_error("this is a super super super super super super long message")|,
345
+ newline_before_expectation: true,
346
+ expectation: proc {
347
+ line do
348
+ plain " Expected "
349
+ plain "block"
350
+ end
351
+
352
+ line do
353
+ plain "to raise error "
354
+ alpha %|#<Exception "this is a super super super super super super long message">|
355
+ end
356
+ },
357
+ )
358
+
359
+ expect(program).
360
+ to produce_output_when_run(expected_output).
361
+ in_color(color_enabled)
362
+ end
363
+ end
364
+ end
365
+
366
+ context "but contains line breaks" do
367
+ it "produces the correct failure message when used in the negative" do
368
+ as_both_colored_and_uncolored do |color_enabled|
369
+ snippet = <<~TEST.strip
370
+ message = "some really long message"
371
+ expect { raise(message) }.not_to raise_error(message)
372
+ TEST
373
+ program = make_plain_test_program(
374
+ snippet,
375
+ color_enabled: color_enabled,
376
+ )
377
+
378
+ expected_output = build_expected_output(
379
+ color_enabled: color_enabled,
380
+ snippet: %|expect { raise(message) }.not_to raise_error(message)|,
381
+ newline_before_expectation: true,
382
+ expectation: proc {
383
+ line do
384
+ plain "Expected raised exception "
385
+ beta %|#<RuntimeError "some really long message">|
386
+ end
387
+
388
+ line do
389
+ plain " not to match "
390
+ alpha %|#<Exception "some really long message">|
391
+ end
392
+ },
393
+ )
394
+
395
+ expect(program).
396
+ to produce_output_when_run(expected_output).
397
+ in_color(color_enabled)
398
+ end
399
+ end
400
+ end
401
+ end
402
+ end
403
+ end
200
404
 
201
- context "but contains line breaks" do
202
- it "produces the correct failure message when used in the positive" do
405
+ context "when used in the negative" do
406
+ context "when the message is short" do
407
+ it "produces the correct failure message" do
203
408
  as_both_colored_and_uncolored do |color_enabled|
204
409
  snippet = <<~TEST.strip
205
- actual_message = <<\~MESSAGE.rstrip
206
- This is fun
207
- So is this
208
- MESSAGE
209
- expected_message = <<\~MESSAGE.rstrip
210
- This is fun
211
- And so is this
212
- MESSAGE
213
- expect { raise(actual_message) }.to raise_error(expected_message)
410
+ expect { raise 'boo' }.not_to raise_error('boo')
214
411
  TEST
215
412
  program = make_plain_test_program(
216
413
  snippet,
@@ -219,23 +416,270 @@ RSpec.describe "Integration with RSpec's #raise_error matcher", type: :integrati
219
416
 
220
417
  expected_output = build_expected_output(
221
418
  color_enabled: color_enabled,
222
- snippet: %|expect { raise(actual_message) }.to raise_error(expected_message)|,
419
+ snippet: %|expect { raise 'boo' }.not_to raise_error('boo')|,
223
420
  expectation: proc {
224
421
  line do
225
422
  plain "Expected raised exception "
226
- beta %|#<RuntimeError "This is fun\\nSo is this">|
423
+ beta %|#<RuntimeError "boo">|
424
+ plain " not to match "
425
+ alpha %|#<Exception "boo">|
426
+ plain "."
227
427
  end
428
+ },
429
+ )
430
+
431
+ expect(program).
432
+ to produce_output_when_run(expected_output).
433
+ in_color(color_enabled)
434
+ end
435
+ end
436
+ end
228
437
 
438
+ context "when the message is long" do
439
+ context "but contains no line breaks" do
440
+ it "produces the correct failure message" do
441
+ as_both_colored_and_uncolored do |color_enabled|
442
+ snippet = <<~TEST.strip
443
+ message = "some really long message"
444
+ expect { raise(message) }.not_to raise_error(message)
445
+ TEST
446
+ program = make_plain_test_program(
447
+ snippet,
448
+ color_enabled: color_enabled,
449
+ )
450
+
451
+ expected_output = build_expected_output(
452
+ color_enabled: color_enabled,
453
+ snippet: %|expect { raise(message) }.not_to raise_error(message)|,
454
+ newline_before_expectation: true,
455
+ expectation: proc {
456
+ line do
457
+ plain "Expected raised exception "
458
+ beta %|#<RuntimeError "some really long message">|
459
+ end
460
+
461
+ line do
462
+ plain " not to match "
463
+ alpha %|#<Exception "some really long message">|
464
+ end
465
+ },
466
+ )
467
+
468
+ expect(program).
469
+ to produce_output_when_run(expected_output).
470
+ in_color(color_enabled)
471
+ end
472
+ end
473
+ end
474
+
475
+ context "but contains line breaks" do
476
+ it "produces the correct failure message" do
477
+ as_both_colored_and_uncolored do |color_enabled|
478
+ snippet = <<~TEST.strip
479
+ message = <<\~MESSAGE.rstrip
480
+ This is fun
481
+ So is this
482
+ MESSAGE
483
+ expect { raise(message) }.not_to raise_error(message)
484
+ TEST
485
+ program = make_plain_test_program(
486
+ snippet,
487
+ color_enabled: color_enabled,
488
+ )
489
+
490
+ expected_output = build_expected_output(
491
+ color_enabled: color_enabled,
492
+ snippet: %|expect { raise(message) }.not_to raise_error(message)|,
493
+ newline_before_expectation: true,
494
+ expectation: proc {
495
+ line do
496
+ plain "Expected raised exception "
497
+ beta %|#<RuntimeError "This is fun\\nSo is this">|
498
+ end
499
+
500
+ line do
501
+ plain " not to match "
502
+ alpha %|#<Exception "This is fun\\nSo is this">|
503
+ end
504
+ },
505
+ )
506
+
507
+ expect(program).
508
+ to produce_output_when_run(expected_output).
509
+ in_color(color_enabled)
510
+ end
511
+ end
512
+ end
513
+ end
514
+ end
515
+ end
516
+
517
+ context "with both an exception and a message" do
518
+ context "when used in the positive" do
519
+ context "when the block raises a different error than what is given" do
520
+ context "when the message is short" do
521
+ it "produces the correct failure message" do
522
+ as_both_colored_and_uncolored do |color_enabled|
523
+ snippet = <<~TEST.strip
524
+ block = -> { raise StandardError.new('a') }
525
+ expect(&block).to raise_error(RuntimeError, 'b')
526
+ TEST
527
+ program = make_plain_test_program(
528
+ snippet,
529
+ color_enabled: color_enabled,
530
+ )
531
+
532
+ expected_output = build_expected_output(
533
+ color_enabled: color_enabled,
534
+ snippet: %|expect(&block).to raise_error(RuntimeError, 'b')|,
535
+ expectation: proc {
536
+ line do
537
+ plain "Expected raised exception "
538
+ beta %|#<StandardError "a">|
539
+ plain " to match "
540
+ alpha %|#<RuntimeError "b">|
541
+ plain "."
542
+ end
543
+ },
544
+ )
545
+
546
+ expect(program).
547
+ to produce_output_when_run(expected_output).
548
+ in_color(color_enabled)
549
+ end
550
+ end
551
+ end
552
+
553
+ context "when the message is long" do
554
+ it "produces the correct failure message" do
555
+ as_both_colored_and_uncolored do |color_enabled|
556
+ snippet = <<~TEST.strip
557
+ block = -> { raise StandardError.new('this is a long message') }
558
+ expect(&block).to raise_error(RuntimeError, 'this is another long message')
559
+ TEST
560
+ program = make_plain_test_program(
561
+ snippet,
562
+ color_enabled: color_enabled,
563
+ )
564
+
565
+ expected_output = build_expected_output(
566
+ color_enabled: color_enabled,
567
+ snippet: %|expect(&block).to raise_error(RuntimeError, 'this is another long message')|,
568
+ newline_before_expectation: true,
569
+ expectation: proc {
570
+ line do
571
+ plain "Expected raised exception "
572
+ beta %|#<StandardError "this is a long message">|
573
+ end
574
+
575
+ line do
576
+ plain " to match "
577
+ alpha %|#<RuntimeError "this is another long message">|
578
+ end
579
+ },
580
+ )
581
+
582
+ expect(program).
583
+ to produce_output_when_run(expected_output).
584
+ in_color(color_enabled)
585
+ end
586
+ end
587
+ end
588
+ end
589
+
590
+ context "when the block raises no error" do
591
+ context "when the message is short" do
592
+ it "produces the correct failure message" do
593
+ as_both_colored_and_uncolored do |color_enabled|
594
+ snippet = <<~TEST.strip
595
+ expect { }.to raise_error(RuntimeError, 'b')
596
+ TEST
597
+ program = make_plain_test_program(
598
+ snippet,
599
+ color_enabled: color_enabled,
600
+ )
601
+
602
+ expected_output = build_expected_output(
603
+ color_enabled: color_enabled,
604
+ snippet: %|expect { }.to raise_error(RuntimeError, 'b')|,
605
+ expectation: proc {
606
+ line do
607
+ plain "Expected block to raise error "
608
+ alpha %|#<RuntimeError "b">|
609
+ plain "."
610
+ end
611
+ },
612
+ )
613
+
614
+ expect(program).
615
+ to produce_output_when_run(expected_output).
616
+ in_color(color_enabled)
617
+ end
618
+ end
619
+ end
620
+
621
+ context "when the message is long" do
622
+ it "produces the correct failure message" do
623
+ as_both_colored_and_uncolored do |color_enabled|
624
+ snippet = <<~TEST.strip
625
+ expect { }.to raise_error(RuntimeError, 'this is a super super super super super super long message')
626
+ TEST
627
+ program = make_plain_test_program(
628
+ snippet,
629
+ color_enabled: color_enabled,
630
+ )
631
+
632
+ expected_output = build_expected_output(
633
+ color_enabled: color_enabled,
634
+ snippet: %|expect { }.to raise_error(RuntimeError, 'this is a super super super super super super long message')|,
635
+ newline_before_expectation: true,
636
+ expectation: proc {
637
+ line do
638
+ plain " Expected "
639
+ plain "block"
640
+ end
641
+
642
+ line do
643
+ plain "to raise error "
644
+ alpha %|#<RuntimeError "this is a super super super super super super long message">|
645
+ end
646
+ },
647
+ )
648
+
649
+ expect(program).
650
+ to produce_output_when_run(expected_output).
651
+ in_color(color_enabled)
652
+ end
653
+ end
654
+ end
655
+ end
656
+ end
657
+
658
+ context "when used in the negative" do
659
+ context "when the message is short" do
660
+ it "produces the correct failure message" do
661
+ as_both_colored_and_uncolored do |color_enabled|
662
+ snippet = <<~TEST.strip
663
+ block = -> { raise StandardError.new('a') }
664
+ expect(&block).not_to raise_error(StandardError, 'a')
665
+ TEST
666
+ program = make_plain_test_program(
667
+ snippet,
668
+ color_enabled: color_enabled,
669
+ )
670
+
671
+ expected_output = build_expected_output(
672
+ color_enabled: color_enabled,
673
+ snippet: %|expect(&block).not_to raise_error(StandardError, 'a')|,
674
+ expectation: proc {
229
675
  line do
230
- plain " to match "
231
- alpha %|#<Exception "This is fun\\nAnd so is this">|
676
+ plain "Expected raised exception "
677
+ beta %|#<StandardError "a">|
678
+ plain " not to match "
679
+ alpha %|#<StandardError "a">|
680
+ plain "."
232
681
  end
233
682
  },
234
- diff: proc {
235
- plain_line %| This is fun\\n|
236
- alpha_line %|- And so is this|
237
- beta_line %|+ So is this|
238
- },
239
683
  )
240
684
 
241
685
  expect(program).
@@ -243,15 +687,14 @@ RSpec.describe "Integration with RSpec's #raise_error matcher", type: :integrati
243
687
  in_color(color_enabled)
244
688
  end
245
689
  end
690
+ end
246
691
 
247
- it "produces the correct failure message when used in the negative" do
692
+ context "when the message is long" do
693
+ it "produces the correct failure message" do
248
694
  as_both_colored_and_uncolored do |color_enabled|
249
695
  snippet = <<~TEST.strip
250
- message = <<\~MESSAGE.rstrip
251
- This is fun
252
- So is this
253
- MESSAGE
254
- expect { raise(message) }.not_to raise_error(message)
696
+ block = -> { raise StandardError.new('this is a long message') }
697
+ expect(&block).not_to raise_error(StandardError, 'this is a long message')
255
698
  TEST
256
699
  program = make_plain_test_program(
257
700
  snippet,
@@ -260,17 +703,17 @@ RSpec.describe "Integration with RSpec's #raise_error matcher", type: :integrati
260
703
 
261
704
  expected_output = build_expected_output(
262
705
  color_enabled: color_enabled,
263
- snippet: %|expect { raise(message) }.not_to raise_error(message)|,
706
+ snippet: %|expect(&block).not_to raise_error(StandardError, 'this is a long message')|,
264
707
  newline_before_expectation: true,
265
708
  expectation: proc {
266
709
  line do
267
710
  plain "Expected raised exception "
268
- beta %|#<RuntimeError "This is fun\\nSo is this">|
711
+ beta %|#<StandardError "this is a long message">|
269
712
  end
270
713
 
271
714
  line do
272
715
  plain " not to match "
273
- alpha %|#<Exception "This is fun\\nSo is this">|
716
+ alpha %|#<StandardError "this is a long message">|
274
717
  end
275
718
  },
276
719
  )
@@ -283,68 +726,4 @@ RSpec.describe "Integration with RSpec's #raise_error matcher", type: :integrati
283
726
  end
284
727
  end
285
728
  end
286
-
287
- context "with both an exception and a message" do
288
- it "produces the correct failure message when used in the positive" do
289
- as_both_colored_and_uncolored do |color_enabled|
290
- snippet = <<~TEST.strip
291
- block = -> { raise StandardError.new('a') }
292
- expect(&block).to raise_error(RuntimeError, 'b')
293
- TEST
294
- program = make_plain_test_program(
295
- snippet,
296
- color_enabled: color_enabled,
297
- )
298
-
299
- expected_output = build_expected_output(
300
- color_enabled: color_enabled,
301
- snippet: %|expect(&block).to raise_error(RuntimeError, 'b')|,
302
- expectation: proc {
303
- line do
304
- plain "Expected raised exception "
305
- beta %|#<StandardError "a">|
306
- plain " to match "
307
- alpha %|#<RuntimeError "b">|
308
- plain "."
309
- end
310
- },
311
- )
312
-
313
- expect(program).
314
- to produce_output_when_run(expected_output).
315
- in_color(color_enabled)
316
- end
317
- end
318
-
319
- it "produces the correct failure message when used in the negative" do
320
- as_both_colored_and_uncolored do |color_enabled|
321
- snippet = <<~TEST.strip
322
- block = -> { raise StandardError.new('a') }
323
- expect(&block).not_to raise_error(StandardError, 'a')
324
- TEST
325
- program = make_plain_test_program(
326
- snippet,
327
- color_enabled: color_enabled,
328
- )
329
-
330
- expected_output = build_expected_output(
331
- color_enabled: color_enabled,
332
- snippet: %|expect(&block).not_to raise_error(StandardError, 'a')|,
333
- expectation: proc {
334
- line do
335
- plain "Expected raised exception "
336
- beta %|#<StandardError "a">|
337
- plain " not to match "
338
- alpha %|#<StandardError "a">|
339
- plain "."
340
- end
341
- },
342
- )
343
-
344
- expect(program).
345
- to produce_output_when_run(expected_output).
346
- in_color(color_enabled)
347
- end
348
- end
349
- end
350
729
  end