super_diff 0.9.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +65 -26
  3. data/lib/super_diff/active_record/differs/active_record_relation.rb +1 -2
  4. data/lib/super_diff/active_record/differs.rb +1 -1
  5. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +22 -18
  6. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +14 -7
  7. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +2 -2
  8. data/lib/super_diff/active_record/object_inspection.rb +1 -1
  9. data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +1 -2
  10. data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +1 -2
  11. data/lib/super_diff/active_record/operation_tree_builders.rb +2 -2
  12. data/lib/super_diff/active_record/operation_tree_flatteners.rb +1 -1
  13. data/lib/super_diff/active_record/operation_trees.rb +1 -1
  14. data/lib/super_diff/active_record.rb +7 -15
  15. data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +5 -6
  16. data/lib/super_diff/active_support/differs.rb +1 -1
  17. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +20 -11
  18. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/ordered_options.rb +46 -0
  19. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +5 -1
  20. data/lib/super_diff/active_support/object_inspection.rb +1 -1
  21. data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +5 -6
  22. data/lib/super_diff/active_support/operation_tree_builders.rb +1 -1
  23. data/lib/super_diff/active_support/operation_tree_flatteners.rb +1 -1
  24. data/lib/super_diff/active_support/operation_trees.rb +1 -1
  25. data/lib/super_diff/active_support.rb +6 -10
  26. data/lib/super_diff/colorized_document_extensions.rb +2 -4
  27. data/lib/super_diff/configuration.rb +14 -8
  28. data/lib/super_diff/csi/color.rb +4 -4
  29. data/lib/super_diff/csi/colorized_document.rb +12 -16
  30. data/lib/super_diff/csi/document.rb +8 -19
  31. data/lib/super_diff/csi/eight_bit_color.rb +19 -19
  32. data/lib/super_diff/csi/four_bit_color.rb +82 -31
  33. data/lib/super_diff/csi/twenty_four_bit_color.rb +12 -11
  34. data/lib/super_diff/csi/uncolorized_document.rb +2 -6
  35. data/lib/super_diff/csi.rb +10 -14
  36. data/lib/super_diff/diff_formatters/collection.rb +35 -41
  37. data/lib/super_diff/differs/date_like.rb +15 -0
  38. data/lib/super_diff/differs/default_object.rb +1 -1
  39. data/lib/super_diff/differs/defaults.rb +2 -1
  40. data/lib/super_diff/differs/main.rb +2 -13
  41. data/lib/super_diff/differs.rb +1 -0
  42. data/lib/super_diff/equality_matchers/array.rb +10 -12
  43. data/lib/super_diff/equality_matchers/base.rb +1 -1
  44. data/lib/super_diff/equality_matchers/default.rb +2 -4
  45. data/lib/super_diff/equality_matchers/defaults.rb +1 -1
  46. data/lib/super_diff/equality_matchers/hash.rb +10 -12
  47. data/lib/super_diff/equality_matchers/multiline_string.rb +11 -13
  48. data/lib/super_diff/equality_matchers/primitive.rb +10 -12
  49. data/lib/super_diff/equality_matchers/singleline_string.rb +10 -12
  50. data/lib/super_diff/equality_matchers.rb +1 -1
  51. data/lib/super_diff/errors.rb +2 -6
  52. data/lib/super_diff/gem_version.rb +3 -3
  53. data/lib/super_diff/helpers.rb +10 -10
  54. data/lib/super_diff/implementation_checks.rb +2 -2
  55. data/lib/super_diff/line.rb +3 -3
  56. data/lib/super_diff/object_inspection/inspection_tree.rb +64 -73
  57. data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +29 -14
  58. data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +17 -13
  59. data/lib/super_diff/object_inspection/inspection_tree_builders/date_like.rb +51 -0
  60. data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +43 -27
  61. data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +2 -1
  62. data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +35 -18
  63. data/lib/super_diff/object_inspection/inspection_tree_builders/primitive.rb +3 -5
  64. data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +30 -36
  65. data/lib/super_diff/object_inspection/inspection_tree_builders.rb +13 -9
  66. data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +11 -22
  67. data/lib/super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines.rb +1 -5
  68. data/lib/super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines.rb +1 -5
  69. data/lib/super_diff/object_inspection/nodes/as_single_line.rb +3 -7
  70. data/lib/super_diff/object_inspection/nodes/base.rb +9 -14
  71. data/lib/super_diff/object_inspection/nodes/inspection.rb +26 -34
  72. data/lib/super_diff/object_inspection/nodes/nesting.rb +1 -1
  73. data/lib/super_diff/object_inspection/nodes/only_when.rb +2 -6
  74. data/lib/super_diff/object_inspection/nodes/text.rb +1 -5
  75. data/lib/super_diff/object_inspection/nodes/when_empty.rb +2 -6
  76. data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +2 -6
  77. data/lib/super_diff/object_inspection/nodes/when_rendering_to_lines.rb +1 -1
  78. data/lib/super_diff/object_inspection/nodes/when_rendering_to_string.rb +1 -5
  79. data/lib/super_diff/object_inspection/nodes.rb +7 -7
  80. data/lib/super_diff/object_inspection.rb +3 -3
  81. data/lib/super_diff/operation_tree_builders/array.rb +12 -11
  82. data/lib/super_diff/operation_tree_builders/base.rb +17 -15
  83. data/lib/super_diff/operation_tree_builders/custom_object.rb +8 -6
  84. data/lib/super_diff/operation_tree_builders/date_like.rb +15 -0
  85. data/lib/super_diff/operation_tree_builders/default_object.rb +29 -21
  86. data/lib/super_diff/operation_tree_builders/defaults.rb +1 -1
  87. data/lib/super_diff/operation_tree_builders/hash.rb +23 -24
  88. data/lib/super_diff/operation_tree_builders/main.rb +4 -11
  89. data/lib/super_diff/operation_tree_builders/multiline_string.rb +3 -3
  90. data/lib/super_diff/operation_tree_builders/time_like.rb +1 -11
  91. data/lib/super_diff/operation_tree_builders.rb +2 -1
  92. data/lib/super_diff/operation_tree_flatteners/base.rb +1 -5
  93. data/lib/super_diff/operation_tree_flatteners/collection.rb +13 -16
  94. data/lib/super_diff/operation_tree_flatteners/default_object.rb +1 -2
  95. data/lib/super_diff/operation_tree_flatteners/hash.rb +2 -10
  96. data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +2 -1
  97. data/lib/super_diff/operation_tree_flatteners.rb +3 -3
  98. data/lib/super_diff/operation_trees/base.rb +3 -5
  99. data/lib/super_diff/operation_trees/default_object.rb +1 -3
  100. data/lib/super_diff/operations/binary_operation.rb +2 -2
  101. data/lib/super_diff/operations/unary_operation.rb +1 -1
  102. data/lib/super_diff/rails.rb +2 -1
  103. data/lib/super_diff/recursion_guard.rb +5 -4
  104. data/lib/super_diff/rspec/augmented_matcher.rb +4 -5
  105. data/lib/super_diff/rspec/differ.rb +6 -13
  106. data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +3 -2
  107. data/lib/super_diff/rspec/differs/collection_including.rb +1 -1
  108. data/lib/super_diff/rspec/differs/hash_including.rb +1 -1
  109. data/lib/super_diff/rspec/differs.rb +3 -3
  110. data/lib/super_diff/rspec/matcher_text_builders/base.rb +13 -15
  111. data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +5 -7
  112. data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +3 -5
  113. data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +2 -10
  114. data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +2 -6
  115. data/lib/super_diff/rspec/matcher_text_builders.rb +5 -8
  116. data/lib/super_diff/rspec/matcher_text_template.rb +13 -16
  117. data/lib/super_diff/rspec/monkey_patches.rb +180 -123
  118. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_containing_exactly.rb +14 -7
  119. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +21 -13
  120. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +35 -36
  121. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/generic_describable_matcher.rb +19 -0
  122. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +21 -15
  123. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +11 -10
  124. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +11 -10
  125. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/object_having_attributes.rb +14 -7
  126. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/value_within.rb +10 -11
  127. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +13 -9
  128. data/lib/super_diff/rspec/object_inspection.rb +1 -1
  129. data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +11 -10
  130. data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +7 -6
  131. data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +11 -10
  132. data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +22 -17
  133. data/lib/super_diff/rspec/operation_tree_builders.rb +4 -4
  134. data/lib/super_diff/rspec.rb +17 -18
  135. data/lib/super_diff/tiered_lines_elider.rb +87 -115
  136. data/lib/super_diff/tiered_lines_formatter.rb +5 -9
  137. data/lib/super_diff/version.rb +1 -1
  138. data/lib/super_diff.rb +13 -9
  139. data/spec/examples.txt +541 -483
  140. data/spec/integration/rails/active_record_spec.rb +3 -1
  141. data/spec/integration/rails/engines_spec.rb +25 -0
  142. data/spec/integration/rails/hash_with_indifferent_access_spec.rb +3 -1
  143. data/spec/integration/rspec/be_falsey_matcher_spec.rb +40 -35
  144. data/spec/integration/rspec/be_matcher_spec.rb +360 -320
  145. data/spec/integration/rspec/be_nil_matcher_spec.rb +38 -34
  146. data/spec/integration/rspec/be_predicate_matcher_spec.rb +376 -359
  147. data/spec/integration/rspec/be_truthy_matcher_spec.rb +38 -33
  148. data/spec/integration/rspec/contain_exactly_matcher_spec.rb +257 -254
  149. data/spec/integration/rspec/eq_matcher_spec.rb +695 -585
  150. data/spec/integration/rspec/generic_describable_matchers_spec.rb +177 -0
  151. data/spec/integration/rspec/have_attributes_matcher_spec.rb +312 -304
  152. data/spec/integration/rspec/have_predicate_matcher_spec.rb +291 -297
  153. data/spec/integration/rspec/include_matcher_spec.rb +327 -225
  154. data/spec/integration/rspec/magic_metadata_spec.rb +51 -0
  155. data/spec/integration/rspec/match_array_matcher_spec.rb +294 -291
  156. data/spec/integration/rspec/match_matcher_spec.rb +916 -903
  157. data/spec/integration/rspec/raise_error_matcher_spec.rb +1208 -449
  158. data/spec/integration/rspec/respond_to_matcher_spec.rb +702 -697
  159. data/spec/integration/rspec/third_party_matcher_spec.rb +142 -138
  160. data/spec/integration/rspec/unhandled_errors_spec.rb +88 -84
  161. data/spec/internal/log/test.log +0 -0
  162. data/spec/spec_helper.rb +20 -20
  163. data/spec/support/command_runner.rb +34 -57
  164. data/spec/support/integration/helpers.rb +44 -32
  165. data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +28 -23
  166. data/spec/support/integration/matchers.rb +34 -0
  167. data/spec/support/integration/test_programs/base.rb +17 -22
  168. data/spec/support/integration/test_programs/plain.rb +6 -0
  169. data/spec/support/integration/test_programs/rspec_active_record.rb +4 -1
  170. data/spec/support/integration/test_programs/rspec_active_support.rb +4 -1
  171. data/spec/support/integration/test_programs/rspec_rails.rb +4 -1
  172. data/spec/support/integration/test_programs/rspec_rails_engine.rb +20 -0
  173. data/spec/support/models/active_record/person.rb +6 -4
  174. data/spec/support/models/active_record/shipping_address.rb +9 -10
  175. data/spec/support/models/customer.rb +2 -4
  176. data/spec/support/models/player.rb +3 -6
  177. data/spec/support/models/shipping_address.rb +4 -13
  178. data/spec/support/shared_examples/active_record.rb +258 -240
  179. data/spec/support/shared_examples/active_support.rb +174 -51
  180. data/spec/support/shared_examples/elided_diffs.rb +447 -423
  181. data/spec/support/shared_examples/hash_with_indifferent_access.rb +500 -464
  182. data/spec/support/shared_examples/key.rb +123 -0
  183. data/spec/support/unit/helpers.rb +1 -3
  184. data/spec/support/unit/matchers/match_output.rb +12 -13
  185. data/spec/unit/active_record/object_inspection_spec.rb +222 -206
  186. data/spec/unit/active_support/object_inspection_spec.rb +170 -0
  187. data/spec/unit/equality_matchers/main_spec.rb +1049 -984
  188. data/spec/unit/helpers_spec.rb +14 -21
  189. data/spec/unit/operation_tree_flatteners/array_spec.rb +557 -524
  190. data/spec/unit/operation_tree_flatteners/custom_object_spec.rb +619 -601
  191. data/spec/unit/operation_tree_flatteners/default_object_spec.rb +619 -621
  192. data/spec/unit/operation_tree_flatteners/hash_spec.rb +595 -556
  193. data/spec/unit/operation_tree_flatteners/multiline_string_spec.rb +102 -92
  194. data/spec/unit/rspec/matchers/be_compared_to_spec.rb +3 -3
  195. data/spec/unit/rspec/matchers/be_predicate_spec.rb +3 -3
  196. data/spec/unit/rspec/matchers/contain_exactly_spec.rb +1 -1
  197. data/spec/unit/rspec/matchers/have_attributes_spec.rb +1 -1
  198. data/spec/unit/rspec/matchers/have_predicate_spec.rb +2 -2
  199. data/spec/unit/rspec/matchers/include_spec.rb +2 -2
  200. data/spec/unit/rspec/matchers/match_array_spec.rb +2 -2
  201. data/spec/unit/rspec/matchers/raise_error_spec.rb +43 -11
  202. data/spec/unit/rspec/matchers/respond_to_spec.rb +23 -16
  203. data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +91 -0
  204. data/spec/unit/rspec/object_inspection_spec.rb +351 -326
  205. data/spec/unit/super_diff_spec.rb +1594 -1437
  206. data/spec/unit/tiered_lines_elider_spec.rb +3508 -3536
  207. data/spec/unit/tiered_lines_formatter_spec.rb +54 -116
  208. data/super_diff.gemspec +13 -12
  209. metadata +88 -75
  210. data/lib/super_diff/errors/no_diff_formatter_available_error.rb +0 -21
  211. data/lib/super_diff/errors/no_operational_sequencer_available_error.rb +0 -22
  212. data/spec/tmp/warnings_logger/all_warnings.txt +0 -2
@@ -26,11 +26,11 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
26
26
  Differing numbers.
27
27
 
28
28
  #{
29
- colored do
30
- expected_line %(Expected: 42)
31
- actual_line %( Actual: 1)
32
- end
33
- }
29
+ colored do
30
+ expected_line "Expected: 42"
31
+ actual_line " Actual: 1"
32
+ end
33
+ }
34
34
  STR
