super_diff 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +24 -12
  3. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +15 -6
  4. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +23 -8
  5. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/ordered_options.rb +46 -0
  6. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +4 -0
  7. data/lib/super_diff/active_support.rb +2 -1
  8. data/lib/super_diff/differs/date_like.rb +15 -0
  9. data/lib/super_diff/differs/defaults.rb +1 -0
  10. data/lib/super_diff/differs.rb +1 -0
  11. data/lib/super_diff/errors.rb +0 -4
  12. data/lib/super_diff/object_inspection/inspection_tree.rb +25 -20
  13. data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +31 -12
  14. data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +19 -9
  15. data/lib/super_diff/object_inspection/inspection_tree_builders/date_like.rb +51 -0
  16. data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +46 -21
  17. data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +1 -0
  18. data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +39 -14
  19. data/lib/super_diff/object_inspection/inspection_tree_builders/primitive.rb +3 -5
  20. data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +31 -20
  21. data/lib/super_diff/object_inspection/inspection_tree_builders.rb +4 -0
  22. data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +3 -2
  23. data/lib/super_diff/operation_tree_builders/date_like.rb +15 -0
  24. data/lib/super_diff/operation_tree_builders/defaults.rb +1 -1
  25. data/lib/super_diff/operation_tree_builders.rb +1 -0
  26. data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +3 -7
  27. data/lib/super_diff/rspec/monkey_patches.rb +59 -8
  28. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_containing_exactly.rb +14 -7
  29. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +19 -13
  30. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +30 -26
  31. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/generic_describable_matcher.rb +19 -0
  32. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +19 -14
  33. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +9 -10
  34. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +9 -10
  35. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/object_having_attributes.rb +14 -7
  36. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/value_within.rb +10 -11
  37. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +4 -0
  38. data/lib/super_diff/rspec.rb +10 -9
  39. data/lib/super_diff/version.rb +1 -1
  40. data/lib/super_diff.rb +9 -0
  41. data/spec/examples.txt +543 -493
  42. data/spec/integration/rails/engines_spec.rb +8 -3
  43. data/spec/integration/rspec/contain_exactly_matcher_spec.rb +19 -19
  44. data/spec/integration/rspec/eq_matcher_spec.rb +111 -39
  45. data/spec/integration/rspec/generic_describable_matchers_spec.rb +177 -0
  46. data/spec/integration/rspec/have_attributes_matcher_spec.rb +25 -25
  47. data/spec/integration/rspec/include_matcher_spec.rb +23 -23
  48. data/spec/integration/rspec/magic_metadata_spec.rb +51 -0
  49. data/spec/integration/rspec/match_array_matcher_spec.rb +30 -30
  50. data/spec/integration/rspec/match_matcher_spec.rb +93 -93
  51. data/spec/integration/rspec/raise_error_matcher_spec.rb +813 -69
  52. data/spec/internal/log/test.log +0 -0
  53. data/spec/spec_helper.rb +3 -0
  54. data/spec/support/integration/helpers.rb +15 -10
  55. data/spec/support/integration/matchers.rb +34 -0
  56. data/spec/support/integration/test_programs/base.rb +6 -6
  57. data/spec/support/integration/test_programs/rspec_rails_engine.rb +3 -13
  58. data/spec/support/shared_examples/active_record.rb +33 -33
  59. data/spec/support/shared_examples/active_support.rb +125 -4
  60. data/spec/support/shared_examples/elided_diffs.rb +48 -48
  61. data/spec/support/shared_examples/hash_with_indifferent_access.rb +88 -88
  62. data/spec/support/shared_examples/key.rb +10 -10
  63. data/spec/unit/active_support/object_inspection_spec.rb +170 -0
  64. data/spec/unit/rspec/matchers/raise_error_spec.rb +43 -11
  65. data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +91 -0
  66. data/spec/unit/rspec/object_inspection_spec.rb +2 -2
  67. data/spec/unit/super_diff_spec.rb +64 -0
  68. metadata +17 -4
  69. data/lib/super_diff/errors/no_diff_formatter_available_error.rb +0 -21
  70. data/lib/super_diff/errors/no_operational_sequencer_available_error.rb +0 -22
