super_diff 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +65 -26
- data/lib/super_diff/active_record/differs/active_record_relation.rb +1 -2
- data/lib/super_diff/active_record/differs.rb +1 -1
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +5 -13
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +1 -3
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +2 -2
- data/lib/super_diff/active_record/object_inspection.rb +1 -1
- data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +1 -2
- data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +1 -2
- data/lib/super_diff/active_record/operation_tree_builders.rb +2 -2
- data/lib/super_diff/active_record/operation_tree_flatteners.rb +1 -1
- data/lib/super_diff/active_record/operation_trees.rb +1 -1
- data/lib/super_diff/active_record.rb +7 -15
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +5 -6
- data/lib/super_diff/active_support/differs.rb +1 -1
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +3 -9
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +1 -1
- data/lib/super_diff/active_support/object_inspection.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +5 -6
- data/lib/super_diff/active_support/operation_tree_builders.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_flatteners.rb +1 -1
- data/lib/super_diff/active_support/operation_trees.rb +1 -1
- data/lib/super_diff/active_support.rb +6 -11
- data/lib/super_diff/colorized_document_extensions.rb +2 -4
- data/lib/super_diff/configuration.rb +14 -8
- data/lib/super_diff/csi/color.rb +4 -4
- data/lib/super_diff/csi/colorized_document.rb +12 -16
- data/lib/super_diff/csi/document.rb +8 -19
- data/lib/super_diff/csi/eight_bit_color.rb +19 -19
- data/lib/super_diff/csi/four_bit_color.rb +82 -31
- data/lib/super_diff/csi/twenty_four_bit_color.rb +12 -11
- data/lib/super_diff/csi/uncolorized_document.rb +2 -6
- data/lib/super_diff/csi.rb +10 -14
- data/lib/super_diff/diff_formatters/collection.rb +35 -41
- data/lib/super_diff/differs/default_object.rb +1 -1
- data/lib/super_diff/differs/defaults.rb +1 -1
- data/lib/super_diff/differs/main.rb +2 -13
- data/lib/super_diff/equality_matchers/array.rb +10 -12
- data/lib/super_diff/equality_matchers/base.rb +1 -1
- data/lib/super_diff/equality_matchers/default.rb +2 -4
- data/lib/super_diff/equality_matchers/defaults.rb +1 -1
- data/lib/super_diff/equality_matchers/hash.rb +10 -12
- data/lib/super_diff/equality_matchers/multiline_string.rb +11 -13
- data/lib/super_diff/equality_matchers/primitive.rb +10 -12
- data/lib/super_diff/equality_matchers/singleline_string.rb +10 -12
- data/lib/super_diff/equality_matchers.rb +1 -1
- data/lib/super_diff/errors.rb +3 -3
- data/lib/super_diff/gem_version.rb +3 -3
- data/lib/super_diff/helpers.rb +10 -10
- data/lib/super_diff/implementation_checks.rb +2 -2
- data/lib/super_diff/line.rb +3 -3
- data/lib/super_diff/object_inspection/inspection_tree.rb +46 -60
- data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +2 -6
- data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +3 -9
- data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +5 -14
- data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +1 -1
- data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +4 -12
- data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +6 -23
- data/lib/super_diff/object_inspection/inspection_tree_builders.rb +9 -9
- data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +8 -20
- data/lib/super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/as_single_line.rb +3 -7
- data/lib/super_diff/object_inspection/nodes/base.rb +9 -14
- data/lib/super_diff/object_inspection/nodes/inspection.rb +26 -34
- data/lib/super_diff/object_inspection/nodes/nesting.rb +1 -1
- data/lib/super_diff/object_inspection/nodes/only_when.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/text.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/when_empty.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_lines.rb +1 -1
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_string.rb +1 -5
- data/lib/super_diff/object_inspection/nodes.rb +7 -7
- data/lib/super_diff/object_inspection.rb +3 -3
- data/lib/super_diff/operation_tree_builders/array.rb +12 -11
- data/lib/super_diff/operation_tree_builders/base.rb +17 -15
- data/lib/super_diff/operation_tree_builders/custom_object.rb +8 -6
- data/lib/super_diff/operation_tree_builders/default_object.rb +29 -21
- data/lib/super_diff/operation_tree_builders/hash.rb +23 -24
- data/lib/super_diff/operation_tree_builders/main.rb +4 -11
- data/lib/super_diff/operation_tree_builders/multiline_string.rb +3 -3
- data/lib/super_diff/operation_tree_builders/time_like.rb +1 -11
- data/lib/super_diff/operation_tree_builders.rb +1 -1
- data/lib/super_diff/operation_tree_flatteners/base.rb +1 -5
- data/lib/super_diff/operation_tree_flatteners/collection.rb +13 -16
- data/lib/super_diff/operation_tree_flatteners/default_object.rb +1 -2
- data/lib/super_diff/operation_tree_flatteners/hash.rb +2 -10
- data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +2 -1
- data/lib/super_diff/operation_tree_flatteners.rb +3 -3
- data/lib/super_diff/operation_trees/base.rb +3 -5
- data/lib/super_diff/operation_trees/default_object.rb +1 -3
- data/lib/super_diff/operations/binary_operation.rb +2 -2
- data/lib/super_diff/operations/unary_operation.rb +1 -1
- data/lib/super_diff/rails.rb +2 -1
- data/lib/super_diff/recursion_guard.rb +5 -4
- data/lib/super_diff/rspec/augmented_matcher.rb +4 -5
- data/lib/super_diff/rspec/differ.rb +6 -13
- data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +3 -2
- data/lib/super_diff/rspec/differs/collection_including.rb +1 -1
- data/lib/super_diff/rspec/differs/hash_including.rb +1 -1
- data/lib/super_diff/rspec/differs.rb +3 -3
- data/lib/super_diff/rspec/matcher_text_builders/base.rb +13 -15
- data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +5 -7
- data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +3 -5
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +1 -5
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +2 -6
- data/lib/super_diff/rspec/matcher_text_builders.rb +5 -8
- data/lib/super_diff/rspec/matcher_text_template.rb +13 -16
- data/lib/super_diff/rspec/monkey_patches.rb +122 -116
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +11 -16
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +2 -1
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +9 -9
- data/lib/super_diff/rspec/object_inspection.rb +1 -1
- data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +11 -10
- data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +7 -6
- data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +11 -10
- data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +22 -17
- data/lib/super_diff/rspec/operation_tree_builders.rb +4 -4
- data/lib/super_diff/rspec.rb +11 -13
- data/lib/super_diff/tiered_lines_elider.rb +87 -115
- data/lib/super_diff/tiered_lines_formatter.rb +5 -9
- data/lib/super_diff/version.rb +1 -1
- data/lib/super_diff.rb +4 -9
- data/spec/examples.txt +493 -485
- data/spec/integration/rails/active_record_spec.rb +3 -1
- data/spec/integration/rails/engines_spec.rb +20 -0
- data/spec/integration/rails/hash_with_indifferent_access_spec.rb +3 -1
- data/spec/integration/rspec/be_falsey_matcher_spec.rb +40 -35
- data/spec/integration/rspec/be_matcher_spec.rb +360 -320
- data/spec/integration/rspec/be_nil_matcher_spec.rb +38 -34
- data/spec/integration/rspec/be_predicate_matcher_spec.rb +376 -359
- data/spec/integration/rspec/be_truthy_matcher_spec.rb +38 -33
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +242 -239
- data/spec/integration/rspec/eq_matcher_spec.rb +595 -557
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +294 -286
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +291 -297
- data/spec/integration/rspec/include_matcher_spec.rb +317 -215
- data/spec/integration/rspec/match_array_matcher_spec.rb +276 -273
- data/spec/integration/rspec/match_matcher_spec.rb +847 -834
- data/spec/integration/rspec/raise_error_matcher_spec.rb +468 -453
- data/spec/integration/rspec/respond_to_matcher_spec.rb +702 -697
- data/spec/integration/rspec/third_party_matcher_spec.rb +142 -138
- data/spec/integration/rspec/unhandled_errors_spec.rb +88 -84
- data/spec/spec_helper.rb +17 -20
- data/spec/support/command_runner.rb +34 -57
- data/spec/support/integration/helpers.rb +35 -28
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +28 -23
- data/spec/support/integration/test_programs/base.rb +12 -17
- data/spec/support/integration/test_programs/plain.rb +6 -0
- data/spec/support/integration/test_programs/rspec_active_record.rb +4 -1
- data/spec/support/integration/test_programs/rspec_active_support.rb +4 -1
- data/spec/support/integration/test_programs/rspec_rails.rb +4 -1
- data/spec/support/integration/test_programs/rspec_rails_engine.rb +30 -0
- data/spec/support/models/active_record/person.rb +6 -4
- data/spec/support/models/active_record/shipping_address.rb +9 -10
- data/spec/support/models/customer.rb +2 -4
- data/spec/support/models/player.rb +3 -6
- data/spec/support/models/shipping_address.rb +4 -13
- data/spec/support/shared_examples/active_record.rb +232 -214
- data/spec/support/shared_examples/active_support.rb +53 -51
- data/spec/support/shared_examples/elided_diffs.rb +405 -381
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +424 -388
- data/spec/support/shared_examples/key.rb +123 -0
- data/spec/support/unit/helpers.rb +1 -3
- data/spec/support/unit/matchers/match_output.rb +12 -13
- data/spec/unit/active_record/object_inspection_spec.rb +222 -206
- data/spec/unit/equality_matchers/main_spec.rb +1049 -984
- data/spec/unit/helpers_spec.rb +14 -21
- data/spec/unit/operation_tree_flatteners/array_spec.rb +557 -524
- data/spec/unit/operation_tree_flatteners/custom_object_spec.rb +619 -601
- data/spec/unit/operation_tree_flatteners/default_object_spec.rb +619 -621
- data/spec/unit/operation_tree_flatteners/hash_spec.rb +595 -556
- data/spec/unit/operation_tree_flatteners/multiline_string_spec.rb +102 -92
- data/spec/unit/rspec/matchers/be_compared_to_spec.rb +3 -3
- data/spec/unit/rspec/matchers/be_predicate_spec.rb +3 -3
- data/spec/unit/rspec/matchers/contain_exactly_spec.rb +1 -1
- data/spec/unit/rspec/matchers/have_attributes_spec.rb +1 -1
- data/spec/unit/rspec/matchers/have_predicate_spec.rb +2 -2
- data/spec/unit/rspec/matchers/include_spec.rb +2 -2
- data/spec/unit/rspec/matchers/match_array_spec.rb +2 -2
- data/spec/unit/rspec/matchers/raise_error_spec.rb +5 -5
- data/spec/unit/rspec/matchers/respond_to_spec.rb +23 -16
- data/spec/unit/rspec/object_inspection_spec.rb +349 -324
- data/spec/unit/super_diff_spec.rb +1542 -1449
- data/spec/unit/tiered_lines_elider_spec.rb +3508 -3536
- data/spec/unit/tiered_lines_formatter_spec.rb +54 -116
- data/super_diff.gemspec +13 -12
- metadata +73 -73
- 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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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 =
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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 =
|
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
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
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 =
|
122
|
-
|
123
|
-
|
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
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
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 =
|
144
|
-
|
145
|
-
|
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
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
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 =
|
166
|
-
|
167
|
-
|
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
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
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
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
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 =
|
199
|
-
|
200
|
-
|
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
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
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
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
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
|
-
|
250
|
-
|
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])
|
254
|
-
|
255
|
-
|
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
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
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
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
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 =
|
298
|
-
|
299
|
-
|
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 =
|
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
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
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
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
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 =
|
345
|
-
|
346
|
-
|
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
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
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
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
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 =
|
381
|
-
|
382
|
-
|
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
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
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
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
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 =
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
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
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
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
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
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 =
|
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
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
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
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
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 =
|
497
|
-
expected: [
|
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
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
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
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
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 =
|
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
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
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
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
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 =
|
565
|
-
expected: [
|
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
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
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
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
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 =
|
599
|
-
|
600
|
-
|
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
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
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
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
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 =
|
639
|
-
|
640
|
-
|
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
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
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
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
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 =
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
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
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
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
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
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 =
|
723
|
-
|
724
|
-
[
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
class: "header",
|
729
|
-
|
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
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
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
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
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
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
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 =
|
796
|
-
|
797
|
-
|
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 =
|
807
|
-
|
808
|
-
|
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
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
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
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
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 =
|
842
|
-
|
843
|
-
|
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
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
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
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
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 =
|
877
|
-
|
878
|
-
|
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
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
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
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
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 =
|
912
|
-
|
913
|
-
|
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
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
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
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
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 =
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
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
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
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
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
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 =
|
994
|
-
|
995
|
-
|
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
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
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
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
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 =
|
1028
|
-
|
1029
|
-
|
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
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
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
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
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 =
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
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
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
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
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
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 =
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
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
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
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
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
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 =
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
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
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
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
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
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 =
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
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
|
-
|
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
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
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
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
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 =
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
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
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
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
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
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 =
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
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
|
-
|
1397
|
-
{
|
1398
|
-
name: "
|
1399
|
-
|
1400
|
-
|
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
|
-
|
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
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
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
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
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
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
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
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
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 =
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
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
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
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
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
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
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
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
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
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
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
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
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
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 = [
|
1692
|
+
expected = %w[a b c]
|
1628
1693
|
expected.insert(1, expected)
|
1629
|
-
actual = [
|
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
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
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
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
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 = [
|
1665
|
-
actual = [
|
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
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
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
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
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: [
|
1702
|
-
actual = { foo: [
|
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
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
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
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
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: [
|
1741
|
-
actual = { foo: [
|
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
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
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
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
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)
|