35
35
 
36
36
  expect(actual_output).to match_output(expected_output)
@@ -53,11 +53,11 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
53
53
  Differing symbols.
54
54
 
55
55
  #{
56
- colored do
57
- expected_line %(Expected: :foo)
58
- actual_line %( Actual: :bar)
59
- end
60
- }
56
+ colored do
57
+ expected_line "Expected: :foo"
58
+ actual_line " Actual: :bar"
59
+ end
60
+ }
61
61
  STR
62
62
 
63
63
  expect(actual_output).to match_output(expected_output)
@@ -74,20 +74,18 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
74
74
 
75
75
  context "given completely different single-line strings" do
76
76
  it "returns a message along with the diff" do
77
- actual_output = described_class.call(
78
- expected: "Marty",
79
- actual: "Jennifer",
80
- )
77
+ actual_output =
78
+ described_class.call(expected: "Marty", actual: "Jennifer")
81
79
 
82
80
  expected_output = <<~STR.strip
83
81
  Differing strings.
84
82
 
85
83
  #{
86
- colored do
87
- expected_line %(Expected: "Marty")
88
- actual_line %( Actual: "Jennifer")
89
- end
90
- }
84
+ colored do
85
+ expected_line %(Expected: "Marty")
86
+ actual_line %( Actual: "Jennifer")
87
+ end
88
+ }
91
89
  STR
92
90
 
93
91
  expect(actual_output).to match_output(expected_output)
@@ -96,20 +94,18 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
96
94
 
97
95
  context "given closely different single-line strings" do
98
96
  it "returns a message along with the diff" do
99
- actual_output = described_class.call(
100
- expected: "Marty",
101
- actual: "Marty McFly",
102
- )
97
+ actual_output =
98
+ described_class.call(expected: "Marty", actual: "Marty McFly")
103
99
 
104
100
  expected_output = <<~STR.strip
105
101
  Differing strings.
106
102
 
107
103
  #{
108
- colored do
109
- expected_line %(Expected: "Marty")
110
- actual_line %( Actual: "Marty McFly")
111
- end
112
- }
104
+ colored do
105
+ expected_line %(Expected: "Marty")
106
+ actual_line %( Actual: "Marty McFly")
107
+ end
108
+ }
113
109
  STR
114
110
 
115
111
  expect(actual_output).to match_output(expected_output)
@@ -118,20 +114,21 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
118
114
 
119
115
  context "given a single-line string and a multi-line string" do
120
116
  it "returns a message along with the diff" do
121
- actual_output = described_class.call(
122
- expected: "Something entirely different",
123
- actual: "This is a line\nAnd that's another line\n",
124
- )
117
+ actual_output =
118
+ described_class.call(
119
+ expected: "Something entirely different",
120
+ actual: "This is a line\nAnd that's another line\n"
121
+ )
125
122
 
126
123
  expected_output = <<~STR.strip
127
124
  Differing strings.
128
125
 
129
126
  #{
130
- colored do
131
- expected_line %(Expected: "Something entirely different")
132
- actual_line %( Actual: "This is a line\\nAnd that's another line\\n")
133
- end
134
- }
127
+ colored do
128
+ expected_line %(Expected: "Something entirely different")
129
+ actual_line %( Actual: "This is a line\\nAnd that's another line\\n")
130
+ end
131
+ }
135
132
  STR
136
133
 
137
134
  expect(actual_output).to match_output(expected_output)
@@ -140,20 +137,21 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
140
137
 
141
138
  context "given a multi-line string and a single-line string" do
142
139
  it "returns a message along with the diff" do
143
- actual_output = described_class.call(
144
- expected: "This is a line\nAnd that's another line\n",
145
- actual: "Something entirely different",
146
- )
140
+ actual_output =
141
+ described_class.call(
142
+ expected: "This is a line\nAnd that's another line\n",
143
+ actual: "Something entirely different"
144
+ )
147
145
 
148
146
  expected_output = <<~STR.strip
149
147
  Differing strings.
150
148
 
151
149
  #{
152
- colored do
153
- expected_line %(Expected: "This is a line\\nAnd that's another line\\n")
154
- actual_line %( Actual: "Something entirely different")
155
- end
156
- }
150
+ colored do
151
+ expected_line %(Expected: "This is a line\\nAnd that's another line\\n")
152
+ actual_line %( Actual: "Something entirely different")
153
+ end
154
+ }
157
155
  STR
158
156
 
159
157
  expect(actual_output).to match_output(expected_output)
@@ -162,31 +160,34 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
162
160
 
163
161
  context "given closely different multi-line strings" do
164
162
  it "returns a message along with the diff" do
165
- actual_output = described_class.call(
166
- expected: "This is a line\nAnd that's a line\nAnd there's a line too",
167
- actual: "This is a line\nSomething completely different\nAnd there's a line too",
168
- )
163
+ actual_output =
164
+ described_class.call(
165
+ expected:
166
+ "This is a line\nAnd that's a line\nAnd there's a line too",
167
+ actual:
168
+ "This is a line\nSomething completely different\nAnd there's a line too"
169
+ )
169
170
 
170
171
  expected_output = <<~STR.strip
171
172
  Differing strings.
172
173
 
173
174
  #{
174
- colored do
175
- expected_line %(Expected: "This is a line\\nAnd that's a line\\nAnd there's a line too")
176
- actual_line %( Actual: "This is a line\\nSomething completely different\\nAnd there's a line too")
177
- end
178
- }
175
+ colored do
176
+ expected_line %(Expected: "This is a line\\nAnd that's a line\\nAnd there's a line too")
177
+ actual_line %( Actual: "This is a line\\nSomething completely different\\nAnd there's a line too")
178
+ end
179
+ }
179
180
 
180
181
  Diff:
181
182
 
182
183
  #{
183
- colored do
184
- plain_line %( This is a line\\n)
185
- expected_line %(- And that's a line\\n)
186
- actual_line %(+ Something completely different\\n)
187
- plain_line %( And there's a line too)
188
- end
189
- }
184
+ colored do
185
+ plain_line %( This is a line\\n)
186
+ expected_line %(- And that's a line\\n)
187
+ actual_line %(+ Something completely different\\n)
188
+ plain_line " And there's a line too"
189
+ end
190
+ }
190
191
  STR
191
192
 
192
193
  expect(actual_output).to match_output(expected_output)
@@ -195,31 +196,32 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
195
196
 
196
197
  context "given completely different multi-line strings" do
197
198
  it "returns a message along with the diff" do
198
- actual_output = described_class.call(
199
- expected: "This is a line\nAnd that's a line\n",
200
- actual: "Something completely different\nAnd something else too\n",
201
- )
199
+ actual_output =
200
+ described_class.call(
201
+ expected: "This is a line\nAnd that's a line\n",
202
+ actual: "Something completely different\nAnd something else too\n"
203
+ )
202
204
 
203
205
  expected_output = <<~STR.strip
204
206
  Differing strings.
205
207
 
206
208
  #{
207
- colored do
208
- expected_line %(Expected: "This is a line\\nAnd that's a line\\n")
209
- actual_line %( Actual: "Something completely different\\nAnd something else too\\n")
210
- end
211
- }
209
+ colored do
210
+ expected_line %(Expected: "This is a line\\nAnd that's a line\\n")
211
+ actual_line %( Actual: "Something completely different\\nAnd something else too\\n")
212
+ end
213
+ }
212
214
 
213
215
  Diff:
214
216
 
215
217
  #{
216
- colored do
217
- expected_line %(- This is a line\\n)
218
- expected_line %(- And that's a line\\n)
219
- actual_line %(+ Something completely different\\n)
220
- actual_line %(+ And something else too\\n)
221
- end
222
- }
218
+ colored do
219
+ expected_line %(- This is a line\\n)
220
+ expected_line %(- And that's a line\\n)
221
+ actual_line %(+ Something completely different\\n)
222
+ actual_line %(+ And something else too\\n)
223
+ end
224
+ }
223
225
  STR
224
226
 
225
227
  expect(actual_output).to match_output(expected_output)
@@ -234,58 +236,55 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
234
236
  red: 3,
235
237
  green: 8,
236
238
  blue: 4,
237
- layer: :foreground,
239
+ layer: :foreground
238
240
  ),
239
241
  SuperDiff::Csi::TwentyFourBitColor.new(
240
242
  red: 47,
241
243
  green: 164,
242
244
  blue: 59,
243
- layer: :foreground,
244
- ),
245
+ layer: :foreground
246
+ )
245
247
  ]
246
248
 
247
249
  expected =
248
250
  colored("This is a line", colors[0]) + "\n" +
249
- colored("And that's a line", colors[1]) + "\n" +
250
- colored("And there's a line too", colors[2]) + "\n"
251
+ colored("And that's a line", colors[1]) + "\n" +
252
+ colored("And there's a line too", colors[2]) + "\n"
251
253
 
252
254
  actual =
253
- colored("This is a line", colors[0]) + "\n" +
254
- colored("Something completely different", colors[1]) + "\n" +
255
- colored("And there's a line too", colors[2]) + "\n"
255
+ colored("This is a line", colors[0]) + "\n" +
256
+ colored("Something completely different", colors[1]) + "\n" +
257
+ colored("And there's a line too", colors[2]) + "\n"
256
258
 
257
- actual_output = described_class.call(
258
- expected: expected,
259
- actual: actual,
260
- )
259
+ actual_output = described_class.call(expected: expected, actual: actual)
261
260
 
262
261
  expected_output = <<~STR.strip
263
262
  Differing strings.
264
263
 
265
264
  #{
266
- colored do
267
- expected_line do
268
- text "Expected: "
269
- text %("\\e[34mThis is a line\\e[0m\\n\\e[38;5;176mAnd that's a line\\e[0m\\n\\e[38;2;47;59;164mAnd there's a line too\\e[0m\\n")
270
- end
271
-
272
- actual_line do
273
- text " Actual: "
274
- text %("\\e[34mThis is a line\\e[0m\\n\\e[38;5;176mSomething completely different\\e[0m\\n\\e[38;2;47;59;164mAnd there's a line too\\e[0m\\n")
275
- end
265
+ colored do
266
+ expected_line do
267
+ text "Expected: "
268
+ text %("\\e[34mThis is a line\\e[0m\\n\\e[38;5;176mAnd that's a line\\e[0m\\n\\e[38;2;47;59;164mAnd there's a line too\\e[0m\\n")
276
269
  end
277
- }
270
+
271
+ actual_line do
272
+ text " Actual: "
273
+ text %("\\e[34mThis is a line\\e[0m\\n\\e[38;5;176mSomething completely different\\e[0m\\n\\e[38;2;47;59;164mAnd there's a line too\\e[0m\\n")
274
+ end
275
+ end
276
+ }
278
277
 
279
278
  Diff:
280
279
 
281
280
  #{