@@ -6,18 +6,18 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
6
6
  it "produces the correct output" do
7
7
  as_both_colored_and_uncolored do |color_enabled|
8
8
  snippet = <<~TEST.strip
9
- expected = {
10
- line_1: "123 Main St.",
11
- city: "Hill Valley",
12
- state: "CA",
13
- zip: "90382",
14
- }
15
9
  actual = HashWithIndifferentAccess.new({
16
10
  line_1: "456 Ponderosa Ct.",
17
11
  city: "Oakland",
18
12
  state: "CA",
19
13
  zip: "91234",
20
14
  })
15
+ expected = {
16
+ line_1: "123 Main St.",
17
+ city: "Hill Valley",
18
+ state: "CA",
19
+ zip: "90382",
20
+ }
21
21
  expect(actual).to eq(expected)
22
22
  TEST
23
23
  program = make_program(snippet, color_enabled: color_enabled)
@@ -63,18 +63,18 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
63
63
  it "produces the correct output" do
64
64
  as_both_colored_and_uncolored do |color_enabled|
65
65
  snippet = <<~TEST.strip
66
- expected = {
67
- "line_1" => "123 Main St.",
68
- "city" => "Hill Valley",
69
- "state" => "CA",
70
- "zip" => "90382",
71
- }
72
66
  actual = HashWithIndifferentAccess.new({
73
67
  line_1: "456 Ponderosa Ct.",
74
68
  city: "Oakland",
75
69
  state: "CA",
76
70
  zip: "91234",
77
71
  })
72
+ expected = {
73
+ "line_1" => "123 Main St.",
74
+ "city" => "Hill Valley",
75
+ "state" => "CA",
76
+ "zip" => "90382",
77
+ }
78
78
  expect(actual).to eq(expected)
79
79
  TEST
80
80
  program = make_program(snippet, color_enabled: color_enabled)
@@ -124,18 +124,18 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
124
124
  it "produces the correct output" do
125
125
  as_both_colored_and_uncolored do |color_enabled|
126
126
  snippet = <<~TEST.strip
127
- expected = HashWithIndifferentAccess.new({
128
- line_1: "456 Ponderosa Ct.",
129
- city: "Oakland",
130
- state: "CA",
131
- zip: "91234",
132
- })
133
127
  actual = {
134
128
  line_1: "123 Main St.",
135
129
  city: "Hill Valley",
136
130
  state: "CA",
137
131
  zip: "90382",
138
132
  }
133
+ expected = HashWithIndifferentAccess.new({
134
+ line_1: "456 Ponderosa Ct.",
135
+ city: "Oakland",
136
+ state: "CA",
137
+ zip: "91234",
138
+ })
139
139
  expect(actual).to eq(expected)
140
140
  TEST
141
141
  program = make_program(snippet, color_enabled: color_enabled)
@@ -181,18 +181,18 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
181
181
  it "produces the correct output" do
182
182
  as_both_colored_and_uncolored do |color_enabled|
183
183
  snippet = <<~TEST.strip
184
- expected = HashWithIndifferentAccess.new({
185
- line_1: "456 Ponderosa Ct.",
186
- city: "Oakland",
187
- state: "CA",
188
- zip: "91234",
189
- })
190
184
  actual = {
191
185
  "line_1" => "123 Main St.",
192
186
  "city" => "Hill Valley",
193
187
  "state" => "CA",
194
188
  "zip" => "90382",
195
189
  }
190
+ expected = HashWithIndifferentAccess.new({
191
+ line_1: "456 Ponderosa Ct.",
192
+ city: "Oakland",
193
+ state: "CA",
194
+ zip: "91234",
195
+ })
196
196
  expect(actual).to eq(expected)