282
- colored do
283
- plain_line %( \\e[34mThis is a line\\e[0m\\n)
284
- expected_line %(- \\e[38;5;176mAnd that's a line\\e[0m\\n)
285
- actual_line %(+ \\e[38;5;176mSomething completely different\\e[0m\\n)
286
- plain_line %( \\e[38;2;47;59;164mAnd there's a line too\\e[0m\\n)
287
- end
288
- }
281
+ colored do
282
+ plain_line %( \\e[34mThis is a line\\e[0m\\n)
283
+ expected_line %(- \\e[38;5;176mAnd that's a line\\e[0m\\n)
284
+ actual_line %(+ \\e[38;5;176mSomething completely different\\e[0m\\n)
285
+ plain_line %( \\e[38;2;47;59;164mAnd there's a line too\\e[0m\\n)
286
+ end
287
+ }
289
288
  STR
290
289
 
291
290
  expect(actual_output).to match_output(expected_output)
@@ -294,10 +293,11 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
294
293
 
295
294
  context "given the same array" do
296
295
  it "returns an empty string" do
297
- output = described_class.call(
298
- expected: ["sausage", "egg", "cheese"],
299
- actual: ["sausage", "egg", "cheese"],
300
- )
296
+ output =
297
+ described_class.call(
298
+ expected: %w[sausage egg cheese],
299
+ actual: %w[sausage egg cheese]
300
+ )
301
301
 
302
302
  expect(output).to eq("")
303
303
  end
@@ -305,34 +305,32 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
305
305
 
306
306
  context "given two equal-length, one-dimensional arrays with differing numbers" do
307
307
  it "returns a message along with the diff" do
308
- actual_output = described_class.call(
309
- expected: [1, 2, 3, 4],
310
- actual: [1, 2, 99, 4],
311
- )
308
+ actual_output =
309
+ described_class.call(expected: [1, 2, 3, 4], actual: [1, 2, 99, 4])
312
310
 
313
311
  expected_output = <<~STR.strip
314
312
  Differing arrays.
315
313
 
316
314
  #{
317
- colored do
318
- expected_line %(Expected: [1, 2, 3, 4])
319
- actual_line %( Actual: [1, 2, 99, 4])
320
- end
321
- }
315
+ colored do
316
+ expected_line "Expected: [1, 2, 3, 4]"
317
+ actual_line " Actual: [1, 2, 99, 4]"
318
+ end
319
+ }
322
320
 
323
321
  Diff:
324
322
 
325
323
  #{
326
- colored do
327
- plain_line %( [)
328
- plain_line %( 1,)
329
- plain_line %( 2,)
330
- expected_line %(- 3,)
331
- actual_line %(+ 99,)
332
- plain_line %( 4)
333
- plain_line %( ])
334
- end
335
- }
324
+ colored do
325
+ plain_line " ["
326
+ plain_line " 1,"
327
+ plain_line " 2,"
328
+ expected_line "- 3,"
329
+ actual_line "+ 99,"
330
+ plain_line " 4"
331
+ plain_line " ]"
332
+ end
333
+ }
336
334
  STR
337
335
 
338
336
  expect(actual_output).to match_output(expected_output)
@@ -341,34 +339,35 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
341
339
 
342
340
  context "given two equal-length, one-dimensional arrays with differing symbols" do
343
341
  it "returns a message along with the diff" do
344
- actual_output = described_class.call(
345
- expected: [:one, :fish, :two, :fish],
346
- actual: [:one, :FISH, :two, :fish],
347
- )
342
+ actual_output =
343
+ described_class.call(
344
+ expected: %i[one fish two fish],
345
+ actual: %i[one FISH two fish]
346
+ )
348
347
 
349
348
  expected_output = <<~STR.strip
350
349
  Differing arrays.
351
350
 
352
351
  #{
353
- colored do
354
- expected_line %(Expected: [:one, :fish, :two, :fish])
355
- actual_line %( Actual: [:one, :FISH, :two, :fish])
356
- end
357
- }
352
+ colored do
353
+ expected_line "Expected: [:one, :fish, :two, :fish]"
354
+ actual_line " Actual: [:one, :FISH, :two, :fish]"
355
+ end
356
+ }
358
357
 
359
358
  Diff:
360
359
 
361
360
  #{
362
- colored do
363
- plain_line %( [)
364
- plain_line %( :one,)
365
- expected_line %(- :fish,)
366
- actual_line %(+ :FISH,)
367
- plain_line %( :two,)
368
- plain_line %( :fish)
369
- plain_line %( ])
370
- end
371
- }
361
+ colored do
362
+ plain_line " ["
363
+ plain_line " :one,"
364
+ expected_line "- :fish,"
365
+ actual_line "+ :FISH,"
366
+ plain_line " :two,"
367
+ plain_line " :fish"
368
+ plain_line " ]"
369
+ end
370
+ }
372
371
  STR
373
372
 
374
373
  expect(actual_output).to match_output(expected_output)
@@ -377,33 +376,34 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
377
376
 
378
377
  context "given two equal-length, one-dimensional arrays with differing strings" do
379
378
  it "returns a message along with the diff" do
380
- actual_output = described_class.call(
381
- expected: ["sausage", "egg", "cheese"],
382
- actual: ["bacon", "egg", "cheese"],
383
- )
379
+ actual_output =
380
+ described_class.call(
381
+ expected: %w[sausage egg cheese],
382
+ actual: %w[bacon egg cheese]
383
+ )
384
384
 
385
385
  expected_output = <<~STR.strip
386
386
  Differing arrays.
387
387
 
388
388
  #{
389
- colored do
390
- expected_line %(Expected: ["sausage", "egg", "cheese"])
391
- actual_line %( Actual: ["bacon", "egg", "cheese"])
392
- end
393
- }
389
+ colored do
390
+ expected_line %(Expected: ["sausage", "egg", "cheese"])
391
+ actual_line %( Actual: ["bacon", "egg", "cheese"])
392
+ end
393
+ }
394
394
 
395
395
  Diff:
396
396
 
397
397
  #{
398
- colored do
399
- plain_line %( [)
400
- expected_line %(- "sausage",)
401
- actual_line %(+ "bacon",)
402
- plain_line %( "egg",)
403
- plain_line %( "cheese")
404
- plain_line %( ])
405
- end
406
- }
398
+ colored do
399
+ plain_line " ["
400
+ expected_line %(- "sausage",)
401
+ actual_line %(+ "bacon",)
402
+ plain_line %( "egg",)
403
+ plain_line %( "cheese")
404
+ plain_line " ]"
405
+ end
406
+ }
407
407
  STR
408
408
 
409
409
  expect(actual_output).to match_output(expected_output)
@@ -412,45 +412,46 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
412
412
 
413
413
  context "given two equal-length, one-dimensional arrays with differing objects" do
414
414
  it "returns a message along with the diff" do
415
- actual_output = described_class.call(
416
- expected: [
417
- SuperDiff::Test::Person.new(name: "Marty", age: 18),
418
- SuperDiff::Test::Person.new(name: "Jennifer", age: 17),
419
- ],
420
- actual: [
421
- SuperDiff::Test::Person.new(name: "Marty", age: 18),
422
- SuperDiff::Test::Person.new(name: "Doc", age: 50),
423
- ],
424
- )
415
+ actual_output =
416
+ described_class.call(
417
+ expected: [
418
+ SuperDiff::Test::Person.new(name: "Marty", age: 18),
419
+ SuperDiff::Test::Person.new(name: "Jennifer", age: 17)
420
+ ],
421
+ actual: [
422
+ SuperDiff::Test::Person.new(name: "Marty", age: 18),
423
+ SuperDiff::Test::Person.new(name: "Doc", age: 50)
424
+ ]
425
+ )
425
426
 
426
427
  expected_output = <<~STR.strip
427
428
  Differing arrays.
428
429
 
429
430
  #{
430
- colored do
431
- expected_line %(Expected: [#<SuperDiff::Test::Person name: "Marty", age: 18>, #<SuperDiff::Test::Person name: "Jennifer", age: 17>])
432
- actual_line %( Actual: [#<SuperDiff::Test::Person name: "Marty", age: 18>, #<SuperDiff::Test::Person name: "Doc", age: 50>])
433
- end
434
- }
431
+ colored do
432
+ expected_line %(Expected: [#<SuperDiff::Test::Person name: "Marty", age: 18>, #<SuperDiff::Test::Person name: "Jennifer", age: 17>])
433
+ actual_line %( Actual: [#<SuperDiff::Test::Person name: "Marty", age: 18>, #<SuperDiff::Test::Person name: "Doc", age: 50>])
434
+ end
435
+ }
435
436
 
436
437
  Diff:
437
438
 
438
439
  #{
439
- colored do
440
- plain_line %( [)
441
- plain_line %( #<SuperDiff::Test::Person {)
442
- plain_line %( name: "Marty",)
443
- plain_line %( age: 18)
444
- plain_line %( }>,)
445
- plain_line %( #<SuperDiff::Test::Person {)
446
- expected_line %(- name: "Jennifer",)
447
- actual_line %(+ name: "Doc",)
448
- expected_line %(- age: 17)
449
- actual_line %(+ age: 50)
450
- plain_line %( }>)
451
- plain_line %( ])
452
- end
453
- }
440
+ colored do
441
+ plain_line " ["
442
+ plain_line " #<SuperDiff::Test::Person {"
443
+ plain_line %( name: "Marty",)
444
+ plain_line " age: 18"
445
+ plain_line " }>,"
446
+ plain_line " #<SuperDiff::Test::Person {"
447
+ expected_line %(- name: "Jennifer",)
448
+ actual_line %(+ name: "Doc",)
449
+ expected_line "- age: 17"
450
+ actual_line "+ age: 50"
451
+ plain_line " }>"
452
+ plain_line " ]"
453
+ end
454
+ }
454
455
  STR
455
456
 
456
457
  expect(actual_output).to match_output(expected_output)
@@ -459,32 +460,30 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
459
460
 
460
461
  context "given two one-dimensional arrays where the actual has elements added to the end" do
461
462
  it "returns a message along with the diff" do
462
- actual_output = described_class.call(
463
- expected: ["bread"],
464
- actual: ["bread", "eggs", "milk"],
465
- )
463
+ actual_output =
464
+ described_class.call(expected: ["bread"], actual: %w[bread eggs milk])
466
465
 
467
466
  expected_output = <<~STR.strip
468
467
  Differing arrays.
469
468
 
470
469
  #{
471
- colored do
472
- expected_line %(Expected: ["bread"])
473
- actual_line %( Actual: ["bread", "eggs", "milk"])
474
- end
475
- }
470
+ colored do
471
+ expected_line %(Expected: ["bread"])
472
+ actual_line %( Actual: ["bread", "eggs", "milk"])
473
+ end
474
+ }
476
475
 
477
476
  Diff:
478
477
 
479
478
  #{
480
- colored do
481
- plain_line %( [)
482
- plain_line %( "bread",)
483
- actual_line %(+ "eggs",)
484
- actual_line %(+ "milk")
485
- plain_line %( ])
486
- end
487
- }
479
+ colored do
480
+ plain_line " ["
481
+ plain_line %( "bread",)
482
+ actual_line %(+ "eggs",)
483
+ actual_line %(+ "milk")
484
+ plain_line " ]"
485
+ end
486
+ }
488
487
  STR
489
488
 
490
489
  expect(actual_output).to match_output(expected_output)
@@ -493,32 +492,30 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
493
492
 
494
493
  context "given two one-dimensional arrays where the actual has elements missing from the end" do
495
494
  it "returns a message along with the diff" do
496
- actual_output = described_class.call(
497
- expected: ["bread", "eggs", "milk"],
498
- actual: ["bread"],
499
- )
495
+ actual_output =
496
+ described_class.call(expected: %w[bread eggs milk], actual: ["bread"])
500
497
 
501
498
  expected_output = <<~STR.strip
502
499
  Differing arrays.
503
500
 
504
501
  #{
505
- colored do
506
- expected_line %(Expected: ["bread", "eggs", "milk"])
507
- actual_line %( Actual: ["bread"])
508
- end
509
- }
502
+ colored do
503
+ expected_line %(Expected: ["bread", "eggs", "milk"])
504
+ actual_line %( Actual: ["bread"])
505
+ end
506
+ }
510
507
 
511
508
  Diff:
512
509
 
513
510
  #{
514
- colored do
515
- plain_line %( [)
516
- plain_line %( "bread")
517
- expected_line %(- "eggs",)
518
- expected_line %(- "milk")
519
- plain_line %( ])
520
- end
521
- }
511
+ colored do
512
+ plain_line " ["
513
+ plain_line %( "bread")
514
+ expected_line %(- "eggs",)
515
+ expected_line %(- "milk")
516
+ plain_line " ]"
517
+ end
518
+ }
522
519
  STR
523
520
 
524
521
  expect(actual_output).to match_output(expected_output)
@@ -527,32 +524,30 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
527
524
 
528
525
  context "given two one-dimensional arrays where the actual has elements added to the beginning" do
529
526
  it "returns a message along with the diff" do
530
- actual_output = described_class.call(
531
- expected: ["milk"],
532
- actual: ["bread", "eggs", "milk"],
533
- )
527
+ actual_output =
528
+ described_class.call(expected: ["milk"], actual: %w[bread eggs milk])
534
529
 
535
530
  expected_output = <<~STR.strip
536
531
  Differing arrays.
537
532
 
538
533
  #{
539
- colored do
540
- expected_line %(Expected: ["milk"])
541
- actual_line %( Actual: ["bread", "eggs", "milk"])
542
- end
543
- }
534
+ colored do
535
+ expected_line %(Expected: ["milk"])
536
+ actual_line %( Actual: ["bread", "eggs", "milk"])
537
+ end
538
+ }
544
539
 
545
540
  Diff:
546
541
 
547
542
  #{
548
- colored do
549
- plain_line %( [)
550
- actual_line %(+ "bread",)
551
- actual_line %(+ "eggs",)
552
- plain_line %( "milk")
553
- plain_line %( ])
554
- end
555
- }
543
+ colored do
544
+ plain_line " ["
545
+ actual_line %(+ "bread",)
546
+ actual_line %(+ "eggs",)
547
+ plain_line %( "milk")
548
+ plain_line " ]"
549
+ end
550
+ }
556
551
  STR
557
552
 
558
553
  expect(actual_output).to match_output(expected_output)
@@ -561,32 +556,30 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
561
556
 
562
557
  context "given two one-dimensional arrays where the actual has elements removed from the beginning" do
563
558
  it "returns a message along with the diff" do
564
- actual_output = described_class.call(
565
- expected: ["bread", "eggs", "milk"],
566
- actual: ["milk"],
567
- )
559
+ actual_output =
560
+ described_class.call(expected: %w[bread eggs milk], actual: ["milk"])
568
561
 
569
562
  expected_output = <<~STR.strip
570
563
  Differing arrays.
571
564
 
572
565
  #{
573
- colored do
574
- expected_line %(Expected: ["bread", "eggs", "milk"])
575
- actual_line %( Actual: ["milk"])
576
- end
577
- }
566
+ colored do
567
+ expected_line %(Expected: ["bread", "eggs", "milk"])
568
+ actual_line %( Actual: ["milk"])
569
+ end
570
+ }
578
571
 
579
572
  Diff:
580
573
 
581
574
  #{
582
- colored do
583
- plain_line %( [)
584
- expected_line %(- "bread",)
585
- expected_line %(- "eggs",)
586
- plain_line %( "milk")
587
- plain_line %( ])
588
- end
589
- }
575
+ colored do
576
+ plain_line " ["
577
+ expected_line %(- "bread",)
578
+ expected_line %(- "eggs",)
579
+ plain_line %( "milk")
580
+ plain_line " ]"
581
+ end
582
+ }
590
583
  STR
591
584
 
592
585
  expect(actual_output).to match_output(expected_output)
@@ -595,38 +588,39 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
595
588
 
596
589
  context "given two arrays containing arrays with differing values" do
597
590
  it "returns a message along with the diff" do
598
- actual_output = described_class.call(
599
- expected: [1, 2, [:a, :b, :c], 4],
600
- actual: [1, 2, [:a, :x, :c], 4],
601
- )
591
+ actual_output =
592
+ described_class.call(
593
+ expected: [1, 2, %i[a b c], 4],
594
+ actual: [1, 2, %i[a x c], 4]
595
+ )
602
596
 
603
597
  expected_output = <<~STR.strip
604
598
  Differing arrays.
605
599
 
606
600
  #{
607
- colored do
608
- expected_line %(Expected: [1, 2, [:a, :b, :c], 4])
609
- actual_line %( Actual: [1, 2, [:a, :x, :c], 4])
610
- end
611
- }
601
+ colored do
602
+ expected_line "Expected: [1, 2, [:a, :b, :c], 4]"
603
+ actual_line " Actual: [1, 2, [:a, :x, :c], 4]"
604
+ end
605
+ }
612
606
 
613
607
  Diff:
614
608
 
615
609
  #{
616
- colored do
617
- plain_line %( [)
618
- plain_line %( 1,)
619
- plain_line %( 2,)
620
- plain_line %( [)
621
- plain_line %( :a,)
622
- expected_line %(- :b,)
623
- actual_line %(+ :x,)
624
- plain_line %( :c)
625
- plain_line %( ],)
626
- plain_line %( 4)
627
- plain_line %( ])
628
- end
629
- }
610
+ colored do
611
+ plain_line " ["
612
+ plain_line " 1,"
613
+ plain_line " 2,"
614
+ plain_line " ["
615
+ plain_line " :a,"
616
+ expected_line "- :b,"
617
+ actual_line "+ :x,"
618
+ plain_line " :c"
619
+ plain_line " ],"
620
+ plain_line " 4"
621
+ plain_line " ]"
622
+ end
623
+ }
630
624
  STR
631
625
 
632
626
  expect(actual_output).to match_output(expected_output)
@@ -635,37 +629,38 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
635
629
 
636
630
  context "given two arrays containing hashes with differing values" do
637
631
  it "returns a message along with the diff" do
638
- actual_output = described_class.call(
639
- expected: [1, 2, { foo: "bar", baz: "qux" }, 4],
640
- actual: [1, 2, { foo: "bar", baz: "qox" }, 4],
641
- )
632
+ actual_output =
633
+ described_class.call(
634
+ expected: [1, 2, { foo: "bar", baz: "qux" }, 4],
635
+ actual: [1, 2, { foo: "bar", baz: "qox" }, 4]
636
+ )
642
637
 
643
638
  expected_output = <<~STR.strip
644
639
  Differing arrays.
645
640
 
646
641
  #{
647
- colored do
648
- expected_line %(Expected: [1, 2, { foo: "bar", baz: "qux" }, 4])
649
- actual_line %( Actual: [1, 2, { foo: "bar", baz: "qox" }, 4])
650
- end
651
- }
642
+ colored do
643
+ expected_line %(Expected: [1, 2, { foo: "bar", baz: "qux" }, 4])
644
+ actual_line %( Actual: [1, 2, { foo: "bar", baz: "qox" }, 4])
645
+ end
646
+ }
652
647
 
653
648
  Diff:
654
649
 
655
650
  #{
656
- colored do
657
- plain_line %( [)
658
- plain_line %( 1,)
659
- plain_line %( 2,)
660
- plain_line %( {)
661
- plain_line %( foo: "bar",)
662
- expected_line %(- baz: "qux")
663
- actual_line %(+ baz: "qox")
664
- plain_line %( },)
665
- plain_line %( 4)
666
- plain_line %( ])
667
- end
668
- }
651
+ colored do
652
+ plain_line " ["
653
+ plain_line " 1,"
654
+ plain_line " 2,"
655
+ plain_line " {"
656
+ plain_line %( foo: "bar",)
657
+ expected_line %(- baz: "qux")
658
+ actual_line %(+ baz: "qox")
659
+ plain_line " },"
660
+ plain_line " 4"
661
+ plain_line " ]"
662
+ end
663
+ }
669
664
  STR
670
665
 
671
666
  expect(actual_output).to match_output(expected_output)
@@ -674,43 +669,44 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
674
669
 
675
670
  context "given two arrays containing custom objects with differing attributes" do
676
671
  it "returns a message along with the diff" do
677
- actual_output = described_class.call(
678
- expected: [
679
- 1,
680
- 2,
681
- SuperDiff::Test::Person.new(name: "Marty", age: 18),
682
- 4,
683
- ],
684
- actual: [1, 2, SuperDiff::Test::Person.new(name: "Doc", age: 50), 4],
685
- )
672
+ actual_output =
673
+ described_class.call(
674
+ expected: [
675
+ 1,
676
+ 2,
677
+ SuperDiff::Test::Person.new(name: "Marty", age: 18),
678
+ 4
679
+ ],
680
+ actual: [1, 2, SuperDiff::Test::Person.new(name: "Doc", age: 50), 4]
681
+ )
686
682
 
687
683
  expected_output = <<~STR.strip
688
684
  Differing arrays.
689
685
 
690
686
  #{
691
- colored do
692
- expected_line %(Expected: [1, 2, #<SuperDiff::Test::Person name: "Marty", age: 18>, 4])
693
- actual_line %( Actual: [1, 2, #<SuperDiff::Test::Person name: "Doc", age: 50>, 4])
694
- end
695
- }
687
+ colored do
688
+ expected_line %(Expected: [1, 2, #<SuperDiff::Test::Person name: "Marty", age: 18>, 4])
689
+ actual_line %( Actual: [1, 2, #<SuperDiff::Test::Person name: "Doc", age: 50>, 4])
690
+ end
691
+ }
696
692
 
697
693
  Diff:
698
694
 
699
695
  #{
700
- colored do
701
- plain_line %( [)
702
- plain_line %( 1,)
703
- plain_line %( 2,)
704
- plain_line %( #<SuperDiff::Test::Person {)
705
- expected_line %(- name: "Marty",)
706
- actual_line %(+ name: "Doc",)
707
- expected_line %(- age: 18)
708
- actual_line %(+ age: 50)
709
- plain_line %( }>,)
710
- plain_line %( 4)
711
- plain_line %( ])
712
- end
713
- }
696
+ colored do
697
+ plain_line " ["
698
+ plain_line " 1,"
699
+ plain_line " 2,"
700
+ plain_line " #<SuperDiff::Test::Person {"
701
+ expected_line %(- name: "Marty",)
702
+ actual_line %(+ name: "Doc",)
703
+ expected_line "- age: 18"
704
+ actual_line "+ age: 50"
705
+ plain_line " }>,"
706
+ plain_line " 4"
707
+ plain_line " ]"
708
+ end
709
+ }
714
710
  STR
715
711
 
716
712
  expect(actual_output).to match_output(expected_output)
@@ -719,71 +715,72 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
719
715
 
720
716
  context "given two arrays which contain all different kinds of values, some which differ" do
721
717
  it "returns a message along with the diff" do
722
- actual_output = described_class.call(
723
- expected: [
724
- [
725
- :h1,
726
- [:span, [:text, "Hello world"]],
727
- {
728
- class: "header",
729
- data: { "sticky" => true },
730
- },
718
+ actual_output =
719
+ described_class.call(
720
+ expected: [
721
+ [
722
+ :h1,
723
+ [:span, [:text, "Hello world"]],
724
+ { class: "header", data: { "sticky" => true } }
725
+ ]
731
726
  ],
732
- ],
733
- actual: [
734
- [
735
- :h2,
736
- [:span, [:text, "Goodbye world"]],
737
- {
738
- id: "hero",
739
- class: "header",
740
- data: { "sticky" => false, role: "deprecated" },
741
- },
742
- ],
743
- :br,
744
- ],
745
- )
727
+ actual: [
728
+ [
729
+ :h2,
730
+ [:span, [:text, "Goodbye world"]],
731
+ {
732
+ id: "hero",
733
+ class: "header",
734
+ data: {
735
+ "sticky" => false,
736
+ :role => "deprecated"
737
+ }
738
+ }
739
+ ],
740
+ :br
741
+ ]
742
+ )
746
743
 
747
744
  expected_output = <<~STR.strip
748
745
  Differing arrays.
749
746
 
750
747
  #{
751
- colored do
752
- expected_line %(Expected: [[:h1, [:span, [:text, "Hello world"]], { class: "header", data: { "sticky" => true } }]])
753
- actual_line %( Actual: [[:h2, [:span, [:text, "Goodbye world"]], { id: "hero", class: "header", data: { "sticky" => false, :role => "deprecated" } }], :br])
754
- end
755
- }
748
+ colored do
749
+ expected_line %(Expected: [[:h1, [:span, [:text, "Hello world"]], { class: "header", data: { "sticky" => true } }]])
750
+ actual_line %( Actual: [[:h2, [:span, [:text, "Goodbye world"]], { id: "hero", class: "header", data: { "sticky" => false, :role => "deprecated" } }], :br])
751
+ end
752
+ }
756
753
 
757
754
  Diff:
758
755
 
759
756
  #{
760
- colored do
761
- plain_line %( [)
762
- plain_line %( [)
763
- expected_line %(- :h1,)
764
- actual_line %(+ :h2,)
765
- plain_line %( [)
766
- plain_line %( :span,)
767
- plain_line %( [)
768
- plain_line %( :text,)
769
- expected_line %(- "Hello world")
770
- actual_line %(+ "Goodbye world")
771
- plain_line %( ])
772
- plain_line %( ],)
773
- plain_line %( {)
774
- actual_line %(+ id: "hero",)
775
- plain_line %( class: "header",)
776
- plain_line %( data: {)
777
- expected_line %(- "sticky" => true)
778
- actual_line %(+ "sticky" => false,)
779
- actual_line %(+ :role => "deprecated")
780
- plain_line %( })
781
- plain_line %( })
782
- plain_line %( ],)
783
- actual_line %(+ :br)
784
- plain_line %( ])
785
- end
786
- }
757
+ colored do
758
+ plain_line " ["
759
+ plain_line " ["
760
+ expected_line "- :h1,"
761
+ actual_line "+ :h2,"
762
+ plain_line " ["
763
+ plain_line " :span,"
764
+ plain_line " ["
765
+ plain_line " :text,"
766
+ expected_line %(- "Hello world")
767
+ actual_line %(+ "Goodbye world")
768
+ plain_line " ]"
769
+ plain_line " ],"
770
+ plain_line " {"
771
+ actual_line %(+ id: "hero",)
772
+ plain_line %( class: "header",)
773
+ plain_line " data: {"
774
+ expected_line %(- "sticky" => true)
775
+ actual_line %(+ "sticky" => false,)
776
+ actual_line %(+ :role => "deprecated")
777
+ plain_line " }"
778
+ plain_line " }"
779
+ plain_line " ],"
780
+ actual_line "+ :br"
781
+ plain_line " ]"
782
+ end
783
+ }
787
784
  STR
788
785
 
789
786
  expect(actual_output).to match_output(expected_output)
@@ -792,10 +789,15 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
792
789
 
793
790
  context "given the same hash" do
794
791
  it "returns an empty string" do
795
- output = described_class.call(
796
- expected: { name: "Marty" },
797
- actual: { name: "Marty" },
798
- )
792
+ output =
793
+ described_class.call(
794
+ expected: {
795
+ name: "Marty"
796
+ },
797
+ actual: {
798
+ name: "Marty"
799
+ }
800
+ )
799
801
 
800
802
  expect(output).to eq("")
801
803
  end
@@ -803,33 +805,42 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
803
805
 
804
806
  context "given two equal-size, one-dimensional hashes where the same key has differing numbers" do
805
807
  it "returns a message along with the diff" do
806
- actual_output = described_class.call(
807
- expected: { tall: 12, grande: 19, venti: 20 },
808
- actual: { tall: 12, grande: 16, venti: 20 },
809
- )
808
+ actual_output =
809
+ described_class.call(
810
+ expected: {
811
+ tall: 12,
812
+ grande: 19,
813
+ venti: 20
814
+ },
815
+ actual: {
816
+ tall: 12,
817
+ grande: 16,
818
+ venti: 20
819
+ }
820
+ )
810
821
 
811
822
  expected_output = <<~STR.strip
812
823
  Differing hashes.
813
824
 
814
825
  #{
815
- colored do
816
- expected_line %(Expected: { tall: 12, grande: 19, venti: 20 })
817
- actual_line %( Actual: { tall: 12, grande: 16, venti: 20 })
818
- end
819
- }
826
+ colored do
827
+ expected_line "Expected: { tall: 12, grande: 19, venti: 20 }"
828
+ actual_line " Actual: { tall: 12, grande: 16, venti: 20 }"
829
+ end
830
+ }
820
831
 
821
832
  Diff:
822
833
 
823
834
  #{
824
- colored do
825
- plain_line %( {)
826
- plain_line %( tall: 12,)
827
- expected_line %(- grande: 19,)
828
- actual_line %(+ grande: 16,)
829
- plain_line %( venti: 20)
830
- plain_line %( })
831
- end
832
- }
835
+ colored do
836
+ plain_line " {"
837
+ plain_line " tall: 12,"
838
+ expected_line "- grande: 19,"
839
+ actual_line "+ grande: 16,"
840
+ plain_line " venti: 20"
841
+ plain_line " }"
842
+ end
843
+ }
833
844
  STR
834
845
 
835
846
  expect(actual_output).to match_output(expected_output)
@@ -838,33 +849,42 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
838
849
 
839
850
  context "given two equal-size, one-dimensional hashes where keys are strings and the same key has differing numbers" do
840
851
  it "returns a message along with the diff" do
841
- actual_output = described_class.call(
842
- expected: { "tall" => 12, "grande" => 19, "venti" => 20 },
843
- actual: { "tall" => 12, "grande" => 16, "venti" => 20 },
844
- )
852
+ actual_output =
853
+ described_class.call(
854
+ expected: {
855
+ "tall" => 12,
856
+ "grande" => 19,
857
+ "venti" => 20
858
+ },
859
+ actual: {
860
+ "tall" => 12,
861
+ "grande" => 16,
862
+ "venti" => 20
863
+ }
864
+ )
845
865
 
846
866
  expected_output = <<~STR.strip
847
867
  Differing hashes.
848
868
 
849
869
  #{
850
- colored do
851
- expected_line %(Expected: { "tall" => 12, "grande" => 19, "venti" => 20 })
852
- actual_line %( Actual: { "tall" => 12, "grande" => 16, "venti" => 20 })
853
- end
854
- }
870
+ colored do
871
+ expected_line %(Expected: { "tall" => 12, "grande" => 19, "venti" => 20 })
872
+ actual_line %( Actual: { "tall" => 12, "grande" => 16, "venti" => 20 })
873
+ end
874
+ }
855
875
 
856
876
  Diff:
857
877
 
858
878
  #{
859
- colored do
860
- plain_line %( {)
861
- plain_line %( "tall" => 12,)
862
- expected_line %(- "grande" => 19,)
863
- actual_line %(+ "grande" => 16,)
864
- plain_line %( "venti" => 20)
865
- plain_line %( })
866
- end
867
- }
879
+ colored do
880
+ plain_line " {"
881
+ plain_line %( "tall" => 12,)
882
+ expected_line %(- "grande" => 19,)
883
+ actual_line %(+ "grande" => 16,)
884
+ plain_line %( "venti" => 20)
885
+ plain_line " }"
886
+ end
887
+ }
868
888
  STR
869
889
 
870
890
  expect(actual_output).to match_output(expected_output)
@@ -873,33 +893,42 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
873
893
 
874
894
  context "given two equal-size, one-dimensional hashes where the same key has differing symbols" do
875
895
  it "returns a message along with the diff" do
876
- actual_output = described_class.call(
877
- expected: { tall: :small, grande: :grand, venti: :large },
878
- actual: { tall: :small, grande: :medium, venti: :large },
879
- )
896
+ actual_output =
897
+ described_class.call(
898
+ expected: {
899
+ tall: :small,
900
+ grande: :grand,
901
+ venti: :large
902
+ },
903
+ actual: {
904
+ tall: :small,
905
+ grande: :medium,
906
+ venti: :large
907
+ }
908
+ )
880
909
 
881
910
  expected_output = <<~STR.strip
882
911
  Differing hashes.
883
912
 
884
913
  #{
885
- colored do
886
- expected_line %(Expected: { tall: :small, grande: :grand, venti: :large })
887
- actual_line %( Actual: { tall: :small, grande: :medium, venti: :large })
888
- end
889
- }
914
+ colored do
915
+ expected_line "Expected: { tall: :small, grande: :grand, venti: :large }"
916
+ actual_line " Actual: { tall: :small, grande: :medium, venti: :large }"
917
+ end
918
+ }
890
919
 