197
197
  TEST
198
198
  program = make_program(snippet, color_enabled: color_enabled)
@@ -240,16 +240,6 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
240
240
  it "produces the correct output" do
241
241
  as_both_colored_and_uncolored do |color_enabled|
242
242
  snippet = <<~TEST.strip
243
- expected = HashWithIndifferentAccess.new({
244
- shipments: [
245
- HashWithIndifferentAccess.new({
246
- estimated_delivery: HashWithIndifferentAccess.new({
247
- from: '2019-05-06',
248
- to: '2019-05-06'
249
- })
250
- })
251
- ]
252
- })
253
243
  actual = {
254
244
  shipments: [
255
245
  {
@@ -260,6 +250,16 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
260
250
  }
261
251
  ]
262
252
  }
253
+ expected = HashWithIndifferentAccess.new({
254
+ shipments: [
255
+ HashWithIndifferentAccess.new({
256
+ estimated_delivery: HashWithIndifferentAccess.new({
257
+ from: '2019-05-06',
258
+ to: '2019-05-06'
259
+ })
260
+ })
261
+ ]
262
+ })
263
263
  expect(actual).to eq(expected)
264
264
  TEST
265
265
  program = make_program(snippet, color_enabled: color_enabled)
@@ -307,16 +307,6 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
307
307
  it "produces the correct output" do
308
308
  as_both_colored_and_uncolored do |color_enabled|
309
309
  snippet = <<~TEST.strip
310
- expected = HashWithIndifferentAccess.new({
311
- shipments: [
312
- HashWithIndifferentAccess.new({
313
- estimated_delivery: HashWithIndifferentAccess.new({
314
- from: '2019-05-06',
315
- to: '2019-05-06'
316
- })
317
- })
318
- ]
319
- })
320
310
  actual = {
321
311
  'shipments' => [
322
312
  {
@@ -327,6 +317,16 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
327
317
  }
328
318
  ]
329
319
  }
320
+ expected = HashWithIndifferentAccess.new({
321
+ shipments: [
322
+ HashWithIndifferentAccess.new({
323
+ estimated_delivery: HashWithIndifferentAccess.new({
324
+ from: '2019-05-06',
325
+ to: '2019-05-06'
326
+ })
327
+ })
328
+ ]
329
+ })
330
330
  expect(actual).to eq(expected)
331
331
  TEST
332
332
  program = make_program(snippet, color_enabled: color_enabled)
@@ -380,18 +380,18 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
380
380
  it "produces the correct output" do
381
381
  as_both_colored_and_uncolored do |color_enabled|
382
382
  snippet = <<~TEST.strip
383
- expected = {
384
- line_1: "123 Main St.",
385
- city: "Hill Valley",
386
- state: "CA",
387
- zip: "90382",
388
- }
389
383
  actual = HashWithIndifferentAccess.new({
390
384
  line_1: "456 Ponderosa Ct.",
391
385
  city: "Oakland",
392
386
  state: "CA",
393
387
  zip: "91234",
394
388
  })
389
+ expected = {
390
+ line_1: "123 Main St.",
391
+ city: "Hill Valley",
392
+ state: "CA",
393
+ zip: "90382",
394
+ }
395
395
  expect(actual).to match(expected)
396
396
  TEST
397
397
  program = make_program(snippet, color_enabled: color_enabled)
@@ -437,18 +437,18 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
437
437
  it "produces the correct output" do
438
438
  as_both_colored_and_uncolored do |color_enabled|
439
439
  snippet = <<~TEST.strip
440
- expected = {
441
- "line_1" => "123 Main St.",
442
- "city" => "Hill Valley",
443
- "state" => "CA",
444
- "zip" => "90382",
445
- }
446
440
  actual = HashWithIndifferentAccess.new({
447
441
  line_1: "456 Ponderosa Ct.",
448
442
  city: "Oakland",
449
443
  state: "CA",
450
444
  zip: "91234",
451
445
  })