891
920
  Diff:
892
921
 
893
922
  #{
894
- colored do
895
- plain_line %( {)
896
- plain_line %( tall: :small,)
897
- expected_line %(- grande: :grand,)
898
- actual_line %(+ grande: :medium,)
899
- plain_line %( venti: :large)
900
- plain_line %( })
901
- end
902
- }
923
+ colored do
924
+ plain_line " {"
925
+ plain_line " tall: :small,"
926
+ expected_line "- grande: :grand,"
927
+ actual_line "+ grande: :medium,"
928
+ plain_line " venti: :large"
929
+ plain_line " }"
930
+ end
931
+ }
903
932
  STR
904
933
 
905
934
  expect(actual_output).to match_output(expected_output)
@@ -908,33 +937,42 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
908
937
 
909
938
  context "given two equal-size, one-dimensional hashes where the same key has differing strings" do
910
939
  it "returns a message along with the diff" do
911
- actual_output = described_class.call(
912
- expected: { tall: "small", grande: "grand", venti: "large" },
913
- actual: { tall: "small", grande: "medium", venti: "large" },
914
- )
940
+ actual_output =
941
+ described_class.call(
942
+ expected: {
943
+ tall: "small",
944
+ grande: "grand",
945
+ venti: "large"
946
+ },
947
+ actual: {
948
+ tall: "small",
949
+ grande: "medium",
950
+ venti: "large"
951
+ }
952
+ )
915
953
 
916
954
  expected_output = <<~STR.strip
917
955
  Differing hashes.
918
956
 
919
957
  #{
920
- colored do
921
- expected_line %(Expected: { tall: "small", grande: "grand", venti: "large" })
922
- actual_line %( Actual: { tall: "small", grande: "medium", venti: "large" })
923
- end
924
- }
958
+ colored do
959
+ expected_line %(Expected: { tall: "small", grande: "grand", venti: "large" })
960
+ actual_line %( Actual: { tall: "small", grande: "medium", venti: "large" })
961
+ end
962
+ }
925
963
 
926
964
  Diff:
927
965
 
928
966
  #{
929
- colored do
930
- plain_line %( {)
931
- plain_line %( tall: "small",)
932
- expected_line %(- grande: "grand",)
933
- actual_line %(+ grande: "medium",)
934
- plain_line %( venti: "large")
935
- plain_line %( })
936
- end
937
- }
967
+ colored do
968
+ plain_line " {"
969
+ plain_line %( tall: "small",)
970
+ expected_line %(- grande: "grand",)
971
+ actual_line %(+ grande: "medium",)
972
+ plain_line %( venti: "large")
973
+ plain_line " }"
974
+ end
975
+ }
938
976
  STR
939
977
 
940
978
  expect(actual_output).to match_output(expected_output)
@@ -943,45 +981,46 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
943
981
 
944
982
  context "given two equal-size, one-dimensional hashes where the same key has differing objects" do
945
983
  it "returns a message along with the diff" do
946
- actual_output = described_class.call(
947
- expected: {
948
- steve: SuperDiff::Test::Person.new(name: "Jobs", age: 30),
949
- susan: SuperDiff::Test::Person.new(name: "Kare", age: 27),
950
- },
951
- actual: {
952
- steve: SuperDiff::Test::Person.new(name: "Wozniak", age: 33),
953
- susan: SuperDiff::Test::Person.new(name: "Kare", age: 27),
954
- },
955
- )
984
+ actual_output =
985
+ described_class.call(
986
+ expected: {
987
+ steve: SuperDiff::Test::Person.new(name: "Jobs", age: 30),
988
+ susan: SuperDiff::Test::Person.new(name: "Kare", age: 27)
989
+ },
990
+ actual: {
991
+ steve: SuperDiff::Test::Person.new(name: "Wozniak", age: 33),
992
+ susan: SuperDiff::Test::Person.new(name: "Kare", age: 27)
993
+ }
994
+ )
956
995
 
957
996
  expected_output = <<~STR.strip
958
997
  Differing hashes.
959
998
 
960
999
  #{
961
- colored do
962
- expected_line %(Expected: { steve: #<SuperDiff::Test::Person name: "Jobs", age: 30>, susan: #<SuperDiff::Test::Person name: "Kare", age: 27> })
963
- actual_line %( Actual: { steve: #<SuperDiff::Test::Person name: "Wozniak", age: 33>, susan: #<SuperDiff::Test::Person name: "Kare", age: 27> })
964
- end
965
- }
1000
+ colored do
1001
+ expected_line %(Expected: { steve: #<SuperDiff::Test::Person name: "Jobs", age: 30>, susan: #<SuperDiff::Test::Person name: "Kare", age: 27> })
1002
+ actual_line %( Actual: { steve: #<SuperDiff::Test::Person name: "Wozniak", age: 33>, susan: #<SuperDiff::Test::Person name: "Kare", age: 27> })
1003
+ end
1004
+ }
966
1005
 
967
1006
  Diff:
968
1007
 
969
1008
  #{
970
- colored do
971
- plain_line %( {)
972
- plain_line %( steve: #<SuperDiff::Test::Person {)
973
- expected_line %(- name: "Jobs",)
974
- actual_line %(+ name: "Wozniak",)
975
- expected_line %(- age: 30)
976
- actual_line %(+ age: 33)
977
- plain_line %( }>,)
978
- plain_line %( susan: #<SuperDiff::Test::Person {)
979
- plain_line %( name: "Kare",)
980
- plain_line %( age: 27)
981
- plain_line %( }>)
982
- plain_line %( })
983
- end
984
- }
1009
+ colored do
1010
+ plain_line " {"
1011
+ plain_line " steve: #<SuperDiff::Test::Person {"
1012
+ expected_line %(- name: "Jobs",)
1013
+ actual_line %(+ name: "Wozniak",)
1014
+ expected_line "- age: 30"
1015
+ actual_line "+ age: 33"
1016
+ plain_line " }>,"
1017
+ plain_line " susan: #<SuperDiff::Test::Person {"
1018
+ plain_line %( name: "Kare",)
1019
+ plain_line " age: 27"
1020
+ plain_line " }>"
1021
+ plain_line " }"
1022
+ end
1023
+ }
985
1024
  STR
986
1025
 
987
1026
  expect(actual_output).to match_output(expected_output)
@@ -990,32 +1029,39 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
990
1029
 
991
1030
  context "given two equal-size, one-dimensional hashes where the actual has extra keys" do
992
1031
  it "returns a message along with the diff" do
993
- actual_output = described_class.call(
994
- expected: { latte: 4.5 },
995
- actual: { latte: 4.5, mocha: 3.5, cortado: 3 },
996
- )
1032
+ actual_output =
1033
+ described_class.call(
1034
+ expected: {
1035
+ latte: 4.5
1036
+ },
1037
+ actual: {
1038
+ latte: 4.5,
1039
+ mocha: 3.5,
1040
+ cortado: 3
1041
+ }
1042
+ )
997
1043
 
998
1044
  expected_output = <<~STR.strip
999
1045
  Differing hashes.
1000
1046
 
1001
1047
  #{
1002
- colored do
1003
- expected_line %(Expected: { latte: 4.5 })
1004
- actual_line %( Actual: { latte: 4.5, mocha: 3.5, cortado: 3 })
1005
- end
1006
- }
1048
+ colored do
1049
+ expected_line "Expected: { latte: 4.5 }"
1050
+ actual_line " Actual: { latte: 4.5, mocha: 3.5, cortado: 3 }"
1051
+ end
1052
+ }
1007
1053
 
1008
1054
  Diff:
1009
1055
 
1010
1056
  #{
1011
- colored do
1012
- plain_line %( {)
1013
- plain_line %( latte: 4.5,)
1014
- actual_line %(+ mocha: 3.5,)
1015
- actual_line %(+ cortado: 3)
1016
- plain_line %( })
1017
- end
1018
- }
1057
+ colored do
1058
+ plain_line " {"
1059
+ plain_line " latte: 4.5,"
1060
+ actual_line "+ mocha: 3.5,"
1061
+ actual_line "+ cortado: 3"
1062
+ plain_line " }"
1063
+ end
1064
+ }
1019
1065
  STR
1020
1066
 
1021
1067
  expect(actual_output).to match_output(expected_output)
@@ -1024,32 +1070,39 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1024
1070
 
1025
1071
  context "given two equal-size, one-dimensional hashes where the actual has missing keys" do
1026
1072
  it "returns a message along with the diff" do
1027
- actual_output = described_class.call(
1028
- expected: { latte: 4.5, mocha: 3.5, cortado: 3 },
1029
- actual: { latte: 4.5 },
1030
- )
1073
+ actual_output =
1074
+ described_class.call(
1075
+ expected: {
1076
+ latte: 4.5,
1077
+ mocha: 3.5,
1078
+ cortado: 3
1079
+ },
1080
+ actual: {
1081
+ latte: 4.5
1082
+ }
1083
+ )
1031
1084
 
1032
1085
  expected_output = <<~STR.strip
1033
1086
  Differing hashes.
1034
1087
 
1035
1088
  #{
1036
- colored do
1037
- expected_line %(Expected: { latte: 4.5, mocha: 3.5, cortado: 3 })
1038
- actual_line %( Actual: { latte: 4.5 })
1039
- end
1040
- }
1089
+ colored do
1090
+ expected_line "Expected: { latte: 4.5, mocha: 3.5, cortado: 3 }"
1091
+ actual_line " Actual: { latte: 4.5 }"
1092
+ end
1093
+ }
1041
1094
 
1042
1095
  Diff:
1043
1096
 
1044
1097
  #{
1045
- colored do
1046
- plain_line %( {)
1047
- plain_line %( latte: 4.5)
1048
- expected_line %(- mocha: 3.5,)
1049
- expected_line %(- cortado: 3)
1050
- plain_line %( })
1051
- end
1052
- }
1098
+ colored do
1099
+ plain_line " {"
1100
+ plain_line " latte: 4.5"
1101
+ expected_line "- mocha: 3.5,"
1102
+ expected_line "- cortado: 3"
1103
+ plain_line " }"
1104
+ end
1105
+ }
1053
1106
  STR
1054
1107
 
1055
1108
  expect(actual_output).to match_output(expected_output)
@@ -1059,77 +1112,84 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1059
1112
  context "given two equal-size, one-dimensional hashes where there is a mixture of missing and extra keys in relatively the same order" do
1060
1113
  context "and the actual value is in relatively the same order as the expected" do
1061
1114
  it "preserves the order of the keys as they are defined" do
1062
- actual_output = described_class.call(
1063
- expected: {
1064
- listed_count: 37_009,
1065
- created_at: "Tue Jan 13 19:28:24 +0000 2009",
1066
- favourites_count: 38,
1067
- geo_enabled: false,
1068
- verified: true,
1069
- statuses_count: 273_860,
1070
- media_count: 51_044,
1071
- contributors_enabled: false,
1072
- profile_background_color: "FFF1E0",
1073
- profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",
1074
- profile_background_tile: false,
1075
- profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
1076
- profile_image_url_https: "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
1077
- profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592",
1078
- },
1079
- actual: {
1080
- listed_count: 37_009,
1081
- created_at: "Tue Jan 13 19:28:24 +0000 2009",
1082
- favourites_count: 38,
1083
- utc_offset: nil,
1084
- time_zone: nil,
1085
- statuses_count: 273_860,
1086
- media_count: 51_044,
1087
- contributors_enabled: false,
1088
- is_translator: false,
1089
- is_translation_enabled: false,
1090
- profile_background_color: "FFF1E0",
1091
- profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",
1092
- profile_background_tile: false,
1093
- profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592",
1094
- }
1095
- )
1115
+ actual_output =
1116
+ described_class.call(
1117
+ expected: {
1118
+ listed_count: 37_009,
1119
+ created_at: "Tue Jan 13 19:28:24 +0000 2009",
1120
+ favourites_count: 38,
1121
+ geo_enabled: false,
1122
+ verified: true,
1123
+ statuses_count: 273_860,
1124
+ media_count: 51_044,
1125
+ contributors_enabled: false,
1126
+ profile_background_color: "FFF1E0",
1127
+ profile_background_image_url_https:
1128
+ "https://abs.twimg.com/images/themes/theme1/bg.png",
1129
+ profile_background_tile: false,
1130
+ profile_image_url:
1131
+ "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
1132
+ profile_image_url_https:
1133
+ "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
1134
+ profile_banner_url:
1135
+ "https://pbs.twimg.com/profile_banners/18949452/1581526592"
1136
+ },
1137
+ actual: {
1138
+ listed_count: 37_009,
1139
+ created_at: "Tue Jan 13 19:28:24 +0000 2009",
1140
+ favourites_count: 38,
1141
+ utc_offset: nil,
1142
+ time_zone: nil,
1143
+ statuses_count: 273_860,
1144
+ media_count: 51_044,
1145
+ contributors_enabled: false,
1146
+ is_translator: false,
1147
+ is_translation_enabled: false,
1148
+ profile_background_color: "FFF1E0",
1149
+ profile_background_image_url_https:
1150
+ "https://abs.twimg.com/images/themes/theme1/bg.png",
1151
+ profile_background_tile: false,
1152
+ profile_banner_url:
1153
+ "https://pbs.twimg.com/profile_banners/18949452/1581526592"
1154
+ }
1155
+ )
1096
1156
 
1097
1157
  expected_output = <<~STR.strip
1098
1158
  Differing hashes.
1099
1159
 
1100
1160
  #{