446
+ expected = {
447
+ "line_1" => "123 Main St.",
448
+ "city" => "Hill Valley",
449
+ "state" => "CA",
450
+ "zip" => "90382",
451
+ }
452
452
  expect(actual).to match(expected)
453
453
  TEST
454
454
  program = make_program(snippet, color_enabled: color_enabled)
@@ -498,18 +498,18 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
498
498
  it "produces the correct output" do
499
499
  as_both_colored_and_uncolored do |color_enabled|
500
500
  snippet = <<~TEST.strip
501
- expected = HashWithIndifferentAccess.new({
502
- line_1: "456 Ponderosa Ct.",
503
- city: "Oakland",
504
- state: "CA",
505
- zip: "91234",
506
- })
507
501
  actual = {
508
502
  line_1: "123 Main St.",
509
503
  city: "Hill Valley",
510
504
  state: "CA",
511
505
  zip: "90382",
512
506
  }
507
+ expected = HashWithIndifferentAccess.new({
508
+ line_1: "456 Ponderosa Ct.",
509
+ city: "Oakland",
510
+ state: "CA",
511
+ zip: "91234",
512
+ })
513
513
  expect(actual).to match(expected)
514
514
  TEST
515
515
  program = make_program(snippet, color_enabled: color_enabled)
@@ -555,18 +555,18 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
555
555
  it "produces the correct output" do
556
556
  as_both_colored_and_uncolored do |color_enabled|
557
557
  snippet = <<~TEST.strip
558
- expected = HashWithIndifferentAccess.new({
559
- line_1: "456 Ponderosa Ct.",
560
- city: "Oakland",
561
- state: "CA",
562
- zip: "91234",
563
- })
564
558
  actual = {
565
559
  "line_1" => "123 Main St.",
566
560
  "city" => "Hill Valley",
567
561
  "state" => "CA",
568
562
  "zip" => "90382",
569
563
  }
564
+ expected = HashWithIndifferentAccess.new({
565
+ line_1: "456 Ponderosa Ct.",
566
+ city: "Oakland",
567
+ state: "CA",
568
+ zip: "91234",
569
+ })
570
570
  expect(actual).to match(expected)
571
571
  TEST
572
572
  program = make_program(snippet, color_enabled: color_enabled)
@@ -614,16 +614,6 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
614
614
  it "produces the correct output" do
615
615
  as_both_colored_and_uncolored do |color_enabled|
616
616
  snippet = <<~TEST.strip
617
- expected = HashWithIndifferentAccess.new({
618
- shipments: [
619
- HashWithIndifferentAccess.new({
620
- estimated_delivery: HashWithIndifferentAccess.new({
621
- from: '2019-05-06',
622
- to: '2019-05-06'
623
- })
624
- })
625
- ]
626
- })
627
617
  actual = {
628
618
  shipments: [
629
619
  {
@@ -634,6 +624,16 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
634
624
  }
635
625
  ]
636
626
  }
627
+ expected = HashWithIndifferentAccess.new({
628
+ shipments: [
629
+ HashWithIndifferentAccess.new({
630
+ estimated_delivery: HashWithIndifferentAccess.new({
631
+ from: '2019-05-06',
632
+ to: '2019-05-06'
633
+ })
634
+ })
635
+ ]
636
+ })
637
637
  expect(actual).to match(expected)
638
638
  TEST
639
639
  program = make_program(snippet, color_enabled: color_enabled)
@@ -681,16 +681,6 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
681
681
  it "produces the correct output" do
682
682
  as_both_colored_and_uncolored do |color_enabled|
683
683
  snippet = <<~TEST.strip
684
- expected = HashWithIndifferentAccess.new({
685
- shipments: [
686
- HashWithIndifferentAccess.new({
687
- estimated_delivery: HashWithIndifferentAccess.new({
688
- from: '2019-05-06',
689
- to: '2019-05-06'
690
- })
691
- })
692
- ]
693
- })
694
684
  actual = {
695
685
  'shipments' => [
696
686
  {
@@ -701,6 +691,16 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
701
691
  }
702
692
  ]
703
693
  }
694
+ expected = HashWithIndifferentAccess.new({
695
+ shipments: [
696
+ HashWithIndifferentAccess.new({
697
+ estimated_delivery: HashWithIndifferentAccess.new({
698
+ from: '2019-05-06',
699
+ to: '2019-05-06'
700
+ })
701
+ })
702
+ ]
703
+ })
704
704
  expect(actual).to match(expected)
705
705
  TEST
706
706
  program = make_program(snippet, color_enabled: color_enabled)
@@ -3,15 +3,15 @@ shared_examples_for "a matcher that supports a toggleable key" do
3
3
  it "produces the key" do
4
4
  as_both_colored_and_uncolored do |color_enabled|
5
5
  snippet = <<~TEST.strip
6
- expected = [
6
+ actual = [
7
7
  "Afghanistan",
8
8
  "Aland Islands",
9
- "Albania"
9
+ "Australia"
10
10
  ]
11
- actual = [
11
+ expected = [
12
12
  "Afghanistan",
13
13
  "Aland Islands",
14
- "Australia"
14
+ "Albania"
15
15
  ]
16
16
  expect(actual).to #{matcher}(expected)
17
17
  TEST
@@ -19,7 +19,7 @@ shared_examples_for "a matcher that supports a toggleable key" do
19
19
  make_plain_test_program(
20
20
  snippet,
21
21
  color_enabled: color_enabled,
22
- configuration: {
22
+ super_diff_configuration: {
23
23
  key_enabled: true
24
24
  }
25
25
  )
@@ -64,15 +64,15 @@ shared_examples_for "a matcher that supports a toggleable key" do
64
64
  it "does not produce the key" do
65
65
  as_both_colored_and_uncolored do |color_enabled|
66
66
  snippet = <<~TEST.strip
67
- expected = [
67
+ actual = [
68
68
  "Afghanistan",
69
69
  "Aland Islands",
70
- "Albania"
70
+ "Australia"
71
71
  ]
72
- actual = [
72
+ expected = [
73
73
  "Afghanistan",
74
74
  "Aland Islands",
75
- "Australia"
75
+ "Albania"
76
76
  ]
77
77
  expect(actual).to #{matcher}(expected)
78
78
  TEST
@@ -80,7 +80,7 @@ shared_examples_for "a matcher that supports a toggleable key" do
80
80
  make_plain_test_program(
81
81
  snippet,
82
82
  color_enabled: color_enabled,
83
- configuration: {
83
+ super_diff_configuration: {
84
84
  key_enabled: false
85
85
  }
86
86
  )
@@ -0,0 +1,170 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe SuperDiff, type: :unit do
4
+ describe ".inspect_object",
5
+ "for ActiveSupport objects",
6
+ active_support: true do
7
+ context "given an ActiveSupport::OrderedOptions object" do
8
+ context "given as_lines: false" do
9
+ it "returns an inspected version of the object" do
10
+ string =
11
+ described_class.inspect_object(
12
+ ::ActiveSupport::OrderedOptions[name: "Bob", age: 42],
13
+ as_lines: false
14
+ )
15
+ expect(string).to eq(%(#<OrderedOptions { name: "Bob", age: 42 }>))
16
+ end
17
+ end
18
+
19
+ context "given as_lines: true" do
20
+ it "returns an inspected version of the object as multiple Lines" do
21
+ tiered_lines =
22
+ described_class.inspect_object(
23
+ ::ActiveSupport::OrderedOptions[name: "Bob", age: 42],
24
+ as_lines: true,
25
+ type: :delete,
26
+ indentation_level: 1
27
+ )
28
+ expect(tiered_lines).to match(
29
+ [
30
+ an_object_having_attributes(
31
+ type: :delete,
32
+ indentation_level: 1,
33
+ value: "#<OrderedOptions {",
34
+ collection_bookend: :open
35
+ ),
36
+ an_object_having_attributes(
37
+ type: :delete,
38
+ indentation_level: 2,
39
+ prefix: "name: ",
40
+ value: "\"Bob\"",
41
+ add_comma: true
42
+ ),
43
+ an_object_having_attributes(
44
+ type: :delete,
45
+ indentation_level: 2,
46
+ prefix: "age: ",
47
+ value: "42",
48
+ add_comma: false
49
+ ),
50
+ an_object_having_attributes(
51
+ type: :delete,
52
+ indentation_level: 1,
53
+ value: "}>",
54
+ collection_bookend: :close
55
+ )
56
+ ]
57
+ )
58
+ end
59
+ end
60
+ end
61
+
62
+ context "given a DateTime object" do
63
+ context "given as_lines: false" do
64
+ it "returns a representation of the datetime on a single line" do
65
+ inspection =
66
+ described_class.inspect_object(
67
+ DateTime.new(2021, 5, 5, 10, 23, 28.123456789123, "-05:00"),
68
+ as_lines: false
69
+ )
70
+ expect(inspection).to eq(
71
+ "#<DateTime 2021-05-05 10:23:28+(123456789/1000000000) -05:00 (-05:00)>"
72
+ )
73
+ end
74
+ end
75
+
76
+ context "given as_lines: true" do
77
+ it "returns a representation of the datetime across multiple lines" do
78
+ inspection =
79
+ described_class.inspect_object(
80
+ DateTime.new(2021, 5, 5, 10, 23, 28.1234567891, "-05:00"),
81
+ as_lines: true,
82
+ type: :delete,
83
+ indentation_level: 1
84
+ )
85
+ expect(inspection).to match(
86
+ [
87
+ an_object_having_attributes(
88
+ type: :delete,
89
+ indentation_level: 1,
90
+ value: "#<DateTime {",
91
+ add_comma: false,
92
+ collection_bookend: :open
93
+ ),
94
+ an_object_having_attributes(
95
+ type: :delete,
96
+ indentation_level: 2,
97
+ value: "year: 2021",
98
+ add_comma: true,
99
+ collection_bookend: nil
100
+ ),
101
+ an_object_having_attributes(
102
+ type: :delete,
103
+ indentation_level: 2,
104
+ value: "month: 5",
105
+ add_comma: true,
106
+ collection_bookend: nil
107
+ ),
108
+ an_object_having_attributes(
109
+ type: :delete,
110
+ indentation_level: 2,
111
+ value: "day: 5",
112
+ add_comma: true,
113
+ collection_bookend: nil
114
+ ),
115
+ an_object_having_attributes(
116
+ type: :delete,
117
+ indentation_level: 2,
118
+ value: "hour: 10",
119
+ add_comma: true,
120
+ collection_bookend: nil
121
+ ),
122
+ an_object_having_attributes(
123
+ type: :delete,
124
+ indentation_level: 2,
125
+ value: "min: 23",
126
+ add_comma: true,
127
+ collection_bookend: nil
128
+ ),
129
+ an_object_having_attributes(
130
+ type: :delete,
131
+ indentation_level: 2,
132
+ value: "sec: 28",
133
+ add_comma: true,
134
+ collection_bookend: nil
135
+ ),
136
+ an_object_having_attributes(
137
+ type: :delete,
138
+ indentation_level: 2,
139
+ value: "subsec: (123456789/1000000000)",
140
+ add_comma: true,
141
+ collection_bookend: nil
142
+ ),
143
+ an_object_having_attributes(
144
+ type: :delete,
145
+ indentation_level: 2,
146
+ value: "zone: \"-05:00\"",
147
+ add_comma: true,
148
+ collection_bookend: nil
149
+ ),
150
+ an_object_having_attributes(
151
+ type: :delete,
152
+ indentation_level: 2,
153
+ value: "utc_offset: -18000",
154
+ add_comma: false,
155
+ collection_bookend: nil
156
+ ),
157
+ an_object_having_attributes(
158
+ type: :delete,
159
+ indentation_level: 1,
160
+ value: "}>",
161
+ add_comma: false,
162
+ collection_bookend: :close
163
+ )
164
+ ]
165
+ )
166
+ end
167
+ end
168
+ end
169
+ end
170
+ end
@@ -5,39 +5,71 @@ RSpec.describe "RSpec's `raise_error` matcher" do
5
5
  context "given only an exception class" do
6
6
  it "returns the correct output" do
7
7
  expect(raise_error(RuntimeError).description).to eq(
8
- "raise error #<RuntimeError>"
8
+ "raise a kind of RuntimeError"
9
9
  )
10
10
  end
11
11
  end
12
12
 
13
- context "with only a message (and assuming a RuntimeError)" do
13
+ context "given only a string message" do
14
14
  it "returns the correct output" do
15
15
  expect(raise_error("hell").description).to eq(
16
- %|raise error #<Exception "hell">|
16
+ %|raise a kind of Exception with message "hell"|
17
17
  )
18
18
  end
19
19
  end
20
20
 
21
- context "with regular expression as message (and assuming a RuntimeError)" do
21
+ context "given only a regexp message" do
22
22
  it "returns the correct output" do
23
- expect(raise_error(/hell/).description).to eq(
24
- "raise error #<Exception /hell/>"
23
+ expect(raise_error(/hell/i).description).to eq(
24
+ "raise a kind of Exception with message matching /hell/i"
25
25
  )
26
26
  end
27
27
  end
28
28
 
29
- context "with both an exception and a message" do
29
+ context "given both an exception and string message" do
30
30
  it "returns the correct output" do
31
31
  expect(raise_error(RuntimeError, "hell").description).to eq(
32
- %|raise error #<RuntimeError "hell">|
32
+ %|raise a kind of RuntimeError with message "hell"|
33
33
  )
34
34
  end
35
35
  end
36
36
 
37
- context "with an exception and a regular expression as message" do
37
+ context "given both an exception and regexp message" do
38
38
  it "returns the correct output" do
39
- expect(raise_error(RuntimeError, /hell/).description).to eq(
40
- "raise error #<RuntimeError /hell/>"
39
+ expect(raise_error(RuntimeError, /hell/i).description).to eq(
40
+ "raise a kind of RuntimeError with message matching /hell/i"
41
+ )
42
+ end
43
+ end
44
+
45
+ context "given a simple RSpec matcher" do
46
+ it "returns the correct output" do
47
+ expect(raise_error(a_kind_of(RuntimeError)).description).to eq(
48
+ "raise #<a kind of RuntimeError>"
49
+ )
50
+ end
51
+ end
52
+
53
+ context "given a simple RSpec matcher and string message" do
54
+ it "returns the correct output" do
55
+ expect(raise_error(a_kind_of(RuntimeError), "boo").description).to eq(
56
+ 'raise #<a kind of RuntimeError> with message "boo"'
57
+ )
58
+ end
59
+ end
60
+
61
+ context "given a simple RSpec matcher and regexp message" do
62
+ it "returns the correct output" do
63
+ expect(raise_error(a_kind_of(RuntimeError), /boo/i).description).to eq(
64
+ "raise #<a kind of RuntimeError> with message matching /boo/i"
65
+ )
66
+ end
67
+ end
68
+
69
+ context "given a compound RSpec matcher" do
70
+ it "returns the correct output" do
71
+ expect(raise_error(a_kind_of(Array).or eq(true)).description).to eq(
72
+ "raise #<a kind of Array or eq true>"
41
73
  )
42
74
  end
43
75
  end