1101
- colored do
1102
- expected_line %(Expected: { listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, geo_enabled: false, verified: true, statuses_count: 273860, media_count: 51044, contributors_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_tile: false, profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", profile_image_url_https: "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592" })
1103
- actual_line %( Actual: { listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, utc_offset: nil, time_zone: nil, statuses_count: 273860, media_count: 51044, contributors_enabled: false, is_translator: false, is_translation_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_tile: false, profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592" })
1104
- end
1105
- }
1161
+ colored do
1162
+ expected_line %(Expected: { listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, geo_enabled: false, verified: true, statuses_count: 273860, media_count: 51044, contributors_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_tile: false, profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", profile_image_url_https: "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592" })
1163
+ actual_line %( Actual: { listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, utc_offset: nil, time_zone: nil, statuses_count: 273860, media_count: 51044, contributors_enabled: false, is_translator: false, is_translation_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_tile: false, profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592" })
1164
+ end
1165
+ }
1106
1166
 
1107
1167
  Diff:
1108
1168
 
1109
1169
  #{
1110
- colored do
1111
- plain_line %( {)
1112
- plain_line %( listed_count: 37009,)
1113
- plain_line %( created_at: "Tue Jan 13 19:28:24 +0000 2009",)
1114
- plain_line %( favourites_count: 38,)
1115
- expected_line %(- geo_enabled: false,)
1116
- expected_line %(- verified: true,)
1117
- actual_line %(+ utc_offset: nil,)
1118
- actual_line %(+ time_zone: nil,)
1119
- plain_line %( statuses_count: 273860,)
1120
- plain_line %( media_count: 51044,)
1121
- plain_line %( contributors_enabled: false,)
1122
- actual_line %(+ is_translator: false,)
1123
- actual_line %(+ is_translation_enabled: false,)
1124
- plain_line %( profile_background_color: "FFF1E0",)
1125
- plain_line %( profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",)
1126
- plain_line %( profile_background_tile: false,)
1127
- expected_line %(- profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",)
1128
- expected_line %(- profile_image_url_https: "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",)
1129
- plain_line %( profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592")
1130
- plain_line %( })
1131
- end
1132
- }
1170
+ colored do
1171
+ plain_line " {"
1172
+ plain_line " listed_count: 37009,"
1173
+ plain_line %( created_at: "Tue Jan 13 19:28:24 +0000 2009",)
1174
+ plain_line " favourites_count: 38,"
1175
+ expected_line "- geo_enabled: false,"
1176
+ expected_line "- verified: true,"
1177
+ actual_line "+ utc_offset: nil,"
1178
+ actual_line "+ time_zone: nil,"
1179
+ plain_line " statuses_count: 273860,"
1180
+ plain_line " media_count: 51044,"
1181
+ plain_line " contributors_enabled: false,"
1182
+ actual_line "+ is_translator: false,"
1183
+ actual_line "+ is_translation_enabled: false,"
1184
+ plain_line %( profile_background_color: "FFF1E0",)
1185
+ plain_line %( profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",)
1186
+ plain_line " profile_background_tile: false,"
1187
+ expected_line %(- profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",)
1188
+ expected_line %(- profile_image_url_https: "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",)
1189
+ plain_line %( profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592")
1190
+ plain_line " }"
1191
+ end
1192
+ }
1133
1193
  STR
1134
1194
 
1135
1195
  expect(actual_output).to match_output(expected_output)
@@ -1138,73 +1198,79 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1138
1198
 
1139
1199
  context "and the actual value is in a different order than the expected" do
1140
1200
  it "preserves the order of the keys as they are defined" do
1141
- actual_output = described_class.call(
1142
- expected: {
1143
- created_at: "Tue Jan 13 19:28:24 +0000 2009",
1144
- favourites_count: 38,
1145
- geo_enabled: false,
1146
- verified: true,
1147
- media_count: 51_044,
1148
- statuses_count: 273_860,
1149
- contributors_enabled: false,
1150
- profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",
1151
- profile_background_color: "FFF1E0",
1152
- profile_background_tile: false,
1153
- profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
1154
- listed_count: 37_009,
1155
- profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592",
1156
- },
1157
- actual: {
1158
- listed_count: 37_009,
1159
- created_at: "Tue Jan 13 19:28:24 +0000 2009",
1160
- favourites_count: 38,
1161
- utc_offset: nil,
1162
- statuses_count: 273_860,
1163
- media_count: 51_044,
1164
- contributors_enabled: false,
1165
- is_translator: false,
1166
- is_translation_enabled: false,
1167
- profile_background_color: "FFF1E0",
1168
- profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",
1169
- profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592",
1170
- profile_background_tile: false,
1171
- }
1172
- )
1201
+ actual_output =
1202
+ described_class.call(
1203
+ expected: {
1204
+ created_at: "Tue Jan 13 19:28:24 +0000 2009",
1205
+ favourites_count: 38,
1206
+ geo_enabled: false,
1207
+ verified: true,
1208
+ media_count: 51_044,
1209
+ statuses_count: 273_860,
1210
+ contributors_enabled: false,
1211
+ profile_background_image_url_https:
1212
+ "https://abs.twimg.com/images/themes/theme1/bg.png",
1213
+ profile_background_color: "FFF1E0",
1214
+ profile_background_tile: false,
1215
+ profile_image_url:
1216
+ "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
1217
+ listed_count: 37_009,
1218
+ profile_banner_url:
1219
+ "https://pbs.twimg.com/profile_banners/18949452/1581526592"
1220
+ },
1221
+ actual: {
1222
+ listed_count: 37_009,
1223
+ created_at: "Tue Jan 13 19:28:24 +0000 2009",
1224
+ favourites_count: 38,
1225
+ utc_offset: nil,
1226
+ statuses_count: 273_860,
1227
+ media_count: 51_044,
1228
+ contributors_enabled: false,
1229
+ is_translator: false,
1230
+ is_translation_enabled: false,
1231
+ profile_background_color: "FFF1E0",
1232
+ profile_background_image_url_https:
1233
+ "https://abs.twimg.com/images/themes/theme1/bg.png",
1234
+ profile_banner_url:
1235
+ "https://pbs.twimg.com/profile_banners/18949452/1581526592",
1236
+ profile_background_tile: false
1237
+ }
1238
+ )
1173
1239
 
1174
1240
  expected_output = <<~STR.strip
1175
1241
  Differing hashes.
1176
1242
 
1177
1243
  #{
1178
- colored do
1179
- expected_line %(Expected: { created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, geo_enabled: false, verified: true, media_count: 51044, statuses_count: 273860, contributors_enabled: false, profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_color: "FFF1E0", profile_background_tile: false, profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", listed_count: 37009, profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592" })
1180
- actual_line %( Actual: { listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, utc_offset: nil, statuses_count: 273860, media_count: 51044, contributors_enabled: false, is_translator: false, is_translation_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592", profile_background_tile: false })
1181
- end
1182
- }
1244
+ colored do
1245
+ expected_line %(Expected: { created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, geo_enabled: false, verified: true, media_count: 51044, statuses_count: 273860, contributors_enabled: false, profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_color: "FFF1E0", profile_background_tile: false, profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", listed_count: 37009, profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592" })
1246
+ actual_line %( Actual: { listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, utc_offset: nil, statuses_count: 273860, media_count: 51044, contributors_enabled: false, is_translator: false, is_translation_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592", profile_background_tile: false })
1247
+ end
1248
+ }
1183
1249
 
1184
1250
  Diff:
1185
1251
 
1186
1252
  #{
1187
- colored do
1188
- plain_line %( {)
1189
- plain_line %( listed_count: 37009,)
1190
- plain_line %( created_at: "Tue Jan 13 19:28:24 +0000 2009",)
1191
- plain_line %( favourites_count: 38,)
1192
- expected_line %(- geo_enabled: false,)
1193
- expected_line %(- verified: true,)
1194
- actual_line %(+ utc_offset: nil,)
1195
- plain_line %( statuses_count: 273860,)
1196
- plain_line %( media_count: 51044,)
1197
- plain_line %( contributors_enabled: false,)
1198
- actual_line %(+ is_translator: false,)
1199
- actual_line %(+ is_translation_enabled: false,)
1200
- plain_line %( profile_background_color: "FFF1E0",)
1201
- plain_line %( profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",)
1202
- expected_line %(- profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",)
1203
- plain_line %( profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592",)
1204
- plain_line %( profile_background_tile: false)
1205
- plain_line %( })
1206
- end
1207
- }
1253
+ colored do
1254
+ plain_line " {"
1255
+ plain_line " listed_count: 37009,"
1256
+ plain_line %( created_at: "Tue Jan 13 19:28:24 +0000 2009",)
1257
+ plain_line " favourites_count: 38,"
1258
+ expected_line "- geo_enabled: false,"
1259
+ expected_line "- verified: true,"
1260
+ actual_line "+ utc_offset: nil,"
1261
+ plain_line " statuses_count: 273860,"
1262
+ plain_line " media_count: 51044,"
1263
+ plain_line " contributors_enabled: false,"
1264
+ actual_line "+ is_translator: false,"
1265
+ actual_line "+ is_translation_enabled: false,"
1266
+ plain_line %( profile_background_color: "FFF1E0",)
1267
+ plain_line %( profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",)
1268
+ expected_line %(- profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",)
1269
+ plain_line %( profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592",)
1270
+ plain_line " profile_background_tile: false"
1271
+ plain_line " }"
1272
+ end
1273
+ }
1208
1274
  STR
1209
1275
 
1210
1276
  expect(actual_output).to match_output(expected_output)
@@ -1214,45 +1280,46 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1214
1280
 
1215
1281
  context "given two hashes containing arrays with differing values" do
1216
1282
  it "returns a message along with the diff" do
1217
- actual_output = described_class.call(
1218
- expected: {
1219
- name: "Elliot",
1220
- interests: ["music", "football", "programming"],
1221
- age: 30,
1222
- },
1223
- actual: {
1224
- name: "Elliot",
1225
- interests: ["music", "travel", "programming"],
1226
- age: 30,
1227
- },
1228
- )
1283
+ actual_output =
1284
+ described_class.call(
1285
+ expected: {
1286
+ name: "Elliot",
1287
+ interests: %w[music football programming],
1288
+ age: 30
1289
+ },
1290
+ actual: {
1291
+ name: "Elliot",
1292
+ interests: %w[music travel programming],
1293
+ age: 30
1294
+ }
1295
+ )
1229
1296
 
1230
1297
  expected_output = <<~STR.strip
1231
1298
  Differing hashes.
1232
1299
 
1233
1300
  #{
1234
- colored do
1235
- expected_line %(Expected: { name: "Elliot", interests: ["music", "football", "programming"], age: 30 })
1236
- actual_line %( Actual: { name: "Elliot", interests: ["music", "travel", "programming"], age: 30 })
1237
- end
1238
- }
1301
+ colored do
1302
+ expected_line %(Expected: { name: "Elliot", interests: ["music", "football", "programming"], age: 30 })
1303
+ actual_line %( Actual: { name: "Elliot", interests: ["music", "travel", "programming"], age: 30 })
1304
+ end
1305
+ }
1239
1306
 
1240
1307
  Diff:
1241
1308
 
1242
1309
  #{
1243
- colored do
1244
- plain_line %( {)
1245
- plain_line %( name: "Elliot",)
1246
- plain_line %( interests: [)
1247
- plain_line %( "music",)
1248
- expected_line %(- "football",)
1249
- actual_line %(+ "travel",)
1250
- plain_line %( "programming")
1251
- plain_line %( ],)
1252
- plain_line %( age: 30)
1253
- plain_line %( })
1254
- end
1255
- }
1310
+ colored do
1311
+ plain_line " {"
1312
+ plain_line %( name: "Elliot",)
1313
+ plain_line " interests: ["
1314
+ plain_line %( "music",)
1315
+ expected_line %(- "football",)
1316
+ actual_line %(+ "travel",)
1317
+ plain_line %( "programming")
1318
+ plain_line " ],"
1319
+ plain_line " age: 30"
1320
+ plain_line " }"
1321
+ end
1322
+ }
1256
1323
  STR
1257
1324
 
1258
1325
  expect(actual_output).to match_output(expected_output)
@@ -1261,53 +1328,54 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1261
1328
 
1262
1329
  context "given two hashes containing hashes with differing values" do
1263
1330
  it "returns a message along with the diff" do
1264
- actual_output = described_class.call(
1265
- expected: {
1266
- check_spelling: true,
1267
- substitutions: {
1268
- "YOLO" => "You only live once",
1269
- "BRB" => "Buns, ribs, and bacon",
1270
- "YMMV" => "Your mileage may vary",
1271
- },
1272
- check_grammar: false,
1273
- },
1274
- actual: {
1275
- check_spelling: true,
1276
- substitutions: {
1277
- "YOLO" => "You only live once",
1278
- "BRB" => "Be right back",
1279
- "YMMV" => "Your mileage may vary",
1331
+ actual_output =
1332
+ described_class.call(
1333
+ expected: {
1334
+ check_spelling: true,
1335
+ substitutions: {
1336
+ "YOLO" => "You only live once",
1337
+ "BRB" => "Buns, ribs, and bacon",
1338
+ "YMMV" => "Your mileage may vary"
1339
+ },
1340
+ check_grammar: false
1280
1341
  },
1281
- check_grammar: false,
1282
- },
1283
- )
1342
+ actual: {
1343
+ check_spelling: true,
1344
+ substitutions: {
1345
+ "YOLO" => "You only live once",
1346
+ "BRB" => "Be right back",
1347
+ "YMMV" => "Your mileage may vary"
1348
+ },
1349
+ check_grammar: false
1350
+ }
1351
+ )
1284
1352
 
1285
1353
  expected_output = <<~STR.strip
1286
1354
  Differing hashes.
1287
1355
 
1288
1356
  #{
1289
- colored do
1290
- expected_line %(Expected: { check_spelling: true, substitutions: { "YOLO" => "You only live once", "BRB" => "Buns, ribs, and bacon", "YMMV" => "Your mileage may vary" }, check_grammar: false })
1291
- actual_line %( Actual: { check_spelling: true, substitutions: { "YOLO" => "You only live once", "BRB" => "Be right back", "YMMV" => "Your mileage may vary" }, check_grammar: false })
1292
- end
1293
- }
1357
+ colored do
1358
+ expected_line %(Expected: { check_spelling: true, substitutions: { "YOLO" => "You only live once", "BRB" => "Buns, ribs, and bacon", "YMMV" => "Your mileage may vary" }, check_grammar: false })
1359
+ actual_line %( Actual: { check_spelling: true, substitutions: { "YOLO" => "You only live once", "BRB" => "Be right back", "YMMV" => "Your mileage may vary" }, check_grammar: false })
1360
+ end
1361
+ }
1294
1362
 
1295
1363
  Diff:
1296
1364
 
1297
1365
  #{
1298
- colored do
1299
- plain_line %( {)
1300
- plain_line %( check_spelling: true,)
1301
- plain_line %( substitutions: {)
1302
- plain_line %( "YOLO" => "You only live once",)
1303
- expected_line %(- "BRB" => "Buns, ribs, and bacon",)
1304
- actual_line %(+ "BRB" => "Be right back",)
1305
- plain_line %( "YMMV" => "Your mileage may vary")
1306
- plain_line %( },)
1307
- plain_line %( check_grammar: false)
1308
- plain_line %( })
1309
- end
1310
- }
1366
+ colored do
1367
+ plain_line " {"
1368
+ plain_line " check_spelling: true,"
1369
+ plain_line " substitutions: {"
1370
+ plain_line %( "YOLO" => "You only live once",)
1371
+ expected_line %(- "BRB" => "Buns, ribs, and bacon",)
1372
+ actual_line %(+ "BRB" => "Be right back",)
1373
+ plain_line %( "YMMV" => "Your mileage may vary")
1374
+ plain_line " },"
1375
+ plain_line " check_grammar: false"
1376
+ plain_line " }"
1377
+ end
1378
+ }
1311
1379
  STR
1312
1380
 
1313
1381
  expect(actual_output).to match_output(expected_output)
@@ -1316,45 +1384,46 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1316
1384
 
1317
1385
  context "given two hashes containing custom objects with differing attributes" do
1318
1386
  it "returns a message along with the diff" do
1319
- actual_output = described_class.call(
1320
- expected: {
1321
- order_id: 1234,
1322
- person: SuperDiff::Test::Person.new(name: "Marty", age: 18),
1323
- amount: 350_00,
1324
- },
1325
- actual: {
1326
- order_id: 1234,
1327
- person: SuperDiff::Test::Person.new(name: "Doc", age: 50),
1328
- amount: 350_00,
1329
- },
1330
- )
1387
+ actual_output =
1388
+ described_class.call(
1389
+ expected: {
1390
+ order_id: 1234,
1391
+ person: SuperDiff::Test::Person.new(name: "Marty", age: 18),
1392
+ amount: 350_00
1393
+ },
1394
+ actual: {
1395
+ order_id: 1234,
1396
+ person: SuperDiff::Test::Person.new(name: "Doc", age: 50),
1397
+ amount: 350_00
1398
+ }
1399
+ )
1331
1400
 
1332
1401
  expected_output = <<~STR.strip
1333
1402
  Differing hashes.
1334
1403
 
1335
1404
  #{
1336
- colored do
1337
- expected_line %(Expected: { order_id: 1234, person: #<SuperDiff::Test::Person name: "Marty", age: 18>, amount: 35000 })
1338
- actual_line %( Actual: { order_id: 1234, person: #<SuperDiff::Test::Person name: "Doc", age: 50>, amount: 35000 })
1339
- end
1340
- }
1405
+ colored do
1406
+ expected_line %(Expected: { order_id: 1234, person: #<SuperDiff::Test::Person name: "Marty", age: 18>, amount: 35000 })
1407
+ actual_line %( Actual: { order_id: 1234, person: #<SuperDiff::Test::Person name: "Doc", age: 50>, amount: 35000 })
1408
+ end
1409
+ }
1341
1410
 
1342
1411
  Diff:
1343
1412
 
1344
1413
  #{
1345
- colored do
1346
- plain_line %( {)
1347
- plain_line %( order_id: 1234,)
1348
- plain_line %( person: #<SuperDiff::Test::Person {)
1349
- expected_line %(- name: "Marty",)
1350
- actual_line %(+ name: "Doc",)
1351
- expected_line %(- age: 18)
1352
- actual_line %(+ age: 50)
1353
- plain_line %( }>,)
1354
- plain_line %( amount: 35000)
1355
- plain_line %( })
1356
- end
1357
- }
1414
+ colored do
1415
+ plain_line " {"
1416
+ plain_line " order_id: 1234,"
1417
+ plain_line " person: #<SuperDiff::Test::Person {"
1418
+ expected_line %(- name: "Marty",)
1419
+ actual_line %(+ name: "Doc",)
1420
+ expected_line "- age: 18"
1421
+ actual_line "+ age: 50"
1422
+ plain_line " }>,"
1423
+ plain_line " amount: 35000"
1424
+ plain_line " }"
1425
+ end
1426
+ }
1358
1427
  STR
1359
1428
 
1360
1429
  expect(actual_output).to match_output(expected_output)
@@ -1363,91 +1432,92 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1363
1432
 
1364
1433
  context "given two hashes which contain all different kinds of values, some which differ" do
1365
1434
  it "returns a message along with the diff" do
1366
- actual_output = described_class.call(
1367
- expected: {
1368
- customer: {
1369
- name: "Marty McFly",
1370
- shipping_address: {
1371
- line_1: "123 Main St.",
1372
- city: "Hill Valley",
1373
- state: "CA",
1374
- zip: "90382",
1375
- },
1376
- },
1377
- items: [
1378
- {
1379
- name: "Fender Stratocaster",
1380
- cost: 100_000,
1381
- options: ["red", "blue", "green"],
1382
- },
1383
- { name: "Chevy 4x4" },
1384
- ],
1385
- },
1386
- actual: {
1387
- customer: {
1388
- name: "Marty McFly, Jr.",
1389
- shipping_address: {
1390
- line_1: "456 Ponderosa Ct.",
1391
- city: "Hill Valley",
1392
- state: "CA",
1393
- zip: "90382",
1435
+ actual_output =
1436
+ described_class.call(
1437
+ expected: {
1438
+ customer: {
1439
+ name: "Marty McFly",
1440
+ shipping_address: {
1441
+ line_1: "123 Main St.",
1442
+ city: "Hill Valley",
1443
+ state: "CA",
1444
+ zip: "90382"
1445
+ }
1394
1446
  },
1447
+ items: [
1448
+ {
1449
+ name: "Fender Stratocaster",
1450
+ cost: 100_000,
1451
+ options: %w[red blue green]
1452
+ },
1453
+ { name: "Chevy 4x4" }
1454
+ ]
1395
1455
  },
1396
- items: [
1397
- {
1398
- name: "Fender Stratocaster",
1399
- cost: 100_000,
1400
- options: ["red", "blue", "green"],
1456
+ actual: {
1457
+ customer: {
1458
+ name: "Marty McFly, Jr.",
1459
+ shipping_address: {
1460
+ line_1: "456 Ponderosa Ct.",
1461
+ city: "Hill Valley",
1462
+ state: "CA",
1463
+ zip: "90382"
1464
+ }
1401
1465
  },
1402
- { name: "Mattel Hoverboard" },
1403
- ],
1404
- },
1405
- )
1466
+ items: [
1467
+ {
1468
+ name: "Fender Stratocaster",
1469
+ cost: 100_000,
1470
+ options: %w[red blue green]
1471
+ },
1472
+ { name: "Mattel Hoverboard" }
1473
+ ]
1474
+ }
1475
+ )
1406
1476
 
1407
1477
  expected_output = <<~STR.strip
1408
1478
  Differing hashes.
1409
1479
 
1410
1480
  #{
1411
- colored do
1412
- expected_line %(Expected: { customer: { name: "Marty McFly", shipping_address: { line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Chevy 4x4" }] })
1413
- actual_line %( Actual: { customer: { name: "Marty McFly, Jr.", shipping_address: { line_1: "456 Ponderosa Ct.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Mattel Hoverboard" }] })
1414
- end
1415
- }
1481
+ colored do
1482
+ expected_line %(Expected: { customer: { name: "Marty McFly", shipping_address: { line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Chevy 4x4" }] })
1483
+ actual_line %( Actual: { customer: { name: "Marty McFly, Jr.", shipping_address: { line_1: "456 Ponderosa Ct.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Mattel Hoverboard" }] })
1484
+ end
1485
+ }
1416
1486
 
1417
1487
  Diff:
1418
1488
 
1419
1489
  #{
1420
- colored do
1421
- plain_line %( {)
1422
- plain_line %( customer: {)
1423
- expected_line %(- name: "Marty McFly",)
1424
- actual_line %(+ name: "Marty McFly, Jr.",)
1425
- plain_line %( shipping_address: {)
1426
- expected_line %(- line_1: "123 Main St.",)
1427
- actual_line %(+ line_1: "456 Ponderosa Ct.",)
1428
- plain_line %( city: "Hill Valley",)
1429
- plain_line %( state: "CA",)
1430
- plain_line %( zip: "90382")
1431
- plain_line %( })
1432
- plain_line %( },)
1433
- plain_line %( items: [)
1434
- plain_line %( {)
1435
- plain_line %( name: "Fender Stratocaster",)
1436
- plain_line %( cost: 100000,)
1437
- plain_line %( options: [)
1438
- plain_line %( "red",)
1439
- plain_line %( "blue",)
1440
- plain_line %( "green")
1441
- plain_line %( ])
1442
- plain_line %( },)
1443
- plain_line %( {)
1444
- expected_line %(- name: "Chevy 4x4")
1445
- actual_line %(+ name: "Mattel Hoverboard")
1446
- plain_line %( })
1447
- plain_line %( ])
1448
- plain_line %( })
1449
- end
1450
- }
1490
+ colored do
1491
+ plain_line " {"
1492
+ plain_line " customer: {"
1493
+ expected_line %(- name: "Marty McFly",)
1494
+ actual_line %(+ name: "Marty McFly, Jr.",)
1495
+ plain_line " shipping_address: {"
1496
+ expected_line %(- line_1: "123 Main St.",)
1497
+ actual_line %(+ line_1: "456 Ponderosa Ct.",)
1498
+ plain_line %( city: "Hill Valley",)
1499
+ plain_line %( state: "CA",)
1500
+ plain_line %( zip: "90382")
1501
+ plain_line " }"
1502
+ plain_line " },"
1503
+ plain_line " items: ["
1504
+ plain_line " {"
1505
+ plain_line %( name: "Fender Stratocaster",)
1506
+ plain_line " cost: 100000,"
1507
+ plain_line " options: ["
1508
+ plain_line %( "red",)
1509
+ plain_line %( "blue",)
1510
+ plain_line %( "green")
1511
+ plain_line " ]"
1512
+ plain_line " },"
1513
+ plain_line " {"
1514
+ expected_line %(- name: "Chevy 4x4")
1515
+ actual_line %(+ name: "Mattel Hoverboard")
1516
+ plain_line " }"
1517
+ plain_line " ]"
1518
+ plain_line " }"
1519
+ end
1520
+ }
1451
1521
  STR
1452
1522
 
1453
1523
  expect(actual_output).to match_output(expected_output)
@@ -1470,33 +1540,30 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1470
1540
  expected = SuperDiff::Test::Person.new(name: "Marty", age: 18)
1471
1541
  actual = SuperDiff::Test::Person.new(name: "Doc", age: 50)
1472
1542
 
1473
- actual_output = described_class.call(
1474
- expected: expected,
1475
- actual: actual,
1476
- )
1543
+ actual_output = described_class.call(expected: expected, actual: actual)
1477
1544
 
1478
1545
  expected_output = <<~STR.strip
1479
1546
  Differing objects.
1480
1547
 
1481
1548
  #{
1482
- colored do
1483
- expected_line %(Expected: #<SuperDiff::Test::Person name: "Marty", age: 18>)
1484
- actual_line %( Actual: #<SuperDiff::Test::Person name: "Doc", age: 50>)
1485
- end
1486
- }
1549
+ colored do
1550
+ expected_line %(Expected: #<SuperDiff::Test::Person name: "Marty", age: 18>)
1551
+ actual_line %( Actual: #<SuperDiff::Test::Person name: "Doc", age: 50>)
1552
+ end
1553
+ }
1487
1554
 
1488
1555
  Diff:
1489
1556
 
1490
1557
  #{
1491
- colored do
1492
- plain_line %( #<SuperDiff::Test::Person {)
1493
- expected_line %(- name: "Marty",)
1494
- actual_line %(+ name: "Doc",)
1495
- expected_line %(- age: 18)
1496
- actual_line %(+ age: 50)
1497
- plain_line %( }>)
1498
- end
1499
- }
1558
+ colored do
1559
+ plain_line " #<SuperDiff::Test::Person {"
1560
+ expected_line %(- name: "Marty",)
1561
+ actual_line %(+ name: "Doc",)
1562
+ expected_line "- age: 18"
1563
+ actual_line "+ age: 50"
1564
+ plain_line " }>"
1565
+ end
1566
+ }
1500
1567
  STR
1501
1568
 
1502
1569
  expect(actual_output).to match_output(expected_output)
@@ -1505,22 +1572,24 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1505
1572
 
1506
1573
  context "given two different versions of the same non-custom class" do
1507
1574
  it "returns a message along with the diff" do
1508
- expected = SuperDiff::Test::Player.new(
1509
- handle: "martymcfly",
1510
- character: "mirage",
1511
- inventory: ["flatline", "purple body shield"],
1512
- shields: 0.6,
1513
- health: 0.3,
1514
- ultimate: 0.8,
1515
- )
1516
- actual = SuperDiff::Test::Player.new(
1517
- handle: "docbrown",
1518
- character: "lifeline",
1519
- inventory: ["wingman", "mastiff"],
1520
- shields: 0.6,
1521
- health: 0.3,
1522
- ultimate: 0.8,
1523
- )
1575
+ expected =
1576
+ SuperDiff::Test::Player.new(
1577
+ handle: "martymcfly",
1578
+ character: "mirage",
1579
+ inventory: ["flatline", "purple body shield"],
1580
+ shields: 0.6,
1581
+ health: 0.3,
1582
+ ultimate: 0.8
1583
+ )
1584
+ actual =
1585
+ SuperDiff::Test::Player.new(
1586
+ handle: "docbrown",
1587
+ character: "lifeline",
1588
+ inventory: %w[wingman mastiff],
1589
+ shields: 0.6,
1590
+ health: 0.3,
1591
+ ultimate: 0.8
1592
+ )
1524
1593
 
1525
1594
  actual_output = described_class.call(expected: expected, actual: actual)
1526
1595
 
@@ -1528,33 +1597,33 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1528
1597
  Differing objects.
1529
1598
 
1530
1599
  #{
1531
- colored do
1532
- expected_line %(Expected: #<SuperDiff::Test::Player:#{SuperDiff::Helpers.object_address_for(expected)} @character="mirage", @handle="martymcfly", @health=0.3, @inventory=["flatline", "purple body shield"], @shields=0.6, @ultimate=0.8>)
1533
- actual_line %( Actual: #<SuperDiff::Test::Player:#{SuperDiff::Helpers.object_address_for(actual)} @character="lifeline", @handle="docbrown", @health=0.3, @inventory=["wingman", "mastiff"], @shields=0.6, @ultimate=0.8>)
1534
- end
1535
- }
1600
+ colored do
1601
+ expected_line %(Expected: #<SuperDiff::Test::Player:#{SuperDiff::Helpers.object_address_for(expected)} @character="mirage", @handle="martymcfly", @health=0.3, @inventory=["flatline", "purple body shield"], @shields=0.6, @ultimate=0.8>)
1602
+ actual_line %( Actual: #<SuperDiff::Test::Player:#{SuperDiff::Helpers.object_address_for(actual)} @character="lifeline", @handle="docbrown", @health=0.3, @inventory=["wingman", "mastiff"], @shields=0.6, @ultimate=0.8>)
1603
+ end
1604
+ }
1536
1605
 
1537
1606
  Diff:
1538
1607
 
1539
1608
  #{
1540
- colored do
1541
- plain_line %( #<SuperDiff::Test::Player:#{SuperDiff::Helpers.object_address_for(actual)} {)
1542
- expected_line %(- @character="mirage",)
1543
- actual_line %(+ @character="lifeline",)
1544
- expected_line %(- @handle="martymcfly",)
1545
- actual_line %(+ @handle="docbrown",)
1546
- plain_line %( @health=0.3,)
1547
- plain_line %( @inventory=[)
1548
- expected_line %(- "flatline",)
1549
- actual_line %(+ "wingman",)
1550
- expected_line %(- "purple body shield")
1551
- actual_line %(+ "mastiff")
1552
- plain_line %( ],)
1553
- plain_line %( @shields=0.6,)
1554
- plain_line %( @ultimate=0.8)
1555
- plain_line %( }>)
1556
- end
1557
- }
1609
+ colored do
1610
+ plain_line %( #<SuperDiff::Test::Player:#{SuperDiff::Helpers.object_address_for(actual)} {)
1611
+ expected_line %(- @character="mirage",)
1612
+ actual_line %(+ @character="lifeline",)
1613
+ expected_line %(- @handle="martymcfly",)
1614
+ actual_line %(+ @handle="docbrown",)
1615
+ plain_line " @health=0.3,"
1616
+ plain_line " @inventory=["
1617
+ expected_line %(- "flatline",)
1618
+ actual_line %(+ "wingman",)
1619
+ expected_line %(- "purple body shield")
1620
+ actual_line %(+ "mastiff")
1621
+ plain_line " ],"
1622
+ plain_line " @shields=0.6,"
1623
+ plain_line " @ultimate=0.8"
1624
+ plain_line " }>"
1625
+ end
1626
+ }
1558
1627
  STR
1559
1628
 
1560
1629
  expect(actual_output).to match_output(expected_output)
@@ -1563,15 +1632,13 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1563
1632
 
1564
1633
  context "given two completely different kinds of custom objects" do
1565
1634
  it "returns a message along with the diff" do
1566
- expected = SuperDiff::Test::Person.new(
1567
- name: "Marty",
1568
- age: 31,
1569
- )
1570
- actual = SuperDiff::Test::Customer.new(
1571
- name: "Doc",
1572
- shipping_address: :some_shipping_address,
1573
- phone: "1234567890",
1574
- )
1635
+ expected = SuperDiff::Test::Person.new(name: "Marty", age: 31)
1636
+ actual =
1637
+ SuperDiff::Test::Customer.new(
1638
+ name: "Doc",
1639
+ shipping_address: :some_shipping_address,
1640
+ phone: "1234567890"
1641
+ )
1575
1642
 
1576
1643
  actual_output = described_class.call(expected: expected, actual: actual)
1577
1644
 
@@ -1579,11 +1646,11 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1579
1646
  Differing objects.
1580
1647
 
1581
1648
  #{
1582
- colored do
1583
- expected_line %(Expected: #<SuperDiff::Test::Person name: "Marty", age: 31>)
1584
- actual_line %( Actual: #<SuperDiff::Test::Customer name: "Doc", shipping_address: :some_shipping_address, phone: "1234567890">)
1585
- end
1586
- }
1649
+ colored do
1650
+ expected_line %(Expected: #<SuperDiff::Test::Person name: "Marty", age: 31>)
1651
+ actual_line %( Actual: #<SuperDiff::Test::Customer name: "Doc", shipping_address: :some_shipping_address, phone: "1234567890">)
1652
+ end
1653
+ }
1587
1654
  STR
1588
1655
 
1589
1656
  expect(actual_output).to match_output(expected_output)
@@ -1592,18 +1659,16 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1592
1659
 
1593
1660
  context "given two completely different kinds of non-custom objects" do
1594
1661
  it "returns a message along with the diff" do
1595
- expected = SuperDiff::Test::Item.new(
1596
- name: "camera",
1597
- quantity: 3,
1598
- )
1599
- actual = SuperDiff::Test::Player.new(
1600
- handle: "mcmire",
1601
- character: "Jon",
1602
- inventory: ["sword"],
1603
- shields: 11.4,
1604
- health: 4,
1605
- ultimate: true,
1606
- )
1662
+ expected = SuperDiff::Test::Item.new(name: "camera", quantity: 3)
1663
+ actual =
1664
+ SuperDiff::Test::Player.new(
1665
+ handle: "mcmire",
1666
+ character: "Jon",
1667
+ inventory: ["sword"],
1668
+ shields: 11.4,
1669
+ health: 4,
1670
+ ultimate: true
1671
+ )
1607
1672
 
1608
1673
  actual_output = described_class.call(expected: expected, actual: actual)
1609
1674
 
@@ -1611,11 +1676,11 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1611
1676
  Differing objects.
1612
1677
 
1613
1678
  #{
1614
- colored do
1615
- expected_line %(Expected: #<SuperDiff::Test::Item:#{SuperDiff::Helpers.object_address_for(expected)} @name="camera", @quantity=3>)
1616
- actual_line %( Actual: #<SuperDiff::Test::Player:#{SuperDiff::Helpers.object_address_for(actual)} @character="Jon", @handle="mcmire", @health=4, @inventory=["sword"], @shields=11.4, @ultimate=true>)
1617
- end
1618
- }
1679
+ colored do
1680
+ expected_line %(Expected: #<SuperDiff::Test::Item:#{SuperDiff::Helpers.object_address_for(expected)} @name="camera", @quantity=3>)
1681
+ actual_line %( Actual: #<SuperDiff::Test::Player:#{SuperDiff::Helpers.object_address_for(actual)} @character="Jon", @handle="mcmire", @health=4, @inventory=["sword"], @shields=11.4, @ultimate=true>)
1682
+ end
1683
+ }
1619
1684
  STR
1620
1685
 
1621
1686
  expect(actual_output).to match_output(expected_output)
@@ -1624,9 +1689,9 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1624
1689
 
1625
1690
  context "when the expected value is a data structure that refers to itself somewhere inside of it" do
1626
1691
  it "replaces the reference with ∙∙∙" do
1627
- expected = ["a", "b", "c"]
1692
+ expected = %w[a b c]
1628
1693
  expected.insert(1, expected)
1629
- actual = ["a", "x", "b", "c"]
1694
+ actual = %w[a x b c]
1630
1695
 
1631
1696
  actual_output = described_class.call(expected: expected, actual: actual)
1632
1697
 
@@ -1634,25 +1699,25 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1634
1699
  Differing arrays.
1635
1700
 
1636
1701
  #{
1637
- colored do
1638
- expected_line %(Expected: ["a", ∙∙∙, "b", "c"])
1639
- actual_line %( Actual: ["a", "x", "b", "c"])
1640
- end
1641
- }
1702
+ colored do
1703
+ expected_line %(Expected: ["a", ∙∙∙, "b", "c"])
1704
+ actual_line %( Actual: ["a", "x", "b", "c"])
1705
+ end
1706
+ }
1642
1707
 
1643
1708
  Diff:
1644
1709
 
1645
1710
  #{
1646
- colored do
1647
- plain_line %( [)
1648
- plain_line %( "a",)
1649
- expected_line %(- ∙∙∙,)
1650
- actual_line %(+ "x",)
1651
- plain_line %( "b",)
1652
- plain_line %( "c")
1653
- plain_line %( ])
1654
- end
1655
- }
1711
+ colored do
1712
+ plain_line " ["
1713
+ plain_line %( "a",)
1714
+ expected_line "- ∙∙∙,"
1715
+ actual_line %(+ "x",)
1716
+ plain_line %( "b",)
1717
+ plain_line %( "c")
1718
+ plain_line " ]"
1719
+ end
1720
+ }
1656
1721
  STR
1657
1722
 
1658
1723
  expect(actual_output).to match_output(expected_output)
@@ -1661,8 +1726,8 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1661
1726
 
1662
1727
  context "when the actual value is a data structure that refers to itself somewhere inside of it" do
1663
1728
  it "replaces the reference with ∙∙∙" do
1664
- expected = ["a", "x", "b", "c"]
1665
- actual = ["a", "b", "c"]
1729
+ expected = %w[a x b c]
1730
+ actual = %w[a b c]
1666
1731
  actual.insert(1, actual)
1667
1732
 
1668
1733
  actual_output = described_class.call(expected: expected, actual: actual)
@@ -1671,25 +1736,25 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1671
1736
  Differing arrays.
1672
1737
 
1673
1738
  #{
1674
- colored do
1675
- expected_line %(Expected: ["a", "x", "b", "c"])
1676
- actual_line %( Actual: ["a", ∙∙∙, "b", "c"])
1677
- end
1678
- }
1739
+ colored do
1740
+ expected_line %(Expected: ["a", "x", "b", "c"])
1741
+ actual_line %( Actual: ["a", ∙∙∙, "b", "c"])
1742
+ end
1743
+ }
1679
1744
 
1680
1745
  Diff:
1681
1746
 
1682
1747
  #{
1683
- colored do
1684
- plain_line %( [)
1685
- plain_line %( "a",)
1686
- expected_line %(- "x",)
1687
- actual_line %(+ ∙∙∙,)
1688
- plain_line %( "b",)
1689
- plain_line %( "c")
1690
- plain_line %( ])
1691
- end
1692
- }
1748
+ colored do
1749
+ plain_line " ["
1750
+ plain_line %( "a",)
1751
+ expected_line %(- "x",)
1752
+ actual_line "+ ∙∙∙,"
1753
+ plain_line %( "b",)
1754
+ plain_line %( "c")
1755
+ plain_line " ]"
1756
+ end
1757
+ }
1693
1758
  STR
1694
1759
 
1695
1760
  expect(actual_output).to match_output(expected_output)
@@ -1698,8 +1763,8 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1698
1763
 
1699
1764
  context "when the data structure being different is present inside a secondary layer" do
1700
1765
  it "replaces the reference with ∙∙∙" do
1701
- expected = { foo: ["a", "x", "b", "c"] }
1702
- actual = { foo: ["a", "b", "c"] }
1766
+ expected = { foo: %w[a x b c] }
1767
+ actual = { foo: %w[a b c] }
1703
1768
  actual[:foo].insert(1, actual)
1704
1769
 
1705
1770
  actual_output = described_class.call(expected: expected, actual: actual)
@@ -1708,27 +1773,27 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1708
1773
  Differing hashes.
1709
1774
 
1710
1775
  #{
1711
- colored do
1712
- expected_line %(Expected: { foo: ["a", "x", "b", "c"] })
1713
- actual_line %( Actual: { foo: ["a", ∙∙∙, "b", "c"] })
1714
- end
1715
- }
1776
+ colored do
1777
+ expected_line %(Expected: { foo: ["a", "x", "b", "c"] })
1778
+ actual_line %( Actual: { foo: ["a", ∙∙∙, "b", "c"] })
1779
+ end
1780
+ }
1716
1781
 
1717
1782
  Diff:
1718
1783
 
1719
1784
  #{
1720
- colored do
1721
- plain_line %( {)
1722
- plain_line %( foo: [)
1723
- plain_line %( "a",)
1724
- expected_line %(- "x",)
1725
- actual_line %(+ ∙∙∙,)
1726
- plain_line %( "b",)
1727
- plain_line %( "c")
1728
- plain_line %( ])
1729
- plain_line %( })
1730
- end
1731
- }
1785
+ colored do
1786
+ plain_line " {"
1787
+ plain_line " foo: ["
1788
+ plain_line %( "a",)
1789
+ expected_line %(- "x",)
1790
+ actual_line "+ ∙∙∙,"
1791
+ plain_line %( "b",)
1792
+ plain_line %( "c")
1793
+ plain_line " ]"
1794
+ plain_line " }"
1795
+ end
1796
+ }
1732
1797
  STR
1733
1798
 
1734
1799
  expect(actual_output).to match_output(expected_output)
@@ -1737,8 +1802,8 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1737
1802
 
1738
1803
  context "when a secondary layer of a data structure refers to itself" do
1739
1804
  it "replaces the reference with ∙∙∙" do
1740
- expected = { foo: ["a", "x", "b", "c"] }
1741
- actual = { foo: ["a", "b", "c"] }
1805
+ expected = { foo: %w[a x b c] }
1806
+ actual = { foo: %w[a b c] }
1742
1807
  actual[:foo].insert(1, actual[:foo])
1743
1808
 
1744
1809
  actual_output = described_class.call(expected: expected, actual: actual)
@@ -1747,27 +1812,27 @@ RSpec.describe SuperDiff::EqualityMatchers::Main, type: :unit do
1747
1812
  Differing hashes.
1748
1813
 
1749
1814
  #{
1750
- colored do
1751
- expected_line %(Expected: { foo: ["a", "x", "b", "c"] })
1752
- actual_line %( Actual: { foo: ["a", ∙∙∙, "b", "c"] })
1753
- end
1754
- }
1815
+ colored do
1816
+ expected_line %(Expected: { foo: ["a", "x", "b", "c"] })
1817
+ actual_line %( Actual: { foo: ["a", ∙∙∙, "b", "c"] })
1818
+ end
1819
+ }
1755
1820
 
1756
1821
  Diff:
1757
1822
 
1758
1823
  #{
1759
- colored do
1760
- plain_line %( {)
1761
- plain_line %( foo: [)
1762
- plain_line %( "a",)
1763
- expected_line %(- "x",)
1764
- actual_line %(+ ∙∙∙,)
1765
- plain_line %( "b",)
1766
- plain_line %( "c")
1767
- plain_line %( ])
1768
- plain_line %( })
1769
- end
1770
- }
1824
+ colored do
1825
+ plain_line " {"
1826
+ plain_line " foo: ["
1827
+ plain_line %( "a",)
1828
+ expected_line %(- "x",)
1829
+ actual_line "+ ∙∙∙,"
1830
+ plain_line %( "b",)
1831
+ plain_line %( "c")
1832
+ plain_line " ]"
1833
+ plain_line " }"
1834
+ end
1835
+ }
1771
1836
  STR
1772
1837
 
1773
1838
  expect(actual_output).to match_output(expected_output)