super_diff 0.9.0 → 0.11.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 +22 -18
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +14 -7
- 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 +20 -11
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/ordered_options.rb +46 -0
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +5 -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 -10
- 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/date_like.rb +15 -0
- data/lib/super_diff/differs/default_object.rb +1 -1
- data/lib/super_diff/differs/defaults.rb +2 -1
- data/lib/super_diff/differs/main.rb +2 -13
- data/lib/super_diff/differs.rb +1 -0
- 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 +2 -6
- 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 +64 -73
- data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +29 -14
- data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +17 -13
- data/lib/super_diff/object_inspection/inspection_tree_builders/date_like.rb +51 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +43 -27
- data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +2 -1
- data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +35 -18
- data/lib/super_diff/object_inspection/inspection_tree_builders/primitive.rb +3 -5
- data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +30 -36
- data/lib/super_diff/object_inspection/inspection_tree_builders.rb +13 -9
- data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +11 -22
- 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/date_like.rb +15 -0
- data/lib/super_diff/operation_tree_builders/default_object.rb +29 -21
- data/lib/super_diff/operation_tree_builders/defaults.rb +1 -1
- 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 +2 -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 +2 -10
- 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 +180 -123
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_containing_exactly.rb +14 -7
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +21 -13
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +35 -36
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/generic_describable_matcher.rb +19 -0
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +21 -15
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +11 -10
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +11 -10
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/object_having_attributes.rb +14 -7
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/value_within.rb +10 -11
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +13 -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 +17 -18
- 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 +13 -9
- data/spec/examples.txt +541 -483
- data/spec/integration/rails/active_record_spec.rb +3 -1
- data/spec/integration/rails/engines_spec.rb +25 -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 +257 -254
- data/spec/integration/rspec/eq_matcher_spec.rb +695 -585
- data/spec/integration/rspec/generic_describable_matchers_spec.rb +177 -0
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +312 -304
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +291 -297
- data/spec/integration/rspec/include_matcher_spec.rb +327 -225
- data/spec/integration/rspec/magic_metadata_spec.rb +51 -0
- data/spec/integration/rspec/match_array_matcher_spec.rb +294 -291
- data/spec/integration/rspec/match_matcher_spec.rb +916 -903
- data/spec/integration/rspec/raise_error_matcher_spec.rb +1208 -449
- 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/internal/log/test.log +0 -0
- data/spec/spec_helper.rb +20 -20
- data/spec/support/command_runner.rb +34 -57
- data/spec/support/integration/helpers.rb +44 -32
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +28 -23
- data/spec/support/integration/matchers.rb +34 -0
- data/spec/support/integration/test_programs/base.rb +17 -22
- 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 +20 -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 +258 -240
- data/spec/support/shared_examples/active_support.rb +174 -51
- data/spec/support/shared_examples/elided_diffs.rb +447 -423
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +500 -464
- 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/active_support/object_inspection_spec.rb +170 -0
- 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 +43 -11
- data/spec/unit/rspec/matchers/respond_to_spec.rb +23 -16
- data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +91 -0
- data/spec/unit/rspec/object_inspection_spec.rb +351 -326
- data/spec/unit/super_diff_spec.rb +1594 -1437
- 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 +88 -75
- data/lib/super_diff/errors/no_diff_formatter_available_error.rb +0 -21
- data/lib/super_diff/errors/no_operational_sequencer_available_error.rb +0 -22
- data/spec/tmp/warnings_logger/all_warnings.txt +0 -2
@@ -12,19 +12,22 @@ RSpec.describe SuperDiff, type: :unit do
|
|
12
12
|
|
13
13
|
context "given as_lines: true" do
|
14
14
|
it "returns nil wrapped in a single Line" do
|
15
|
-
tiered_lines =
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
indentation_level: 1,
|
20
|
-
)
|
21
|
-
expect(tiered_lines).to match([
|
22
|
-
an_object_having_attributes(
|
15
|
+
tiered_lines =
|
16
|
+
described_class.inspect_object(
|
17
|
+
nil,
|
18
|
+
as_lines: true,
|
23
19
|
type: :delete,
|
24
|
-
indentation_level: 1
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
indentation_level: 1
|
21
|
+
)
|
22
|
+
expect(tiered_lines).to match(
|
23
|
+
[
|
24
|
+
an_object_having_attributes(
|
25
|
+
type: :delete,
|
26
|
+
indentation_level: 1,
|
27
|
+
value: "nil"
|
28
|
+
)
|
29
|
+
]
|
30
|
+
)
|
28
31
|
end
|
29
32
|
end
|
30
33
|
end
|
@@ -39,19 +42,22 @@ RSpec.describe SuperDiff, type: :unit do
|
|
39
42
|
|
40
43
|
context "given as_lines: true" do
|
41
44
|
it "returns true wrapped in a single Line" do
|
42
|
-
tiered_lines =
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
indentation_level: 1,
|
47
|
-
)
|
48
|
-
expect(tiered_lines).to match([
|
49
|
-
an_object_having_attributes(
|
45
|
+
tiered_lines =
|
46
|
+
described_class.inspect_object(
|
47
|
+
true,
|
48
|
+
as_lines: true,
|
50
49
|
type: :delete,
|
51
|
-
indentation_level: 1
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
indentation_level: 1
|
51
|
+
)
|
52
|
+
expect(tiered_lines).to match(
|
53
|
+
[
|
54
|
+
an_object_having_attributes(
|
55
|
+
type: :delete,
|
56
|
+
indentation_level: 1,
|
57
|
+
value: "true"
|
58
|
+
)
|
59
|
+
]
|
60
|
+
)
|
55
61
|
end
|
56
62
|
end
|
57
63
|
end
|
@@ -66,19 +72,22 @@ RSpec.describe SuperDiff, type: :unit do
|
|
66
72
|
|
67
73
|
context "given as_lines: true" do
|
68
74
|
it "returns false wrapped in a single Line" do
|
69
|
-
tiered_lines =
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
indentation_level: 1,
|
74
|
-
)
|
75
|
-
expect(tiered_lines).to match([
|
76
|
-
an_object_having_attributes(
|
75
|
+
tiered_lines =
|
76
|
+
described_class.inspect_object(
|
77
|
+
false,
|
78
|
+
as_lines: true,
|
77
79
|
type: :delete,
|
78
|
-
indentation_level: 1
|
79
|
-
|
80
|
-
|
81
|
-
|
80
|
+
indentation_level: 1
|
81
|
+
)
|
82
|
+
expect(tiered_lines).to match(
|
83
|
+
[
|
84
|
+
an_object_having_attributes(
|
85
|
+
type: :delete,
|
86
|
+
indentation_level: 1,
|
87
|
+
value: "false"
|
88
|
+
)
|
89
|
+
]
|
90
|
+
)
|
82
91
|
end
|
83
92
|
end
|
84
93
|
end
|
@@ -93,19 +102,22 @@ RSpec.describe SuperDiff, type: :unit do
|
|
93
102
|
|
94
103
|
context "given as_lines: true" do
|
95
104
|
it "returns the number wrapped in a single Line" do
|
96
|
-
tiered_lines =
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
indentation_level: 1,
|
101
|
-
)
|
102
|
-
expect(tiered_lines).to match([
|
103
|
-
an_object_having_attributes(
|
105
|
+
tiered_lines =
|
106
|
+
described_class.inspect_object(
|
107
|
+
3,
|
108
|
+
as_lines: true,
|
104
109
|
type: :delete,
|
105
|
-
indentation_level: 1
|
106
|
-
|
107
|
-
|
108
|
-
|
110
|
+
indentation_level: 1
|
111
|
+
)
|
112
|
+
expect(tiered_lines).to match(
|
113
|
+
[
|
114
|
+
an_object_having_attributes(
|
115
|
+
type: :delete,
|
116
|
+
indentation_level: 1,
|
117
|
+
value: "3"
|
118
|
+
)
|
119
|
+
]
|
120
|
+
)
|
109
121
|
end
|
110
122
|
end
|
111
123
|
end
|
@@ -120,19 +132,22 @@ RSpec.describe SuperDiff, type: :unit do
|
|
120
132
|
|
121
133
|
context "given as_lines: true" do
|
122
134
|
it "returns an inspected version of the symbol wrapped in a single Line" do
|
123
|
-
tiered_lines =
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
indentation_level: 1,
|
128
|
-
)
|
129
|
-
expect(tiered_lines).to match([
|
130
|
-
an_object_having_attributes(
|
135
|
+
tiered_lines =
|
136
|
+
described_class.inspect_object(
|
137
|
+
:foo,
|
138
|
+
as_lines: true,
|
131
139
|
type: :delete,
|
132
|
-
indentation_level: 1
|
133
|
-
|
134
|
-
|
135
|
-
|
140
|
+
indentation_level: 1
|
141
|
+
)
|
142
|
+
expect(tiered_lines).to match(
|
143
|
+
[
|
144
|
+
an_object_having_attributes(
|
145
|
+
type: :delete,
|
146
|
+
indentation_level: 1,
|
147
|
+
value: ":foo"
|
148
|
+
)
|
149
|
+
]
|
150
|
+
)
|
136
151
|
end
|
137
152
|
end
|
138
153
|
end
|
@@ -147,19 +162,22 @@ RSpec.describe SuperDiff, type: :unit do
|
|
147
162
|
|
148
163
|
context "given as_lines: true" do
|
149
164
|
it "returns an inspected version of the regex wrapped in a single Line" do
|
150
|
-
tiered_lines =
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
indentation_level: 1,
|
155
|
-
)
|
156
|
-
expect(tiered_lines).to match([
|
157
|
-
an_object_having_attributes(
|
165
|
+
tiered_lines =
|
166
|
+
described_class.inspect_object(
|
167
|
+
/foo/,
|
168
|
+
as_lines: true,
|
158
169
|
type: :delete,
|
159
|
-
indentation_level: 1
|
160
|
-
|
161
|
-
|
162
|
-
|
170
|
+
indentation_level: 1
|
171
|
+
)
|
172
|
+
expect(tiered_lines).to match(
|
173
|
+
[
|
174
|
+
an_object_having_attributes(
|
175
|
+
type: :delete,
|
176
|
+
indentation_level: 1,
|
177
|
+
value: "/foo/"
|
178
|
+
)
|
179
|
+
]
|
180
|
+
)
|
163
181
|
end
|
164
182
|
end
|
165
183
|
end
|
@@ -174,19 +192,22 @@ RSpec.describe SuperDiff, type: :unit do
|
|
174
192
|
|
175
193
|
context "given as_lines: true" do
|
176
194
|
it "returns an inspected version of the string wrapped in a single Line" do
|
177
|
-
tiered_lines =
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
indentation_level: 1,
|
182
|
-
)
|
183
|
-
expect(tiered_lines).to match([
|
184
|
-
an_object_having_attributes(
|
195
|
+
tiered_lines =
|
196
|
+
described_class.inspect_object(
|
197
|
+
"Marty",
|
198
|
+
as_lines: true,
|
185
199
|
type: :delete,
|
186
|
-
indentation_level: 1
|
187
|
-
|
188
|
-
|
189
|
-
|
200
|
+
indentation_level: 1
|
201
|
+
)
|
202
|
+
expect(tiered_lines).to match(
|
203
|
+
[
|
204
|
+
an_object_having_attributes(
|
205
|
+
type: :delete,
|
206
|
+
indentation_level: 1,
|
207
|
+
value: %("Marty")
|
208
|
+
)
|
209
|
+
]
|
210
|
+
)
|
190
211
|
end
|
191
212
|
end
|
192
213
|
end
|
@@ -195,31 +216,36 @@ RSpec.describe SuperDiff, type: :unit do
|
|
195
216
|
context "that does not contain color codes" do
|
196
217
|
context "given as_lines: false" do
|
197
218
|
it "returns an inspected version of the string, with newline characters escaped" do
|
198
|
-
string =
|
199
|
-
|
200
|
-
|
201
|
-
|
219
|
+
string =
|
220
|
+
described_class.inspect_object(
|
221
|
+
"This is a line\nAnd that's a line\nAnd there's a line too",
|
222
|
+
as_lines: false
|
223
|
+
)
|
202
224
|
expect(string).to eq(
|
203
|
-
%("This is a line\\nAnd that's a line\\nAnd there's a line too")
|
225
|
+
%("This is a line\\nAnd that's a line\\nAnd there's a line too")
|
204
226
|
)
|
205
227
|
end
|
206
228
|
end
|
207
229
|
|
208
230
|
context "given as_lines: true" do
|
209
231
|
it "returns an inspected version of the string, with newline characters escaped, wrapped in a Line" do
|
210
|
-
tiered_lines =
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
indentation_level: 1,
|
215
|
-
)
|
216
|
-
expect(tiered_lines).to match([
|
217
|
-
an_object_having_attributes(
|
232
|
+
tiered_lines =
|
233
|
+
described_class.inspect_object(
|
234
|
+
"This is a line\nAnd that's a line\nAnd there's a line too",
|
235
|
+
as_lines: true,
|
218
236
|
type: :delete,
|
219
|
-
indentation_level: 1
|
220
|
-
|
221
|
-
|
222
|
-
|
237
|
+
indentation_level: 1
|
238
|
+
)
|
239
|
+
expect(tiered_lines).to match(
|
240
|
+
[
|
241
|
+
an_object_having_attributes(
|
242
|
+
type: :delete,
|
243
|
+
indentation_level: 1,
|
244
|
+
value:
|
245
|
+
%("This is a line\\nAnd that's a line\\nAnd there's a line too")
|
246
|
+
)
|
247
|
+
]
|
248
|
+
)
|
223
249
|
end
|
224
250
|
end
|
225
251
|
end
|
@@ -233,29 +259,27 @@ RSpec.describe SuperDiff, type: :unit do
|
|
233
259
|
red: 3,
|
234
260
|
green: 8,
|
235
261
|
blue: 4,
|
236
|
-
layer: :foreground
|
262
|
+
layer: :foreground
|
237
263
|
),
|
238
264
|
SuperDiff::Csi::TwentyFourBitColor.new(
|
239
265
|
red: 47,
|
240
266
|
green: 164,
|
241
267
|
blue: 59,
|
242
|
-
layer: :foreground
|
243
|
-
)
|
268
|
+
layer: :foreground
|
269
|
+
)
|
244
270
|
]
|
245
271
|
string_to_inspect = [
|
246
272
|
colored("This is a line", colors[0]),
|
247
273
|
colored("And that's a line", colors[1]),
|
248
|
-
colored("And there's a line too", colors[2])
|
274
|
+
colored("And there's a line too", colors[2])
|
249
275
|
].join("\n")
|
250
276
|
|
251
|
-
inspection =
|
252
|
-
string_to_inspect,
|
253
|
-
as_lines: false,
|
254
|
-
)
|
277
|
+
inspection =
|
278
|
+
described_class.inspect_object(string_to_inspect, as_lines: false)
|
255
279
|
# TODO: Figure out how to represent a colorized string inside of an
|
256
280
|
# already colorized string
|
257
281
|
expect(inspection).to eq(
|
258
|
-
%("\\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")
|
282
|
+
%("\\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")
|
259
283
|
)
|
260
284
|
end
|
261
285
|
end
|
@@ -268,36 +292,40 @@ RSpec.describe SuperDiff, type: :unit do
|
|
268
292
|
red: 3,
|
269
293
|
green: 8,
|
270
294
|
blue: 4,
|
271
|
-
layer: :foreground
|
295
|
+
layer: :foreground
|
272
296
|
),
|
273
297
|
SuperDiff::Csi::TwentyFourBitColor.new(
|
274
298
|
red: 47,
|
275
299
|
green: 164,
|
276
300
|
blue: 59,
|
277
|
-
layer: :foreground
|
278
|
-
)
|
301
|
+
layer: :foreground
|
302
|
+
)
|
279
303
|
]
|
280
304
|
string_to_inspect = [
|
281
305
|
colored("This is a line", colors[0]),
|
282
306
|
colored("And that's a line", colors[1]),
|
283
|
-
colored("And there's a line too", colors[2])
|
307
|
+
colored("And there's a line too", colors[2])
|
284
308
|
].join("\n")
|
285
309
|
|
286
|
-
tiered_lines =
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
310
|
+
tiered_lines =
|
311
|
+
described_class.inspect_object(
|
312
|
+
string_to_inspect,
|
313
|
+
as_lines: true,
|
314
|
+
type: :delete,
|
315
|
+
indentation_level: 1
|
316
|
+
)
|
292
317
|
# TODO: Figure out how to represent a colorized string inside of an
|
293
318
|
# already colorized string
|
294
|
-
expect(tiered_lines).to match(
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
319
|
+
expect(tiered_lines).to match(
|
320
|
+
[
|
321
|
+
an_object_having_attributes(
|
322
|
+
type: :delete,
|
323
|
+
indentation_level: 1,
|
324
|
+
value:
|
325
|
+
%("\\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")
|
326
|
+
)
|
327
|
+
]
|
328
|
+
)
|
301
329
|
end
|
302
330
|
end
|
303
331
|
end
|
@@ -307,54 +335,55 @@ RSpec.describe SuperDiff, type: :unit do
|
|
307
335
|
context "containing only primitive values" do
|
308
336
|
context "given as_lines: false" do
|
309
337
|
it "returns an inspected version of the array" do
|
310
|
-
string =
|
311
|
-
["foo", 2, :baz],
|
312
|
-
as_lines: false,
|
313
|
-
)
|
338
|
+
string =
|
339
|
+
described_class.inspect_object(["foo", 2, :baz], as_lines: false)
|
314
340
|
expect(string).to eq(%(["foo", 2, :baz]))
|
315
341
|
end
|
316
342
|
end
|
317
343
|
|
318
344
|
context "given as_lines: true" do
|
319
345
|
it "returns an inspected version of the array as multiple Lines" do
|
320
|
-
tiered_lines =
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
indentation_level: 1,
|
325
|
-
)
|
326
|
-
expect(tiered_lines).to match([
|
327
|
-
an_object_having_attributes(
|
328
|
-
type: :delete,
|
329
|
-
indentation_level: 1,
|
330
|
-
value: %([),
|
331
|
-
collection_bookend: :open,
|
332
|
-
),
|
333
|
-
an_object_having_attributes(
|
334
|
-
type: :delete,
|
335
|
-
indentation_level: 2,
|
336
|
-
value: %("foo"),
|
337
|
-
add_comma: true,
|
338
|
-
),
|
339
|
-
an_object_having_attributes(
|
340
|
-
type: :delete,
|
341
|
-
indentation_level: 2,
|
342
|
-
value: %(2),
|
343
|
-
add_comma: true,
|
344
|
-
),
|
345
|
-
an_object_having_attributes(
|
346
|
-
type: :delete,
|
347
|
-
indentation_level: 2,
|
348
|
-
value: %(:baz),
|
349
|
-
add_comma: false,
|
350
|
-
),
|
351
|
-
an_object_having_attributes(
|
346
|
+
tiered_lines =
|
347
|
+
described_class.inspect_object(
|
348
|
+
["foo", 2, :baz],
|
349
|
+
as_lines: true,
|
352
350
|
type: :delete,
|
353
|
-
indentation_level: 1
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
351
|
+
indentation_level: 1
|
352
|
+
)
|
353
|
+
expect(tiered_lines).to match(
|
354
|
+
[
|
355
|
+
an_object_having_attributes(
|
356
|
+
type: :delete,
|
357
|
+
indentation_level: 1,
|
358
|
+
value: "[",
|
359
|
+
collection_bookend: :open
|
360
|
+
),
|
361
|
+
an_object_having_attributes(
|
362
|
+
type: :delete,
|
363
|
+
indentation_level: 2,
|
364
|
+
value: %("foo"),
|
365
|
+
add_comma: true
|
366
|
+
),
|
367
|
+
an_object_having_attributes(
|
368
|
+
type: :delete,
|
369
|
+
indentation_level: 2,
|
370
|
+
value: "2",
|
371
|
+
add_comma: true
|
372
|
+
),
|
373
|
+
an_object_having_attributes(
|
374
|
+
type: :delete,
|
375
|
+
indentation_level: 2,
|
376
|
+
value: ":baz",
|
377
|
+
add_comma: false
|
378
|
+
),
|
379
|
+
an_object_having_attributes(
|
380
|
+
type: :delete,
|
381
|
+
indentation_level: 1,
|
382
|
+
value: "]",
|
383
|
+
collection_bookend: :close
|
384
|
+
)
|
385
|
+
]
|
386
|
+
)
|
358
387
|
end
|
359
388
|
end
|
360
389
|
end
|
@@ -362,81 +391,77 @@ RSpec.describe SuperDiff, type: :unit do
|
|
362
391
|
context "containing other arrays" do
|
363
392
|
context "given as_lines: false" do
|
364
393
|
it "returns an inspected version of the array" do
|
365
|
-
string =
|
366
|
-
|
367
|
-
"foo",
|
368
|
-
|
369
|
-
|
370
|
-
],
|
371
|
-
as_lines: false,
|
372
|
-
)
|
394
|
+
string =
|
395
|
+
described_class.inspect_object(
|
396
|
+
["foo", %w[bar baz], "qux"],
|
397
|
+
as_lines: false
|
398
|
+
)
|
373
399
|
expect(string).to eq(%(["foo", ["bar", "baz"], "qux"]))
|
374
400
|
end
|
375
401
|
end
|
376
402
|
|
377
403
|
context "given as_lines: true" do
|
378
404
|
it "returns an inspected version of the array as multiple Lines" do
|
379
|
-
tiered_lines =
|
405
|
+
tiered_lines =
|
406
|
+
described_class.inspect_object(
|
407
|
+
["foo", %w[bar baz], "qux"],
|
408
|
+
as_lines: true,
|
409
|
+
type: :delete,
|
410
|
+
indentation_level: 1
|
411
|
+
)
|
412
|
+
expect(tiered_lines).to match(
|
380
413
|
[
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
414
|
+
an_object_having_attributes(
|
415
|
+
type: :delete,
|
416
|
+
indentation_level: 1,
|
417
|
+
value: "[",
|
418
|
+
collection_bookend: :open
|
419
|
+
),
|
420
|
+
an_object_having_attributes(
|
421
|
+
type: :delete,
|
422
|
+
indentation_level: 2,
|
423
|
+
value: %("foo"),
|
424
|
+
add_comma: true
|
425
|
+
),
|
426
|
+
an_object_having_attributes(
|
427
|
+
type: :delete,
|
428
|
+
indentation_level: 2,
|
429
|
+
value: "[",
|
430
|
+
collection_bookend: :open
|
431
|
+
),
|
432
|
+
an_object_having_attributes(
|
433
|
+
type: :delete,
|
434
|
+
indentation_level: 3,
|
435
|
+
value: %("bar"),
|
436
|
+
add_comma: true
|
437
|
+
),
|
438
|
+
an_object_having_attributes(
|
439
|
+
type: :delete,
|
440
|
+
indentation_level: 3,
|
441
|
+
value: %("baz"),
|
442
|
+
add_comma: false
|
443
|
+
),
|
444
|
+
an_object_having_attributes(
|
445
|
+
type: :delete,
|
446
|
+
indentation_level: 2,
|
447
|
+
value: "]",
|
448
|
+
add_comma: true,
|
449
|
+
collection_bookend: :close
|
450
|
+
),
|
451
|
+
an_object_having_attributes(
|
452
|
+
type: :delete,
|
453
|
+
indentation_level: 2,
|
454
|
+
value: %("qux"),
|
455
|
+
add_comma: false
|
456
|
+
),
|
457
|
+
an_object_having_attributes(
|
458
|
+
type: :delete,
|
459
|
+
indentation_level: 1,
|
460
|
+
value: "]",
|
461
|
+
collection_bookend: :close
|
462
|
+
)
|
463
|
+
]
|
388
464
|
)
|
389
|
-
expect(tiered_lines).to match([
|
390
|
-
an_object_having_attributes(
|
391
|
-
type: :delete,
|
392
|
-
indentation_level: 1,
|
393
|
-
value: %([),
|
394
|
-
collection_bookend: :open,
|
395
|
-
),
|
396
|
-
an_object_having_attributes(
|
397
|
-
type: :delete,
|
398
|
-
indentation_level: 2,
|
399
|
-
value: %("foo"),
|
400
|
-
add_comma: true,
|
401
|
-
),
|
402
|
-
an_object_having_attributes(
|
403
|
-
type: :delete,
|
404
|
-
indentation_level: 2,
|
405
|
-
value: %([),
|
406
|
-
collection_bookend: :open,
|
407
|
-
),
|
408
|
-
an_object_having_attributes(
|
409
|
-
type: :delete,
|
410
|
-
indentation_level: 3,
|
411
|
-
value: %("bar"),
|
412
|
-
add_comma: true,
|
413
|
-
),
|
414
|
-
an_object_having_attributes(
|
415
|
-
type: :delete,
|
416
|
-
indentation_level: 3,
|
417
|
-
value: %("baz"),
|
418
|
-
add_comma: false,
|
419
|
-
),
|
420
|
-
an_object_having_attributes(
|
421
|
-
type: :delete,
|
422
|
-
indentation_level: 2,
|
423
|
-
value: %(]),
|
424
|
-
add_comma: true,
|
425
|
-
collection_bookend: :close,
|
426
|
-
),
|
427
|
-
an_object_having_attributes(
|
428
|
-
type: :delete,
|
429
|
-
indentation_level: 2,
|
430
|
-
value: %("qux"),
|
431
|
-
add_comma: false,
|
432
|
-
),
|
433
|
-
an_object_having_attributes(
|
434
|
-
type: :delete,
|
435
|
-
indentation_level: 1,
|
436
|
-
value: %(]),
|
437
|
-
collection_bookend: :close,
|
438
|
-
),
|
439
|
-
])
|
440
465
|
end
|
441
466
|
end
|
442
467
|
end
|
@@ -445,25 +470,28 @@ RSpec.describe SuperDiff, type: :unit do
|
|
445
470
|
context "given as_lines: false" do
|
446
471
|
it "returns an inspected version of the array" do
|
447
472
|
string = described_class.inspect_object([], as_lines: false)
|
448
|
-
expect(string).to eq(
|
473
|
+
expect(string).to eq("[]")
|
449
474
|
end
|
450
475
|
end
|
451
476
|
|
452
477
|
context "given as_lines: true" do
|
453
478
|
it "returns an inspected version of the array as multiple Lines" do
|
454
|
-
tiered_lines =
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
indentation_level: 1,
|
459
|
-
)
|
460
|
-
expect(tiered_lines).to match([
|
461
|
-
an_object_having_attributes(
|
479
|
+
tiered_lines =
|
480
|
+
described_class.inspect_object(
|
481
|
+
[],
|
482
|
+
as_lines: true,
|
462
483
|
type: :delete,
|
463
|
-
indentation_level: 1
|
464
|
-
|
465
|
-
|
466
|
-
|
484
|
+
indentation_level: 1
|
485
|
+
)
|
486
|
+
expect(tiered_lines).to match(
|
487
|
+
[
|
488
|
+
an_object_having_attributes(
|
489
|
+
type: :delete,
|
490
|
+
indentation_level: 1,
|
491
|
+
value: "[]"
|
492
|
+
)
|
493
|
+
]
|
494
|
+
)
|
467
495
|
end
|
468
496
|
end
|
469
497
|
end
|
@@ -474,252 +502,1035 @@ RSpec.describe SuperDiff, type: :unit do
|
|
474
502
|
context "where all of the keys are symbols" do
|
475
503
|
context "given as_lines: false" do
|
476
504
|
it "returns an inspected version of the hash" do
|
477
|
-
string =
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
505
|
+
string =
|
506
|
+
described_class.inspect_object(
|
507
|
+
# rubocop:disable Style/HashSyntax
|
508
|
+
{ foo: "bar", baz: "qux" },
|
509
|
+
# rubocop:enable Style/HashSyntax
|
510
|
+
as_lines: false
|
511
|
+
)
|
483
512
|
expect(string).to eq(%({ foo: "bar", baz: "qux" }))
|
484
513
|
end
|
485
514
|
end
|
486
515
|
|
487
516
|
context "given as_lines: true" do
|
488
517
|
it "returns an inspected version of the hash as multiple Lines" do
|
489
|
-
tiered_lines =
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
indentation_level: 1,
|
496
|
-
)
|
497
|
-
expect(tiered_lines).to match([
|
498
|
-
an_object_having_attributes(
|
499
|
-
type: :delete,
|
500
|
-
indentation_level: 1,
|
501
|
-
value: %({),
|
502
|
-
collection_bookend: :open,
|
503
|
-
),
|
504
|
-
an_object_having_attributes(
|
518
|
+
tiered_lines =
|
519
|
+
described_class.inspect_object(
|
520
|
+
# rubocop:disable Style/HashSyntax
|
521
|
+
{ foo: "bar", baz: "qux" },
|
522
|
+
# rubocop:enable Style/HashSyntax
|
523
|
+
as_lines: true,
|
505
524
|
type: :delete,
|
506
|
-
indentation_level:
|
507
|
-
|
508
|
-
|
525
|
+
indentation_level: 1
|
526
|
+
)
|
527
|
+
expect(tiered_lines).to match(
|
528
|
+
[
|
529
|
+
an_object_having_attributes(
|
530
|
+
type: :delete,
|
531
|
+
indentation_level: 1,
|
532
|
+
value: "{",
|
533
|
+
collection_bookend: :open
|
534
|
+
),
|
535
|
+
an_object_having_attributes(
|
536
|
+
type: :delete,
|
537
|
+
indentation_level: 2,
|
538
|
+
prefix: "foo: ",
|
539
|
+
value: %("bar"),
|
540
|
+
add_comma: true
|
541
|
+
),
|
542
|
+
an_object_having_attributes(
|
543
|
+
type: :delete,
|
544
|
+
indentation_level: 2,
|
545
|
+
prefix: "baz: ",
|
546
|
+
value: %("qux"),
|
547
|
+
add_comma: false
|
548
|
+
),
|
549
|
+
an_object_having_attributes(
|
550
|
+
type: :delete,
|
551
|
+
indentation_level: 1,
|
552
|
+
value: "}",
|
553
|
+
collection_bookend: :close
|
554
|
+
)
|
555
|
+
]
|
556
|
+
)
|
557
|
+
end
|
558
|
+
end
|
559
|
+
end
|
560
|
+
|
561
|
+
context "where only some of the keys are symbols" do
|
562
|
+
context "given as_lines: false" do
|
563
|
+
it "returns an inspected version of the hash" do
|
564
|
+
string =
|
565
|
+
described_class.inspect_object(
|
566
|
+
{ :foo => "bar", 2 => "baz" },
|
567
|
+
as_lines: false
|
568
|
+
)
|
569
|
+
expect(string).to eq(%({ :foo => "bar", 2 => "baz" }))
|
570
|
+
end
|
571
|
+
end
|
572
|
+
|
573
|
+
context "given as_lines: true" do
|
574
|
+
it "returns an inspected version of the hash as multiple Lines" do
|
575
|
+
tiered_lines =
|
576
|
+
described_class.inspect_object(
|
577
|
+
{ :foo => "bar", 2 => "baz" },
|
578
|
+
as_lines: true,
|
579
|
+
type: :delete,
|
580
|
+
indentation_level: 1
|
581
|
+
)
|
582
|
+
expect(tiered_lines).to match(
|
583
|
+
[
|
584
|
+
an_object_having_attributes(
|
585
|
+
type: :delete,
|
586
|
+
indentation_level: 1,
|
587
|
+
value: "{",
|
588
|
+
collection_bookend: :open
|
589
|
+
),
|
590
|
+
an_object_having_attributes(
|
591
|
+
type: :delete,
|
592
|
+
indentation_level: 2,
|
593
|
+
prefix: ":foo => ",
|
594
|
+
value: %("bar"),
|
595
|
+
add_comma: true
|
596
|
+
),
|
597
|
+
an_object_having_attributes(
|
598
|
+
type: :delete,
|
599
|
+
indentation_level: 2,
|
600
|
+
prefix: "2 => ",
|
601
|
+
value: %("baz"),
|
602
|
+
add_comma: false
|
603
|
+
),
|
604
|
+
an_object_having_attributes(
|
605
|
+
type: :delete,
|
606
|
+
indentation_level: 1,
|
607
|
+
value: "}",
|
608
|
+
collection_bookend: :close
|
609
|
+
)
|
610
|
+
]
|
611
|
+
)
|
612
|
+
end
|
613
|
+
end
|
614
|
+
end
|
615
|
+
end
|
616
|
+
|
617
|
+
context "containing other hashes" do
|
618
|
+
context "given as_lines: false" do
|
619
|
+
it "returns an inspected version of the hash" do
|
620
|
+
value_to_inspect = {
|
621
|
+
# rubocop:disable Style/HashSyntax
|
622
|
+
category_name: "Appliances",
|
623
|
+
products_by_sku: {
|
624
|
+
"EMDL-2934" => {
|
625
|
+
id: 4,
|
626
|
+
name: "Jordan Air"
|
627
|
+
},
|
628
|
+
"KDS-3912" => {
|
629
|
+
id: 8,
|
630
|
+
name: "Chevy Impala"
|
631
|
+
}
|
632
|
+
},
|
633
|
+
number_of_products: 2
|
634
|
+
# rubocop:enable Style/HashSyntax
|
635
|
+
}
|
636
|
+
string =
|
637
|
+
described_class.inspect_object(value_to_inspect, as_lines: false)
|
638
|
+
# rubocop:disable Metrics/LineLength
|
639
|
+
expect(string).to eq(
|
640
|
+
%({ category_name: "Appliances", products_by_sku: { "EMDL-2934" => { id: 4, name: "Jordan Air" }, "KDS-3912" => { id: 8, name: "Chevy Impala" } }, number_of_products: 2 })
|
641
|
+
)
|
642
|
+
# rubocop:enable Metrics/LineLength
|
643
|
+
end
|
644
|
+
end
|
645
|
+
|
646
|
+
context "given as_lines: true" do
|
647
|
+
it "returns an inspected version of the array as multiple Lines" do
|
648
|
+
value_to_inspect = {
|
649
|
+
# rubocop:disable Style/HashSyntax
|
650
|
+
category_name: "Appliances",
|
651
|
+
products_by_sku: {
|
652
|
+
"EMDL-2934" => {
|
653
|
+
id: 4,
|
654
|
+
name: "George Foreman Grill"
|
655
|
+
},
|
656
|
+
"KDS-3912" => {
|
657
|
+
id: 8,
|
658
|
+
name: "Magic Bullet"
|
659
|
+
}
|
660
|
+
},
|
661
|
+
number_of_products: 2
|
662
|
+
# rubocop:enable Style/HashSyntax
|
663
|
+
}
|
664
|
+
tiered_lines =
|
665
|
+
described_class.inspect_object(
|
666
|
+
value_to_inspect,
|
667
|
+
as_lines: true,
|
668
|
+
type: :delete,
|
669
|
+
indentation_level: 1
|
670
|
+
)
|
671
|
+
expect(tiered_lines).to match(
|
672
|
+
[
|
673
|
+
an_object_having_attributes(
|
674
|
+
type: :delete,
|
675
|
+
indentation_level: 1,
|
676
|
+
value: "{",
|
677
|
+
collection_bookend: :open
|
678
|
+
),
|
679
|
+
an_object_having_attributes(
|
680
|
+
type: :delete,
|
681
|
+
indentation_level: 2,
|
682
|
+
prefix: "category_name: ",
|
683
|
+
value: %("Appliances"),
|
684
|
+
add_comma: true
|
685
|
+
),
|
686
|
+
an_object_having_attributes(
|
687
|
+
type: :delete,
|
688
|
+
indentation_level: 2,
|
689
|
+
prefix: "products_by_sku: ",
|
690
|
+
value: "{",
|
691
|
+
collection_bookend: :open
|
692
|
+
),
|
693
|
+
an_object_having_attributes(
|
694
|
+
type: :delete,
|
695
|
+
indentation_level: 3,
|
696
|
+
prefix: %("EMDL-2934" => ),
|
697
|
+
value: "{",
|
698
|
+
collection_bookend: :open
|
699
|
+
),
|
700
|
+
an_object_having_attributes(
|
701
|
+
type: :delete,
|
702
|
+
indentation_level: 4,
|
703
|
+
prefix: "id: ",
|
704
|
+
value: "4",
|
705
|
+
add_comma: true
|
706
|
+
),
|
707
|
+
an_object_having_attributes(
|
708
|
+
type: :delete,
|
709
|
+
indentation_level: 4,
|
710
|
+
prefix: "name: ",
|
711
|
+
value: %("George Foreman Grill"),
|
712
|
+
add_comma: false
|
713
|
+
),
|
714
|
+
an_object_having_attributes(
|
715
|
+
type: :delete,
|
716
|
+
indentation_level: 3,
|
717
|
+
prefix: "",
|
718
|
+
value: "}",
|
509
719
|
add_comma: true,
|
720
|
+
collection_bookend: :close
|
721
|
+
),
|
722
|
+
an_object_having_attributes(
|
723
|
+
type: :delete,
|
724
|
+
indentation_level: 3,
|
725
|
+
prefix: %("KDS-3912" => ),
|
726
|
+
value: "{",
|
727
|
+
collection_bookend: :open
|
728
|
+
),
|
729
|
+
an_object_having_attributes(
|
730
|
+
type: :delete,
|
731
|
+
indentation_level: 4,
|
732
|
+
prefix: "id: ",
|
733
|
+
value: "8",
|
734
|
+
add_comma: true
|
735
|
+
),
|
736
|
+
an_object_having_attributes(
|
737
|
+
type: :delete,
|
738
|
+
indentation_level: 4,
|
739
|
+
prefix: "name: ",
|
740
|
+
value: %("Magic Bullet"),
|
741
|
+
add_comma: false
|
742
|
+
),
|
743
|
+
an_object_having_attributes(
|
744
|
+
type: :delete,
|
745
|
+
indentation_level: 3,
|
746
|
+
prefix: "",
|
747
|
+
value: "}",
|
748
|
+
collection_bookend: :close
|
510
749
|
),
|
511
750
|
an_object_having_attributes(
|
512
751
|
type: :delete,
|
513
752
|
indentation_level: 2,
|
514
|
-
prefix:
|
515
|
-
value:
|
516
|
-
add_comma:
|
753
|
+
prefix: "",
|
754
|
+
value: "}",
|
755
|
+
add_comma: true,
|
756
|
+
collection_bookend: :close
|
517
757
|
),
|
518
758
|
an_object_having_attributes(
|
519
759
|
type: :delete,
|
520
|
-
indentation_level:
|
521
|
-
|
522
|
-
|
760
|
+
indentation_level: 2,
|
761
|
+
prefix: "number_of_products: ",
|
762
|
+
value: "2"
|
523
763
|
),
|
524
|
-
|
525
|
-
|
764
|
+
an_object_having_attributes(
|
765
|
+
type: :delete,
|
766
|
+
indentation_level: 1,
|
767
|
+
prefix: "",
|
768
|
+
value: "}"
|
769
|
+
)
|
770
|
+
]
|
771
|
+
)
|
526
772
|
end
|
527
773
|
end
|
774
|
+
end
|
528
775
|
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
776
|
+
context "which is empty" do
|
777
|
+
context "given as_lines: false" do
|
778
|
+
it "returns an inspected version of the array" do
|
779
|
+
string = described_class.inspect_object({}, as_lines: false)
|
780
|
+
expect(string).to eq("{}")
|
781
|
+
end
|
782
|
+
end
|
783
|
+
|
784
|
+
context "given as_lines: true" do
|
785
|
+
it "returns an inspected version of the array" do
|
786
|
+
tiered_lines =
|
787
|
+
described_class.inspect_object(
|
788
|
+
{},
|
789
|
+
as_lines: true,
|
790
|
+
type: :delete,
|
791
|
+
indentation_level: 1
|
535
792
|
)
|
536
|
-
|
537
|
-
|
793
|
+
expect(tiered_lines).to match(
|
794
|
+
[
|
795
|
+
an_object_having_attributes(
|
796
|
+
type: :delete,
|
797
|
+
indentation_level: 1,
|
798
|
+
value: "{}"
|
799
|
+
)
|
800
|
+
]
|
801
|
+
)
|
538
802
|
end
|
803
|
+
end
|
804
|
+
end
|
805
|
+
end
|
539
806
|
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
807
|
+
context "given a Time object" do
|
808
|
+
context "that does not have an associated time zone" do
|
809
|
+
context "given as_lines: false" do
|
810
|
+
it "returns a representation of the time on a single line" do
|
811
|
+
inspection =
|
812
|
+
described_class.inspect_object(
|
813
|
+
Time.new(2021, 5, 5, 10, 23, 28.1234567891, "-05:00"),
|
814
|
+
as_lines: false
|
815
|
+
)
|
816
|
+
expect(inspection).to eq(
|
817
|
+
"#<Time 2021-05-05 10:23:28+(34749996836695/281474976710656) -05:00>"
|
818
|
+
)
|
819
|
+
end
|
820
|
+
end
|
821
|
+
|
822
|
+
context "given as_lines: true" do
|
823
|
+
it "returns a representation of the time across multiple lines" do
|
824
|
+
inspection =
|
825
|
+
described_class.inspect_object(
|
826
|
+
Time.new(2021, 5, 5, 10, 23, 28.1234567891, "-05:00"),
|
544
827
|
as_lines: true,
|
545
828
|
type: :delete,
|
546
|
-
indentation_level: 1
|
829
|
+
indentation_level: 1
|
547
830
|
)
|
548
|
-
|
831
|
+
expect(inspection).to match(
|
832
|
+
[
|
549
833
|
an_object_having_attributes(
|
550
834
|
type: :delete,
|
551
835
|
indentation_level: 1,
|
552
|
-
value:
|
553
|
-
|
836
|
+
value: "#<Time {",
|
837
|
+
add_comma: false,
|
838
|
+
collection_bookend: :open
|
554
839
|
),
|
555
840
|
an_object_having_attributes(
|
556
841
|
type: :delete,
|
557
842
|
indentation_level: 2,
|
558
|
-
|
559
|
-
value: %("bar"),
|
843
|
+
value: "year: 2021",
|
560
844
|
add_comma: true,
|
845
|
+
collection_bookend: nil
|
561
846
|
),
|
562
847
|
an_object_having_attributes(
|
563
848
|
type: :delete,
|
564
849
|
indentation_level: 2,
|
565
|
-
|
566
|
-
|
850
|
+
value: "month: 5",
|
851
|
+
add_comma: true,
|
852
|
+
collection_bookend: nil
|
853
|
+
),
|
854
|
+
an_object_having_attributes(
|
855
|
+
type: :delete,
|
856
|
+
indentation_level: 2,
|
857
|
+
value: "day: 5",
|
858
|
+
add_comma: true,
|
859
|
+
collection_bookend: nil
|
860
|
+
),
|
861
|
+
an_object_having_attributes(
|
862
|
+
type: :delete,
|
863
|
+
indentation_level: 2,
|
864
|
+
value: "hour: 10",
|
865
|
+
add_comma: true,
|
866
|
+
collection_bookend: nil
|
867
|
+
),
|
868
|
+
an_object_having_attributes(
|
869
|
+
type: :delete,
|
870
|
+
indentation_level: 2,
|
871
|
+
value: "min: 23",
|
872
|
+
add_comma: true,
|
873
|
+
collection_bookend: nil
|
874
|
+
),
|
875
|
+
an_object_having_attributes(
|
876
|
+
type: :delete,
|
877
|
+
indentation_level: 2,
|
878
|
+
value: "sec: 28",
|
879
|
+
add_comma: true,
|
880
|
+
collection_bookend: nil
|
881
|
+
),
|
882
|
+
an_object_having_attributes(
|
883
|
+
type: :delete,
|
884
|
+
indentation_level: 2,
|
885
|
+
value: "subsec: (34749996836695/281474976710656)",
|
886
|
+
add_comma: true,
|
887
|
+
collection_bookend: nil
|
888
|
+
),
|
889
|
+
an_object_having_attributes(
|
890
|
+
type: :delete,
|
891
|
+
indentation_level: 2,
|
892
|
+
value: "zone: nil",
|
893
|
+
add_comma: true,
|
894
|
+
collection_bookend: nil
|
895
|
+
),
|
896
|
+
an_object_having_attributes(
|
897
|
+
type: :delete,
|
898
|
+
indentation_level: 2,
|
899
|
+
value: "utc_offset: -18000",
|
567
900
|
add_comma: false,
|
901
|
+
collection_bookend: nil
|
568
902
|
),
|
569
903
|
an_object_having_attributes(
|
570
904
|
type: :delete,
|
571
905
|
indentation_level: 1,
|
572
|
-
value:
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
906
|
+
value: "}>",
|
907
|
+
add_comma: false,
|
908
|
+
collection_bookend: :close
|
909
|
+
)
|
910
|
+
]
|
911
|
+
)
|
577
912
|
end
|
578
913
|
end
|
579
914
|
end
|
580
915
|
|
581
|
-
context "
|
916
|
+
context "that has an associated time zone" do
|
917
|
+
around do |example|
|
918
|
+
ClimateControl.modify(TZ: "America/Chicago", &example)
|
919
|
+
end
|
920
|
+
|
582
921
|
context "given as_lines: false" do
|
583
|
-
it "returns
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
:number_of_products => 2,
|
592
|
-
# rubocop:enable Style/HashSyntax
|
593
|
-
}
|
594
|
-
string = described_class.inspect_object(
|
595
|
-
value_to_inspect,
|
596
|
-
as_lines: false,
|
597
|
-
)
|
598
|
-
# rubocop:disable Metrics/LineLength
|
599
|
-
expect(string).to eq(
|
600
|
-
%({ category_name: "Appliances", products_by_sku: { "EMDL-2934" => { id: 4, name: "Jordan Air" }, "KDS-3912" => { id: 8, name: "Chevy Impala" } }, number_of_products: 2 }),
|
922
|
+
it "returns a representation of the time on a single line" do
|
923
|
+
inspection =
|
924
|
+
described_class.inspect_object(
|
925
|
+
Time.new(2021, 5, 5, 10, 23, 28.1234567891),
|
926
|
+
as_lines: false
|
927
|
+
)
|
928
|
+
expect(inspection).to eq(
|
929
|
+
"#<Time 2021-05-05 10:23:28+(34749996836695/281474976710656) -05:00 (CDT)>"
|
601
930
|
)
|
602
|
-
# rubocop:enable Metrics/LineLength
|
603
931
|
end
|
604
932
|
end
|
605
933
|
|
606
934
|
context "given as_lines: true" do
|
607
|
-
it "returns
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
"EMDL-2934" => { :id => 4, :name => "George Foreman Grill" },
|
613
|
-
"KDS-3912" => { :id => 8, :name => "Magic Bullet" },
|
614
|
-
},
|
615
|
-
:number_of_products => 2,
|
616
|
-
# rubocop:enable Style/HashSyntax
|
617
|
-
}
|
618
|
-
tiered_lines = described_class.inspect_object(
|
619
|
-
value_to_inspect,
|
620
|
-
as_lines: true,
|
621
|
-
type: :delete,
|
622
|
-
indentation_level: 1,
|
623
|
-
)
|
624
|
-
expect(tiered_lines).to match([
|
625
|
-
an_object_having_attributes(
|
626
|
-
type: :delete,
|
627
|
-
indentation_level: 1,
|
628
|
-
value: %({),
|
629
|
-
collection_bookend: :open,
|
630
|
-
),
|
631
|
-
an_object_having_attributes(
|
632
|
-
type: :delete,
|
633
|
-
indentation_level: 2,
|
634
|
-
prefix: %(category_name: ),
|
635
|
-
value: %("Appliances"),
|
636
|
-
add_comma: true,
|
637
|
-
),
|
638
|
-
an_object_having_attributes(
|
639
|
-
type: :delete,
|
640
|
-
indentation_level: 2,
|
641
|
-
prefix: %(products_by_sku: ),
|
642
|
-
value: %({),
|
643
|
-
collection_bookend: :open,
|
644
|
-
),
|
645
|
-
an_object_having_attributes(
|
646
|
-
type: :delete,
|
647
|
-
indentation_level: 3,
|
648
|
-
prefix: %("EMDL-2934" => ),
|
649
|
-
value: %({),
|
650
|
-
collection_bookend: :open,
|
651
|
-
),
|
652
|
-
an_object_having_attributes(
|
653
|
-
type: :delete,
|
654
|
-
indentation_level: 4,
|
655
|
-
prefix: %(id: ),
|
656
|
-
value: %(4),
|
657
|
-
add_comma: true,
|
658
|
-
),
|
659
|
-
an_object_having_attributes(
|
660
|
-
type: :delete,
|
661
|
-
indentation_level: 4,
|
662
|
-
prefix: %(name: ),
|
663
|
-
value: %("George Foreman Grill"),
|
664
|
-
add_comma: false,
|
665
|
-
),
|
666
|
-
an_object_having_attributes(
|
667
|
-
type: :delete,
|
668
|
-
indentation_level: 3,
|
669
|
-
prefix: "",
|
670
|
-
value: %(}),
|
671
|
-
add_comma: true,
|
672
|
-
collection_bookend: :close,
|
673
|
-
),
|
674
|
-
an_object_having_attributes(
|
675
|
-
type: :delete,
|
676
|
-
indentation_level: 3,
|
677
|
-
prefix: %("KDS-3912" => ),
|
678
|
-
value: %({),
|
679
|
-
collection_bookend: :open,
|
680
|
-
),
|
681
|
-
an_object_having_attributes(
|
682
|
-
type: :delete,
|
683
|
-
indentation_level: 4,
|
684
|
-
prefix: %(id: ),
|
685
|
-
value: %(8),
|
686
|
-
add_comma: true,
|
687
|
-
),
|
688
|
-
an_object_having_attributes(
|
935
|
+
it "returns a representation of the time across multiple lines" do
|
936
|
+
inspection =
|
937
|
+
described_class.inspect_object(
|
938
|
+
Time.new(2021, 5, 5, 10, 23, 28.1234567891),
|
939
|
+
as_lines: true,
|
689
940
|
type: :delete,
|
690
|
-
indentation_level:
|
691
|
-
|
692
|
-
|
941
|
+
indentation_level: 1
|
942
|
+
)
|
943
|
+
expect(inspection).to match(
|
944
|
+
[
|
945
|
+
an_object_having_attributes(
|
946
|
+
type: :delete,
|
947
|
+
indentation_level: 1,
|
948
|
+
value: "#<Time {",
|
949
|
+
add_comma: false,
|
950
|
+
collection_bookend: :open
|
951
|
+
),
|
952
|
+
an_object_having_attributes(
|
953
|
+
type: :delete,
|
954
|
+
indentation_level: 2,
|
955
|
+
value: "year: 2021",
|
956
|
+
add_comma: true,
|
957
|
+
collection_bookend: nil
|
958
|
+
),
|
959
|
+
an_object_having_attributes(
|
960
|
+
type: :delete,
|
961
|
+
indentation_level: 2,
|
962
|
+
value: "month: 5",
|
963
|
+
add_comma: true,
|
964
|
+
collection_bookend: nil
|
965
|
+
),
|
966
|
+
an_object_having_attributes(
|
967
|
+
type: :delete,
|
968
|
+
indentation_level: 2,
|
969
|
+
value: "day: 5",
|
970
|
+
add_comma: true,
|
971
|
+
collection_bookend: nil
|
972
|
+
),
|
973
|
+
an_object_having_attributes(
|
974
|
+
type: :delete,
|
975
|
+
indentation_level: 2,
|
976
|
+
value: "hour: 10",
|
977
|
+
add_comma: true,
|
978
|
+
collection_bookend: nil
|
979
|
+
),
|
980
|
+
an_object_having_attributes(
|
981
|
+
type: :delete,
|
982
|
+
indentation_level: 2,
|
983
|
+
value: "min: 23",
|
984
|
+
add_comma: true,
|
985
|
+
collection_bookend: nil
|
986
|
+
),
|
987
|
+
an_object_having_attributes(
|
988
|
+
type: :delete,
|
989
|
+
indentation_level: 2,
|
990
|
+
value: "sec: 28",
|
991
|
+
add_comma: true,
|
992
|
+
collection_bookend: nil
|
993
|
+
),
|
994
|
+
an_object_having_attributes(
|
995
|
+
type: :delete,
|
996
|
+
indentation_level: 2,
|
997
|
+
value: "subsec: (34749996836695/281474976710656)",
|
998
|
+
add_comma: true,
|
999
|
+
collection_bookend: nil
|
1000
|
+
),
|
1001
|
+
an_object_having_attributes(
|
1002
|
+
type: :delete,
|
1003
|
+
indentation_level: 2,
|
1004
|
+
value: %(zone: "CDT"),
|
1005
|
+
add_comma: true,
|
1006
|
+
collection_bookend: nil
|
1007
|
+
),
|
1008
|
+
an_object_having_attributes(
|
1009
|
+
type: :delete,
|
1010
|
+
indentation_level: 2,
|
1011
|
+
value: "utc_offset: -18000",
|
1012
|
+
add_comma: false,
|
1013
|
+
collection_bookend: nil
|
1014
|
+
),
|
1015
|
+
an_object_having_attributes(
|
1016
|
+
type: :delete,
|
1017
|
+
indentation_level: 1,
|
1018
|
+
value: "}>",
|
1019
|
+
add_comma: false,
|
1020
|
+
collection_bookend: :close
|
1021
|
+
)
|
1022
|
+
]
|
1023
|
+
)
|
1024
|
+
end
|
1025
|
+
end
|
1026
|
+
end
|
1027
|
+
end
|
1028
|
+
|
1029
|
+
context "given a Date object" do
|
1030
|
+
context "given as_lines: false" do
|
1031
|
+
it "returns a representation of the date on a single line" do
|
1032
|
+
inspection =
|
1033
|
+
described_class.inspect_object(
|
1034
|
+
Date.new(2023, 10, 14),
|
1035
|
+
as_lines: false
|
1036
|
+
)
|
1037
|
+
expect(inspection).to eq("#<Date 2023-10-14>")
|
1038
|
+
end
|
1039
|
+
end
|
1040
|
+
|
1041
|
+
context "given as_lines: true" do
|
1042
|
+
it "returns a representation of the date across multiple lines" do
|
1043
|
+
inspection =
|
1044
|
+
described_class.inspect_object(
|
1045
|
+
Date.new(2023, 10, 14),
|
1046
|
+
as_lines: true,
|
1047
|
+
type: :delete,
|
1048
|
+
indentation_level: 1
|
1049
|
+
)
|
1050
|
+
expect(inspection).to match(
|
1051
|
+
[
|
1052
|
+
an_object_having_attributes(
|
1053
|
+
type: :delete,
|
1054
|
+
indentation_level: 1,
|
1055
|
+
value: "#<Date {",
|
693
1056
|
add_comma: false,
|
1057
|
+
collection_bookend: :open
|
694
1058
|
),
|
695
1059
|
an_object_having_attributes(
|
696
1060
|
type: :delete,
|
697
|
-
indentation_level:
|
698
|
-
|
699
|
-
|
700
|
-
collection_bookend:
|
1061
|
+
indentation_level: 2,
|
1062
|
+
value: "year: 2023",
|
1063
|
+
add_comma: true,
|
1064
|
+
collection_bookend: nil
|
701
1065
|
),
|
702
1066
|
an_object_having_attributes(
|
703
1067
|
type: :delete,
|
704
1068
|
indentation_level: 2,
|
705
|
-
|
706
|
-
value: %(}),
|
1069
|
+
value: "month: 10",
|
707
1070
|
add_comma: true,
|
708
|
-
collection_bookend:
|
1071
|
+
collection_bookend: nil
|
709
1072
|
),
|
710
1073
|
an_object_having_attributes(
|
711
1074
|
type: :delete,
|
712
1075
|
indentation_level: 2,
|
713
|
-
|
714
|
-
|
1076
|
+
value: "day: 14",
|
1077
|
+
add_comma: false,
|
1078
|
+
collection_bookend: nil
|
715
1079
|
),
|
716
1080
|
an_object_having_attributes(
|
717
1081
|
type: :delete,
|
718
1082
|
indentation_level: 1,
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
1083
|
+
value: "}>",
|
1084
|
+
add_comma: false,
|
1085
|
+
collection_bookend: :close
|
1086
|
+
)
|
1087
|
+
]
|
1088
|
+
)
|
1089
|
+
end
|
1090
|
+
end
|
1091
|
+
end
|
1092
|
+
|
1093
|
+
context "given a class" do
|
1094
|
+
context "given as_lines: false" do
|
1095
|
+
it "returns an inspected version of the object" do
|
1096
|
+
string =
|
1097
|
+
described_class.inspect_object(
|
1098
|
+
SuperDiff::Test::Person,
|
1099
|
+
as_lines: false
|
1100
|
+
)
|
1101
|
+
expect(string).to eq("SuperDiff::Test::Person")
|
1102
|
+
end
|
1103
|
+
end
|
1104
|
+
|
1105
|
+
context "given as_lines: true" do
|
1106
|
+
it "returns an inspected version of the object" do
|
1107
|
+
tiered_lines =
|
1108
|
+
described_class.inspect_object(
|
1109
|
+
SuperDiff::Test::Person,
|
1110
|
+
as_lines: true,
|
1111
|
+
type: :delete,
|
1112
|
+
indentation_level: 1
|
1113
|
+
)
|
1114
|
+
expect(tiered_lines).to match(
|
1115
|
+
[
|
1116
|
+
an_object_having_attributes(
|
1117
|
+
type: :delete,
|
1118
|
+
indentation_level: 1,
|
1119
|
+
value: "SuperDiff::Test::Person"
|
1120
|
+
)
|
1121
|
+
]
|
1122
|
+
)
|
1123
|
+
end
|
1124
|
+
end
|
1125
|
+
end
|
1126
|
+
|
1127
|
+
# TODO: Add when empty
|
1128
|
+
context "given a custom object" do
|
1129
|
+
context "containing only primitive values" do
|
1130
|
+
context "given as_lines: false" do
|
1131
|
+
it "returns an inspected version of the object" do
|
1132
|
+
string =
|
1133
|
+
described_class.inspect_object(
|
1134
|
+
SuperDiff::Test::Person.new(name: "Doc", age: 58),
|
1135
|
+
as_lines: false
|
1136
|
+
)
|
1137
|
+
expect(string).to eq(
|
1138
|
+
%(#<SuperDiff::Test::Person name: "Doc", age: 58>)
|
1139
|
+
)
|
1140
|
+
end
|
1141
|
+
end
|
1142
|
+
|
1143
|
+
context "given as_lines: true" do
|
1144
|
+
it "returns an inspected version of the object as multiple Lines" do
|
1145
|
+
tiered_lines =
|
1146
|
+
described_class.inspect_object(
|
1147
|
+
SuperDiff::Test::Person.new(name: "Doc", age: 58),
|
1148
|
+
as_lines: true,
|
1149
|
+
type: :delete,
|
1150
|
+
indentation_level: 1
|
1151
|
+
)
|
1152
|
+
expect(tiered_lines).to match(
|
1153
|
+
[
|
1154
|
+
an_object_having_attributes(
|
1155
|
+
type: :delete,
|
1156
|
+
indentation_level: 1,
|
1157
|
+
value: "#<SuperDiff::Test::Person {"
|
1158
|
+
),
|
1159
|
+
an_object_having_attributes(
|
1160
|
+
type: :delete,
|
1161
|
+
indentation_level: 2,
|
1162
|
+
prefix: "name: ",
|
1163
|
+
value: %("Doc"),
|
1164
|
+
add_comma: true
|
1165
|
+
),
|
1166
|
+
an_object_having_attributes(
|
1167
|
+
type: :delete,
|
1168
|
+
indentation_level: 2,
|
1169
|
+
prefix: "age: ",
|
1170
|
+
value: "58",
|
1171
|
+
add_comma: false
|
1172
|
+
),
|
1173
|
+
an_object_having_attributes(
|
1174
|
+
type: :delete,
|
1175
|
+
indentation_level: 1,
|
1176
|
+
value: "}>"
|
1177
|
+
)
|
1178
|
+
]
|
1179
|
+
)
|
1180
|
+
end
|
1181
|
+
end
|
1182
|
+
end
|
1183
|
+
|
1184
|
+
context "containing other custom objects" do
|
1185
|
+
context "given as_lines: false" do
|
1186
|
+
it "returns an inspected version of the object" do
|
1187
|
+
string =
|
1188
|
+
described_class.inspect_object(
|
1189
|
+
SuperDiff::Test::Customer.new(
|
1190
|
+
name: "Marty McFly",
|
1191
|
+
shipping_address:
|
1192
|
+
SuperDiff::Test::ShippingAddress.new(
|
1193
|
+
line_1: "123 Main St.",
|
1194
|
+
line_2: "",
|
1195
|
+
city: "Hill Valley",
|
1196
|
+
state: "CA",
|
1197
|
+
zip: "90382"
|
1198
|
+
),
|
1199
|
+
phone: "111-222-3333"
|
1200
|
+
),
|
1201
|
+
as_lines: false
|
1202
|
+
)
|
1203
|
+
expect(string).to eq(
|
1204
|
+
# rubocop:disable Metrics/LineLength
|
1205
|
+
%(#<SuperDiff::Test::Customer name: "Marty McFly", shipping_address: #<SuperDiff::Test::ShippingAddress line_1: "123 Main St.", line_2: "", city: "Hill Valley", state: "CA", zip: "90382">, phone: "111-222-3333">)
|
1206
|
+
# rubocop:enable Metrics/LineLength
|
1207
|
+
)
|
1208
|
+
end
|
1209
|
+
end
|
1210
|
+
|
1211
|
+
context "given as_lines: true" do
|
1212
|
+
it "returns an inspected version of the object as multiple Lines" do
|
1213
|
+
tiered_lines =
|
1214
|
+
described_class.inspect_object(
|
1215
|
+
SuperDiff::Test::Customer.new(
|
1216
|
+
name: "Marty McFly",
|
1217
|
+
shipping_address:
|
1218
|
+
SuperDiff::Test::ShippingAddress.new(
|
1219
|
+
line_1: "123 Main St.",
|
1220
|
+
line_2: "",
|
1221
|
+
city: "Hill Valley",
|
1222
|
+
state: "CA",
|
1223
|
+
zip: "90382"
|
1224
|
+
),
|
1225
|
+
phone: "111-222-3333"
|
1226
|
+
),
|
1227
|
+
as_lines: true,
|
1228
|
+
type: :delete,
|
1229
|
+
indentation_level: 1
|
1230
|
+
)
|
1231
|
+
expect(tiered_lines).to match(
|
1232
|
+
[
|
1233
|
+
an_object_having_attributes(
|
1234
|
+
type: :delete,
|
1235
|
+
indentation_level: 1,
|
1236
|
+
value: "#<SuperDiff::Test::Customer {",
|
1237
|
+
collection_bookend: :open
|
1238
|
+
),
|
1239
|
+
an_object_having_attributes(
|
1240
|
+
type: :delete,
|
1241
|
+
indentation_level: 2,
|
1242
|
+
prefix: "name: ",
|
1243
|
+
value: %("Marty McFly"),
|
1244
|
+
add_comma: true
|
1245
|
+
),
|
1246
|
+
an_object_having_attributes(
|
1247
|
+
type: :delete,
|
1248
|
+
indentation_level: 2,
|
1249
|
+
prefix: "shipping_address: ",
|
1250
|
+
value: "#<SuperDiff::Test::ShippingAddress {",
|
1251
|
+
add_comma: false,
|
1252
|
+
collection_bookend: :open
|
1253
|
+
),
|
1254
|
+
an_object_having_attributes(
|
1255
|
+
type: :delete,
|
1256
|
+
indentation_level: 3,
|
1257
|
+
prefix: "line_1: ",
|
1258
|
+
value: %("123 Main St.")
|
1259
|
+
),
|
1260
|
+
an_object_having_attributes(
|
1261
|
+
type: :delete,
|
1262
|
+
indentation_level: 3,
|
1263
|
+
prefix: "line_2: ",
|
1264
|
+
value: %(""),
|
1265
|
+
add_comma: true
|
1266
|
+
),
|
1267
|
+
an_object_having_attributes(
|
1268
|
+
type: :delete,
|
1269
|
+
indentation_level: 3,
|
1270
|
+
prefix: "city: ",
|
1271
|
+
value: %("Hill Valley"),
|
1272
|
+
add_comma: true
|
1273
|
+
),
|
1274
|
+
an_object_having_attributes(
|
1275
|
+
type: :delete,
|
1276
|
+
indentation_level: 3,
|
1277
|
+
prefix: "state: ",
|
1278
|
+
value: %("CA"),
|
1279
|
+
add_comma: true
|
1280
|
+
),
|
1281
|
+
an_object_having_attributes(
|
1282
|
+
type: :delete,
|
1283
|
+
indentation_level: 3,
|
1284
|
+
prefix: "zip: ",
|
1285
|
+
value: %("90382"),
|
1286
|
+
add_comma: false
|
1287
|
+
),
|
1288
|
+
an_object_having_attributes(
|
1289
|
+
type: :delete,
|
1290
|
+
indentation_level: 2,
|
1291
|
+
value: "}>",
|
1292
|
+
add_comma: true,
|
1293
|
+
collection_bookend: :close
|
1294
|
+
),
|
1295
|
+
an_object_having_attributes(
|
1296
|
+
type: :delete,
|
1297
|
+
indentation_level: 2,
|
1298
|
+
prefix: "phone: ",
|
1299
|
+
value: %("111-222-3333"),
|
1300
|
+
add_comma: false
|
1301
|
+
),
|
1302
|
+
an_object_having_attributes(
|
1303
|
+
type: :delete,
|
1304
|
+
indentation_level: 1,
|
1305
|
+
value: "}>",
|
1306
|
+
add_comma: false,
|
1307
|
+
collection_bookend: :close
|
1308
|
+
)
|
1309
|
+
]
|
1310
|
+
)
|
1311
|
+
end
|
1312
|
+
end
|
1313
|
+
end
|
1314
|
+
end
|
1315
|
+
|
1316
|
+
context "given a non-custom object" do
|
1317
|
+
context "containing only primitive values" do
|
1318
|
+
context "given as_lines: false" do
|
1319
|
+
it "returns an inspected version of the object" do
|
1320
|
+
string =
|
1321
|
+
described_class.inspect_object(
|
1322
|
+
SuperDiff::Test::Item.new(name: "mac and cheese", quantity: 2),
|
1323
|
+
as_lines: false
|
1324
|
+
)
|
1325
|
+
expect(string).to match(
|
1326
|
+
/\A#<SuperDiff::Test::Item:0x[a-z0-9]+ @name="mac and cheese", @quantity=2>\Z/
|
1327
|
+
)
|
1328
|
+
end
|
1329
|
+
end
|
1330
|
+
|
1331
|
+
context "given as_lines: true" do
|
1332
|
+
it "returns an inspected version of the object as multiple Lines" do
|
1333
|
+
tiered_lines =
|
1334
|
+
described_class.inspect_object(
|
1335
|
+
SuperDiff::Test::Item.new(name: "mac and cheese", quantity: 2),
|
1336
|
+
as_lines: true,
|
1337
|
+
type: :delete,
|
1338
|
+
indentation_level: 1
|
1339
|
+
)
|
1340
|
+
expect(tiered_lines).to match(
|
1341
|
+
[
|
1342
|
+
an_object_having_attributes(
|
1343
|
+
type: :delete,
|
1344
|
+
indentation_level: 1,
|
1345
|
+
value:
|
1346
|
+
a_string_matching(/#<SuperDiff::Test::Item:0x[a-f0-9]+ \{/),
|
1347
|
+
collection_bookend: :open
|
1348
|
+
),
|
1349
|
+
an_object_having_attributes(
|
1350
|
+
type: :delete,
|
1351
|
+
indentation_level: 2,
|
1352
|
+
prefix: "@name=",
|
1353
|
+
value: %("mac and cheese"),
|
1354
|
+
add_comma: true
|
1355
|
+
),
|
1356
|
+
an_object_having_attributes(
|
1357
|
+
type: :delete,
|
1358
|
+
indentation_level: 2,
|
1359
|
+
prefix: "@quantity=",
|
1360
|
+
value: "2",
|
1361
|
+
add_comma: false
|
1362
|
+
),
|
1363
|
+
an_object_having_attributes(
|
1364
|
+
type: :delete,
|
1365
|
+
indentation_level: 1,
|
1366
|
+
value: "}>",
|
1367
|
+
collection_bookend: :close
|
1368
|
+
)
|
1369
|
+
]
|
1370
|
+
)
|
1371
|
+
end
|
1372
|
+
end
|
1373
|
+
end
|
1374
|
+
|
1375
|
+
context "containing other custom objects" do
|
1376
|
+
context "given as_lines: false" do
|
1377
|
+
it "returns an inspected version of the object" do
|
1378
|
+
string =
|
1379
|
+
described_class.inspect_object(
|
1380
|
+
SuperDiff::Test::Order.new(
|
1381
|
+
[
|
1382
|
+
SuperDiff::Test::Item.new(name: "ham", quantity: 1),
|
1383
|
+
SuperDiff::Test::Item.new(name: "eggs", quantity: 2),
|
1384
|
+
SuperDiff::Test::Item.new(name: "cheese", quantity: 1)
|
1385
|
+
]
|
1386
|
+
),
|
1387
|
+
as_lines: false
|
1388
|
+
)
|
1389
|
+
expect(string).to match(
|
1390
|
+
# rubocop:disable Metrics/LineLength
|
1391
|
+
/\A#<SuperDiff::Test::Order:0x[a-z0-9]+ @items=\[#<SuperDiff::Test::Item:0x[a-z0-9]+ @name="ham", @quantity=1>, #<SuperDiff::Test::Item:0x[a-z0-9]+ @name="eggs", @quantity=2>, #<SuperDiff::Test::Item:0x[a-z0-9]+ @name="cheese", @quantity=1>\]>\Z/
|
1392
|
+
# rubocop:enable Metrics/LineLength
|
1393
|
+
)
|
1394
|
+
end
|
1395
|
+
end
|
1396
|
+
|
1397
|
+
context "given as_lines: true" do
|
1398
|
+
it "returns an inspected version of the object as multiple Lines" do
|
1399
|
+
tiered_lines =
|
1400
|
+
described_class.inspect_object(
|
1401
|
+
SuperDiff::Test::Order.new(
|
1402
|
+
[
|
1403
|
+
SuperDiff::Test::Item.new(name: "ham", quantity: 1),
|
1404
|
+
SuperDiff::Test::Item.new(name: "eggs", quantity: 2),
|
1405
|
+
SuperDiff::Test::Item.new(name: "cheese", quantity: 1)
|
1406
|
+
]
|
1407
|
+
),
|
1408
|
+
as_lines: true,
|
1409
|
+
type: :delete,
|
1410
|
+
indentation_level: 1
|
1411
|
+
)
|
1412
|
+
expect(tiered_lines).to match(
|
1413
|
+
[
|
1414
|
+
an_object_having_attributes(
|
1415
|
+
type: :delete,
|
1416
|
+
indentation_level: 1,
|
1417
|
+
value:
|
1418
|
+
a_string_matching(
|
1419
|
+
/#<SuperDiff::Test::Order:0x[a-f0-9]+ \{/
|
1420
|
+
),
|
1421
|
+
collection_bookend: :open
|
1422
|
+
),
|
1423
|
+
an_object_having_attributes(
|
1424
|
+
type: :delete,
|
1425
|
+
indentation_level: 2,
|
1426
|
+
prefix: "@items=",
|
1427
|
+
value: "[",
|
1428
|
+
add_comma: false,
|
1429
|
+
collection_bookend: :open
|
1430
|
+
),
|
1431
|
+
an_object_having_attributes(
|
1432
|
+
type: :delete,
|
1433
|
+
indentation_level: 3,
|
1434
|
+
value:
|
1435
|
+
a_string_matching(/#<SuperDiff::Test::Item:0x[a-f0-9]+ \{/),
|
1436
|
+
add_comma: false,
|
1437
|
+
collection_bookend: :open
|
1438
|
+
),
|
1439
|
+
an_object_having_attributes(
|
1440
|
+
type: :delete,
|
1441
|
+
indentation_level: 4,
|
1442
|
+
prefix: "@name=",
|
1443
|
+
value: %("ham"),
|
1444
|
+
add_comma: true
|
1445
|
+
),
|
1446
|
+
an_object_having_attributes(
|
1447
|
+
type: :delete,
|
1448
|
+
indentation_level: 4,
|
1449
|
+
prefix: "@quantity=",
|
1450
|
+
value: "1",
|
1451
|
+
add_comma: false
|
1452
|
+
),
|
1453
|
+
an_object_having_attributes(
|
1454
|
+
type: :delete,
|
1455
|
+
indentation_level: 3,
|
1456
|
+
value: "}>",
|
1457
|
+
add_comma: true,
|
1458
|
+
collection_bookend: :close
|
1459
|
+
),
|
1460
|
+
an_object_having_attributes(
|
1461
|
+
type: :delete,
|
1462
|
+
indentation_level: 3,
|
1463
|
+
value:
|
1464
|
+
a_string_matching(/#<SuperDiff::Test::Item:0x[a-f0-9]+ \{/),
|
1465
|
+
add_comma: false,
|
1466
|
+
collection_bookend: :open
|
1467
|
+
),
|
1468
|
+
an_object_having_attributes(
|
1469
|
+
type: :delete,
|
1470
|
+
indentation_level: 4,
|
1471
|
+
prefix: "@name=",
|
1472
|
+
value: %("eggs"),
|
1473
|
+
add_comma: true
|
1474
|
+
),
|
1475
|
+
an_object_having_attributes(
|
1476
|
+
type: :delete,
|
1477
|
+
indentation_level: 4,
|
1478
|
+
prefix: "@quantity=",
|
1479
|
+
value: "2",
|
1480
|
+
add_comma: false
|
1481
|
+
),
|
1482
|
+
an_object_having_attributes(
|
1483
|
+
type: :delete,
|
1484
|
+
indentation_level: 3,
|
1485
|
+
value: "}>",
|
1486
|
+
add_comma: true,
|
1487
|
+
collection_bookend: :close
|
1488
|
+
),
|
1489
|
+
an_object_having_attributes(
|
1490
|
+
type: :delete,
|
1491
|
+
indentation_level: 3,
|
1492
|
+
value:
|
1493
|
+
a_string_matching(/#<SuperDiff::Test::Item:0x[a-f0-9]+ \{/),
|
1494
|
+
add_comma: false,
|
1495
|
+
collection_bookend: :open
|
1496
|
+
),
|
1497
|
+
an_object_having_attributes(
|
1498
|
+
type: :delete,
|
1499
|
+
indentation_level: 4,
|
1500
|
+
prefix: "@name=",
|
1501
|
+
value: %("cheese"),
|
1502
|
+
add_comma: true
|
1503
|
+
),
|
1504
|
+
an_object_having_attributes(
|
1505
|
+
type: :delete,
|
1506
|
+
indentation_level: 4,
|
1507
|
+
prefix: "@quantity=",
|
1508
|
+
value: "1",
|
1509
|
+
add_comma: false
|
1510
|
+
),
|
1511
|
+
an_object_having_attributes(
|
1512
|
+
type: :delete,
|
1513
|
+
indentation_level: 3,
|
1514
|
+
value: "}>",
|
1515
|
+
add_comma: false,
|
1516
|
+
collection_bookend: :close
|
1517
|
+
),
|
1518
|
+
an_object_having_attributes(
|
1519
|
+
type: :delete,
|
1520
|
+
indentation_level: 2,
|
1521
|
+
value: "]",
|
1522
|
+
add_comma: false,
|
1523
|
+
collection_bookend: :close
|
1524
|
+
),
|
1525
|
+
an_object_having_attributes(
|
1526
|
+
type: :delete,
|
1527
|
+
indentation_level: 1,
|
1528
|
+
value: "}>",
|
1529
|
+
add_comma: false,
|
1530
|
+
collection_bookend: :close
|
1531
|
+
)
|
1532
|
+
]
|
1533
|
+
)
|
723
1534
|
end
|
724
1535
|
end
|
725
1536
|
end
|
@@ -727,1166 +1538,509 @@ RSpec.describe SuperDiff, type: :unit do
|
|
727
1538
|
context "which is empty" do
|
728
1539
|
context "given as_lines: false" do
|
729
1540
|
it "returns an inspected version of the array" do
|
730
|
-
string =
|
731
|
-
|
1541
|
+
string =
|
1542
|
+
described_class.inspect_object(
|
1543
|
+
SuperDiff::Test::EmptyClass.new,
|
1544
|
+
as_lines: false
|
1545
|
+
)
|
1546
|
+
expect(string).to match(
|
1547
|
+
/#<SuperDiff::Test::EmptyClass:0x[a-z0-9]+>/
|
1548
|
+
)
|
732
1549
|
end
|
733
1550
|
end
|
734
1551
|
|
735
1552
|
context "given as_lines: true" do
|
736
1553
|
it "returns an inspected version of the array" do
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
indentation_level: 1,
|
742
|
-
)
|
743
|
-
expect(tiered_lines).to match([
|
744
|
-
an_object_having_attributes(
|
1554
|
+
inspection =
|
1555
|
+
described_class.inspect_object(
|
1556
|
+
SuperDiff::Test::EmptyClass.new,
|
1557
|
+
as_lines: true,
|
745
1558
|
type: :delete,
|
746
|
-
indentation_level: 1
|
747
|
-
|
748
|
-
|
749
|
-
|
1559
|
+
indentation_level: 1
|
1560
|
+
)
|
1561
|
+
expect(inspection).to match(
|
1562
|
+
[
|
1563
|
+
an_object_having_attributes(
|
1564
|
+
type: :delete,
|
1565
|
+
indentation_level: 1,
|
1566
|
+
value:
|
1567
|
+
a_string_matching(
|
1568
|
+
/#<SuperDiff::Test::EmptyClass:0x[a-z0-9]+>/
|
1569
|
+
)
|
1570
|
+
)
|
1571
|
+
]
|
1572
|
+
)
|
750
1573
|
end
|
751
1574
|
end
|
752
1575
|
end
|
753
1576
|
end
|
754
1577
|
|
755
|
-
context "given a
|
756
|
-
context "
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
1578
|
+
context "given a combination of all kinds of values" do
|
1579
|
+
context "given as_lines: false" do
|
1580
|
+
it "returns an inspected version of the object" do
|
1581
|
+
string =
|
1582
|
+
described_class.inspect_object(
|
1583
|
+
{
|
1584
|
+
state: :down,
|
1585
|
+
errors: [
|
1586
|
+
"Container A-234 is partially damaged",
|
1587
|
+
"Vessel B042 was attacked by raccoons",
|
1588
|
+
"Product FDK-3429 is out of stock"
|
1589
|
+
],
|
1590
|
+
mission_critical: true,
|
1591
|
+
serviceable: false,
|
1592
|
+
outstanding_orders: [
|
1593
|
+
SuperDiff::Test::Order.new(
|
1594
|
+
[
|
1595
|
+
SuperDiff::Test::Item.new(name: "ham", quantity: 1),
|
1596
|
+
SuperDiff::Test::Item.new(name: "eggs", quantity: 2),
|
1597
|
+
SuperDiff::Test::Item.new(name: "cheese", quantity: 1)
|
1598
|
+
]
|
1599
|
+
)
|
1600
|
+
],
|
1601
|
+
customers: [
|
1602
|
+
SuperDiff::Test::Customer.new(
|
1603
|
+
name: "Marty McFly",
|
1604
|
+
shipping_address:
|
1605
|
+
SuperDiff::Test::ShippingAddress.new(
|
1606
|
+
line_1: "123 Baltic Ave.",
|
1607
|
+
line_2: "",
|
1608
|
+
city: "Hill Valley",
|
1609
|
+
state: "CA",
|
1610
|
+
zip: "90382"
|
1611
|
+
),
|
1612
|
+
phone: "111-111-1111"
|
1613
|
+
),
|
1614
|
+
SuperDiff::Test::Customer.new(
|
1615
|
+
name: "Doc Brown",
|
1616
|
+
shipping_address:
|
1617
|
+
SuperDiff::Test::ShippingAddress.new(
|
1618
|
+
line_1: "456 Park Place",
|
1619
|
+
line_2: "",
|
1620
|
+
city: "Beverly Hills",
|
1621
|
+
state: "CA",
|
1622
|
+
zip: "90210"
|
1623
|
+
),
|
1624
|
+
phone: "222-222-2222"
|
1625
|
+
)
|
1626
|
+
]
|
1627
|
+
},
|
761
1628
|
as_lines: false
|
762
1629
|
)
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
1630
|
+
expect(string).to match(
|
1631
|
+
# rubocop:disable Metrics/LineLength
|
1632
|
+
/\A\{ state: :down, errors: \["Container A-234 is partially damaged", "Vessel B042 was attacked by raccoons", "Product FDK-3429 is out of stock"\], mission_critical: true, serviceable: false, outstanding_orders: \[#<SuperDiff::Test::Order:0x[a-z0-9]+ @items=\[#<SuperDiff::Test::Item:0x[a-z0-9]+ @name="ham", @quantity=1>, #<SuperDiff::Test::Item:0x[a-z0-9]+ @name="eggs", @quantity=2>, #<SuperDiff::Test::Item:0x[a-z0-9]+ @name="cheese", @quantity=1>\]>\], customers: \[#<SuperDiff::Test::Customer name: "Marty McFly", shipping_address: #<SuperDiff::Test::ShippingAddress line_1: "123 Baltic Ave.", line_2: "", city: "Hill Valley", state: "CA", zip: "90382">, phone: "111-111-1111">, #<SuperDiff::Test::Customer name: "Doc Brown", shipping_address: #<SuperDiff::Test::ShippingAddress line_1: "456 Park Place", line_2: "", city: "Beverly Hills", state: "CA", zip: "90210">, phone: "222-222-2222">\] \}\Z/
|
1633
|
+
# rubocop:enable Metrics/LineLength
|
1634
|
+
)
|
767
1635
|
end
|
1636
|
+
end
|
768
1637
|
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
1638
|
+
context "given as_lines: true" do
|
1639
|
+
it "returns an inspected version of the object as multiple Lines" do
|
1640
|
+
tiered_lines =
|
1641
|
+
described_class.inspect_object(
|
1642
|
+
{
|
1643
|
+
state: :down,
|
1644
|
+
errors: [
|
1645
|
+
"Container A-234 is partially damaged",
|
1646
|
+
"Vessel B042 was attacked by raccoons",
|
1647
|
+
"Product FDK-3429 is out of stock"
|
1648
|
+
],
|
1649
|
+
mission_critical: true,
|
1650
|
+
serviceable: false,
|
1651
|
+
outstanding_orders: [
|
1652
|
+
SuperDiff::Test::Order.new(
|
1653
|
+
[
|
1654
|
+
SuperDiff::Test::Item.new(name: "ham", quantity: 1),
|
1655
|
+
SuperDiff::Test::Item.new(name: "eggs", quantity: 2),
|
1656
|
+
SuperDiff::Test::Item.new(name: "cheese", quantity: 1)
|
1657
|
+
]
|
1658
|
+
)
|
1659
|
+
],
|
1660
|
+
customers: [
|
1661
|
+
SuperDiff::Test::Customer.new(
|
1662
|
+
name: "Marty McFly",
|
1663
|
+
shipping_address:
|
1664
|
+
SuperDiff::Test::ShippingAddress.new(
|
1665
|
+
line_1: "123 Baltic Ave.",
|
1666
|
+
line_2: "",
|
1667
|
+
city: "Hill Valley",
|
1668
|
+
state: "CA",
|
1669
|
+
zip: "90382"
|
1670
|
+
),
|
1671
|
+
phone: "111-111-1111"
|
1672
|
+
),
|
1673
|
+
SuperDiff::Test::Customer.new(
|
1674
|
+
name: "Doc Brown",
|
1675
|
+
shipping_address:
|
1676
|
+
SuperDiff::Test::ShippingAddress.new(
|
1677
|
+
line_1: "456 Park Place",
|
1678
|
+
line_2: "",
|
1679
|
+
city: "Beverly Hills",
|
1680
|
+
state: "CA",
|
1681
|
+
zip: "90210"
|
1682
|
+
),
|
1683
|
+
phone: "222-222-2222"
|
1684
|
+
)
|
1685
|
+
]
|
1686
|
+
},
|
773
1687
|
as_lines: true,
|
774
1688
|
type: :delete,
|
775
1689
|
indentation_level: 1
|
776
1690
|
)
|
777
|
-
|
1691
|
+
expect(tiered_lines).to match(
|
1692
|
+
[
|
778
1693
|
an_object_having_attributes(
|
779
1694
|
type: :delete,
|
780
1695
|
indentation_level: 1,
|
781
|
-
value:
|
782
|
-
|
783
|
-
collection_bookend: :open,
|
784
|
-
),
|
785
|
-
an_object_having_attributes(
|
786
|
-
type: :delete,
|
787
|
-
indentation_level: 2,
|
788
|
-
value: %(year: 2021),
|
789
|
-
add_comma: true,
|
790
|
-
collection_bookend: nil,
|
791
|
-
),
|
792
|
-
an_object_having_attributes(
|
793
|
-
type: :delete,
|
794
|
-
indentation_level: 2,
|
795
|
-
value: %(month: 5),
|
796
|
-
add_comma: true,
|
797
|
-
collection_bookend: nil,
|
798
|
-
),
|
799
|
-
an_object_having_attributes(
|
800
|
-
type: :delete,
|
801
|
-
indentation_level: 2,
|
802
|
-
value: %(day: 5),
|
803
|
-
add_comma: true,
|
804
|
-
collection_bookend: nil,
|
805
|
-
),
|
806
|
-
an_object_having_attributes(
|
807
|
-
type: :delete,
|
808
|
-
indentation_level: 2,
|
809
|
-
value: %(hour: 10),
|
810
|
-
add_comma: true,
|
811
|
-
collection_bookend: nil,
|
812
|
-
),
|
813
|
-
an_object_having_attributes(
|
814
|
-
type: :delete,
|
815
|
-
indentation_level: 2,
|
816
|
-
value: %(min: 23),
|
817
|
-
add_comma: true,
|
818
|
-
collection_bookend: nil,
|
819
|
-
),
|
820
|
-
an_object_having_attributes(
|
821
|
-
type: :delete,
|
822
|
-
indentation_level: 2,
|
823
|
-
value: %(sec: 28),
|
824
|
-
add_comma: true,
|
825
|
-
collection_bookend: nil,
|
826
|
-
),
|
827
|
-
an_object_having_attributes(
|
828
|
-
type: :delete,
|
829
|
-
indentation_level: 2,
|
830
|
-
value: %(subsec: (34749996836695/281474976710656)),
|
831
|
-
add_comma: true,
|
832
|
-
collection_bookend: nil,
|
1696
|
+
value: "{",
|
1697
|
+
collection_bookend: :open
|
833
1698
|
),
|
834
1699
|
an_object_having_attributes(
|
835
1700
|
type: :delete,
|
836
1701
|
indentation_level: 2,
|
837
|
-
|
838
|
-
|
839
|
-
|
1702
|
+
prefix: "state: ",
|
1703
|
+
value: ":down",
|
1704
|
+
add_comma: true
|
840
1705
|
),
|
841
1706
|
an_object_having_attributes(
|
842
1707
|
type: :delete,
|
843
1708
|
indentation_level: 2,
|
844
|
-
|
845
|
-
|
846
|
-
collection_bookend:
|
847
|
-
),
|
848
|
-
an_object_having_attributes(
|
849
|
-
type: :delete,
|
850
|
-
indentation_level: 1,
|
851
|
-
value: %(}>),
|
852
|
-
add_comma: false,
|
853
|
-
collection_bookend: :close,
|
1709
|
+
prefix: "errors: ",
|
1710
|
+
value: "[",
|
1711
|
+
collection_bookend: :open
|
854
1712
|
),
|
855
|
-
])
|
856
|
-
end
|
857
|
-
end
|
858
|
-
end
|
859
|
-
|
860
|
-
context "that has an associated time zone" do
|
861
|
-
around do |example|
|
862
|
-
ClimateControl.modify(TZ: 'America/Chicago', &example)
|
863
|
-
end
|
864
|
-
|
865
|
-
context "given as_lines: false" do
|
866
|
-
it "returns a representation of the time on a single line" do
|
867
|
-
inspection = described_class.inspect_object(
|
868
|
-
Time.new(2021, 5, 5, 10, 23, 28.1234567891),
|
869
|
-
as_lines: false
|
870
|
-
)
|
871
|
-
expect(inspection).to eq(
|
872
|
-
"#<Time 2021-05-05 10:23:28+(34749996836695/281474976710656) -05:00 (CDT)>"
|
873
|
-
)
|
874
|
-
end
|
875
|
-
end
|
876
|
-
|
877
|
-
context "given as_lines: true" do
|
878
|
-
it "returns a representation of the time across multiple lines" do
|
879
|
-
inspection = described_class.inspect_object(
|
880
|
-
Time.new(2021, 5, 5, 10, 23, 28.1234567891),
|
881
|
-
as_lines: true,
|
882
|
-
type: :delete,
|
883
|
-
indentation_level: 1
|
884
|
-
)
|
885
|
-
expect(inspection).to match([
|
886
1713
|
an_object_having_attributes(
|
887
1714
|
type: :delete,
|
888
|
-
indentation_level:
|
889
|
-
value: %(
|
890
|
-
add_comma:
|
891
|
-
collection_bookend: :open,
|
1715
|
+
indentation_level: 3,
|
1716
|
+
value: %("Container A-234 is partially damaged"),
|
1717
|
+
add_comma: true
|
892
1718
|
),
|
893
1719
|
an_object_having_attributes(
|
894
1720
|
type: :delete,
|
895
|
-
indentation_level:
|
896
|
-
value: %(
|
897
|
-
add_comma: true
|
898
|
-
collection_bookend: nil,
|
1721
|
+
indentation_level: 3,
|
1722
|
+
value: %("Vessel B042 was attacked by raccoons"),
|
1723
|
+
add_comma: true
|
899
1724
|
),
|
900
1725
|
an_object_having_attributes(
|
901
1726
|
type: :delete,
|
902
|
-
indentation_level:
|
903
|
-
value: %(
|
904
|
-
add_comma:
|
905
|
-
collection_bookend: nil,
|
1727
|
+
indentation_level: 3,
|
1728
|
+
value: %("Product FDK-3429 is out of stock"),
|
1729
|
+
add_comma: false
|
906
1730
|
),
|
907
1731
|
an_object_having_attributes(
|
908
1732
|
type: :delete,
|
909
1733
|
indentation_level: 2,
|
910
|
-
value:
|
911
|
-
|
912
|
-
collection_bookend: nil,
|
1734
|
+
value: "]",
|
1735
|
+
collection_bookend: :close
|
913
1736
|
),
|
914
1737
|
an_object_having_attributes(
|
915
1738
|
type: :delete,
|
916
1739
|
indentation_level: 2,
|
917
|
-
|
918
|
-
|
919
|
-
|
1740
|
+
prefix: "mission_critical: ",
|
1741
|
+
value: "true",
|
1742
|
+
add_comma: true
|
920
1743
|
),
|
921
1744
|
an_object_having_attributes(
|
922
1745
|
type: :delete,
|
923
1746
|
indentation_level: 2,
|
924
|
-
|
925
|
-
|
926
|
-
|
1747
|
+
prefix: "serviceable: ",
|
1748
|
+
value: "false",
|
1749
|
+
add_comma: true
|
927
1750
|
),
|
928
1751
|
an_object_having_attributes(
|
929
1752
|
type: :delete,
|
930
1753
|
indentation_level: 2,
|
931
|
-
|
932
|
-
|
933
|
-
collection_bookend:
|
1754
|
+
prefix: "outstanding_orders: ",
|
1755
|
+
value: "[",
|
1756
|
+
collection_bookend: :open
|
934
1757
|
),
|
935
1758
|
an_object_having_attributes(
|
936
1759
|
type: :delete,
|
937
|
-
indentation_level:
|
938
|
-
value:
|
939
|
-
|
940
|
-
collection_bookend:
|
1760
|
+
indentation_level: 3,
|
1761
|
+
value:
|
1762
|
+
a_string_matching(/#<SuperDiff::Test::Order:0x[a-f0-9]+ \{/),
|
1763
|
+
collection_bookend: :open
|
941
1764
|
),
|
942
1765
|
an_object_having_attributes(
|
943
1766
|
type: :delete,
|
944
|
-
indentation_level:
|
945
|
-
|
946
|
-
|
947
|
-
collection_bookend:
|
1767
|
+
indentation_level: 4,
|
1768
|
+
prefix: "@items=",
|
1769
|
+
value: "[",
|
1770
|
+
collection_bookend: :open
|
948
1771
|
),
|
949
1772
|
an_object_having_attributes(
|
950
1773
|
type: :delete,
|
951
|
-
indentation_level:
|
952
|
-
value:
|
953
|
-
|
954
|
-
collection_bookend:
|
1774
|
+
indentation_level: 5,
|
1775
|
+
value:
|
1776
|
+
a_string_matching(/#<SuperDiff::Test::Item:0x[a-f0-9]+ \{/),
|
1777
|
+
collection_bookend: :open
|
955
1778
|
),
|
956
1779
|
an_object_having_attributes(
|
957
1780
|
type: :delete,
|
958
|
-
indentation_level:
|
959
|
-
|
960
|
-
|
961
|
-
|
1781
|
+
indentation_level: 6,
|
1782
|
+
prefix: "@name=",
|
1783
|
+
value: %("ham"),
|
1784
|
+
add_comma: true
|
962
1785
|
),
|
963
|
-
])
|
964
|
-
end
|
965
|
-
end
|
966
|
-
end
|
967
|
-
end
|
968
|
-
|
969
|
-
context "given a class" do
|
970
|
-
context "given as_lines: false" do
|
971
|
-
it "returns an inspected version of the object" do
|
972
|
-
string = described_class.inspect_object(
|
973
|
-
SuperDiff::Test::Person,
|
974
|
-
as_lines: false,
|
975
|
-
)
|
976
|
-
expect(string).to eq("SuperDiff::Test::Person")
|
977
|
-
end
|
978
|
-
end
|
979
|
-
|
980
|
-
context "given as_lines: true" do
|
981
|
-
it "returns an inspected version of the object" do
|
982
|
-
tiered_lines = described_class.inspect_object(
|
983
|
-
SuperDiff::Test::Person,
|
984
|
-
as_lines: true,
|
985
|
-
type: :delete,
|
986
|
-
indentation_level: 1,
|
987
|
-
)
|
988
|
-
expect(tiered_lines).to match([
|
989
|
-
an_object_having_attributes(
|
990
|
-
type: :delete,
|
991
|
-
indentation_level: 1,
|
992
|
-
value: %(SuperDiff::Test::Person),
|
993
|
-
),
|
994
|
-
])
|
995
|
-
end
|
996
|
-
end
|
997
|
-
end
|
998
|
-
|
999
|
-
# TODO: Add when empty
|
1000
|
-
context "given a custom object" do
|
1001
|
-
context "containing only primitive values" do
|
1002
|
-
context "given as_lines: false" do
|
1003
|
-
it "returns an inspected version of the object" do
|
1004
|
-
string = described_class.inspect_object(
|
1005
|
-
SuperDiff::Test::Person.new(name: "Doc", age: 58),
|
1006
|
-
as_lines: false,
|
1007
|
-
)
|
1008
|
-
expect(string).to eq(
|
1009
|
-
%(#<SuperDiff::Test::Person name: "Doc", age: 58>),
|
1010
|
-
)
|
1011
|
-
end
|
1012
|
-
end
|
1013
|
-
|
1014
|
-
context "given as_lines: true" do
|
1015
|
-
it "returns an inspected version of the object as multiple Lines" do
|
1016
|
-
tiered_lines = described_class.inspect_object(
|
1017
|
-
SuperDiff::Test::Person.new(name: "Doc", age: 58),
|
1018
|
-
as_lines: true,
|
1019
|
-
type: :delete,
|
1020
|
-
indentation_level: 1,
|
1021
|
-
)
|
1022
|
-
expect(tiered_lines).to match([
|
1023
1786
|
an_object_having_attributes(
|
1024
1787
|
type: :delete,
|
1025
|
-
indentation_level:
|
1026
|
-
|
1788
|
+
indentation_level: 6,
|
1789
|
+
prefix: "@quantity=",
|
1790
|
+
value: "1",
|
1791
|
+
add_comma: false
|
1027
1792
|
),
|
1028
1793
|
an_object_having_attributes(
|
1029
1794
|
type: :delete,
|
1030
|
-
indentation_level:
|
1031
|
-
|
1032
|
-
|
1033
|
-
add_comma: true,
|
1795
|
+
indentation_level: 5,
|
1796
|
+
value: "}>",
|
1797
|
+
collection_bookend: :close
|
1034
1798
|
),
|
1035
1799
|
an_object_having_attributes(
|
1036
1800
|
type: :delete,
|
1037
|
-
indentation_level:
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1801
|
+
indentation_level: 5,
|
1802
|
+
value:
|
1803
|
+
a_string_matching(/#<SuperDiff::Test::Item:0x[a-f0-9]+ \{/),
|
1804
|
+
collection_bookend: :open
|
1041
1805
|
),
|
1042
1806
|
an_object_having_attributes(
|
1043
1807
|
type: :delete,
|
1044
|
-
indentation_level:
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
end
|
1049
|
-
end
|
1050
|
-
end
|
1051
|
-
|
1052
|
-
context "containing other custom objects" do
|
1053
|
-
context "given as_lines: false" do
|
1054
|
-
it "returns an inspected version of the object" do
|
1055
|
-
string = described_class.inspect_object(
|
1056
|
-
SuperDiff::Test::Customer.new(
|
1057
|
-
name: "Marty McFly",
|
1058
|
-
shipping_address: SuperDiff::Test::ShippingAddress.new(
|
1059
|
-
line_1: "123 Main St.",
|
1060
|
-
line_2: "",
|
1061
|
-
city: "Hill Valley",
|
1062
|
-
state: "CA",
|
1063
|
-
zip: "90382",
|
1064
|
-
),
|
1065
|
-
phone: "111-222-3333",
|
1066
|
-
),
|
1067
|
-
as_lines: false,
|
1068
|
-
)
|
1069
|
-
expect(string).to eq(
|
1070
|
-
# rubocop:disable Metrics/LineLength
|
1071
|
-
%(#<SuperDiff::Test::Customer name: "Marty McFly", shipping_address: #<SuperDiff::Test::ShippingAddress line_1: "123 Main St.", line_2: "", city: "Hill Valley", state: "CA", zip: "90382">, phone: "111-222-3333">),
|
1072
|
-
# rubocop:enable Metrics/LineLength
|
1073
|
-
)
|
1074
|
-
end
|
1075
|
-
end
|
1076
|
-
|
1077
|
-
context "given as_lines: true" do
|
1078
|
-
it "returns an inspected version of the object as multiple Lines" do
|
1079
|
-
tiered_lines = described_class.inspect_object(
|
1080
|
-
SuperDiff::Test::Customer.new(
|
1081
|
-
name: "Marty McFly",
|
1082
|
-
shipping_address: SuperDiff::Test::ShippingAddress.new(
|
1083
|
-
line_1: "123 Main St.",
|
1084
|
-
line_2: "",
|
1085
|
-
city: "Hill Valley",
|
1086
|
-
state: "CA",
|
1087
|
-
zip: "90382",
|
1088
|
-
),
|
1089
|
-
phone: "111-222-3333",
|
1808
|
+
indentation_level: 6,
|
1809
|
+
prefix: "@name=",
|
1810
|
+
value: %("eggs"),
|
1811
|
+
add_comma: true
|
1090
1812
|
),
|
1091
|
-
as_lines: true,
|
1092
|
-
type: :delete,
|
1093
|
-
indentation_level: 1,
|
1094
|
-
)
|
1095
|
-
expect(tiered_lines).to match([
|
1096
1813
|
an_object_having_attributes(
|
1097
1814
|
type: :delete,
|
1098
|
-
indentation_level:
|
1099
|
-
|
1100
|
-
|
1815
|
+
indentation_level: 6,
|
1816
|
+
prefix: "@quantity=",
|
1817
|
+
value: "2",
|
1818
|
+
add_comma: false
|
1101
1819
|
),
|
1102
1820
|
an_object_having_attributes(
|
1103
1821
|
type: :delete,
|
1104
|
-
indentation_level:
|
1105
|
-
|
1106
|
-
|
1107
|
-
add_comma: true,
|
1822
|
+
indentation_level: 5,
|
1823
|
+
value: "}>",
|
1824
|
+
collection_bookend: :close
|
1108
1825
|
),
|
1109
1826
|
an_object_having_attributes(
|
1110
1827
|
type: :delete,
|
1111
|
-
indentation_level:
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
collection_bookend: :open,
|
1828
|
+
indentation_level: 5,
|
1829
|
+
value:
|
1830
|
+
a_string_matching(/#<SuperDiff::Test::Item:0x[a-f0-9]+ \{/),
|
1831
|
+
collection_bookend: :open
|
1116
1832
|
),
|
1117
1833
|
an_object_having_attributes(
|
1118
1834
|
type: :delete,
|
1119
|
-
indentation_level:
|
1120
|
-
prefix:
|
1121
|
-
value: %("
|
1835
|
+
indentation_level: 6,
|
1836
|
+
prefix: "@name=",
|
1837
|
+
value: %("cheese"),
|
1838
|
+
add_comma: true
|
1122
1839
|
),
|
1123
1840
|
an_object_having_attributes(
|
1124
1841
|
type: :delete,
|
1125
|
-
indentation_level:
|
1126
|
-
prefix:
|
1127
|
-
value:
|
1128
|
-
add_comma:
|
1842
|
+
indentation_level: 6,
|
1843
|
+
prefix: "@quantity=",
|
1844
|
+
value: "1",
|
1845
|
+
add_comma: false
|
1129
1846
|
),
|
1130
1847
|
an_object_having_attributes(
|
1131
1848
|
type: :delete,
|
1132
|
-
indentation_level:
|
1133
|
-
|
1134
|
-
|
1135
|
-
add_comma: true,
|
1849
|
+
indentation_level: 5,
|
1850
|
+
value: "}>",
|
1851
|
+
collection_bookend: :close
|
1136
1852
|
),
|
1137
1853
|
an_object_having_attributes(
|
1138
1854
|
type: :delete,
|
1139
|
-
indentation_level:
|
1140
|
-
|
1141
|
-
|
1142
|
-
add_comma: true,
|
1855
|
+
indentation_level: 4,
|
1856
|
+
value: "]",
|
1857
|
+
collection_bookend: :close
|
1143
1858
|
),
|
1144
1859
|
an_object_having_attributes(
|
1145
1860
|
type: :delete,
|
1146
1861
|
indentation_level: 3,
|
1147
|
-
|
1148
|
-
|
1149
|
-
add_comma: false,
|
1862
|
+
value: "}>",
|
1863
|
+
collection_bookend: :close
|
1150
1864
|
),
|
1151
1865
|
an_object_having_attributes(
|
1152
1866
|
type: :delete,
|
1153
1867
|
indentation_level: 2,
|
1154
|
-
value:
|
1155
|
-
|
1156
|
-
collection_bookend: :close,
|
1868
|
+
value: "]",
|
1869
|
+
collection_bookend: :close
|
1157
1870
|
),
|
1158
1871
|
an_object_having_attributes(
|
1159
1872
|
type: :delete,
|
1160
1873
|
indentation_level: 2,
|
1161
|
-
prefix:
|
1162
|
-
value:
|
1163
|
-
|
1874
|
+
prefix: "customers: ",
|
1875
|
+
value: "[",
|
1876
|
+
collection_bookend: :open
|
1164
1877
|
),
|
1165
1878
|
an_object_having_attributes(
|
1166
1879
|
type: :delete,
|
1167
|
-
indentation_level:
|
1168
|
-
value:
|
1169
|
-
|
1170
|
-
collection_bookend: :close,
|
1171
|
-
),
|
1172
|
-
])
|
1173
|
-
end
|
1174
|
-
end
|
1175
|
-
end
|
1176
|
-
end
|
1177
|
-
|
1178
|
-
context "given a non-custom object" do
|
1179
|
-
context "containing only primitive values" do
|
1180
|
-
context "given as_lines: false" do
|
1181
|
-
it "returns an inspected version of the object" do
|
1182
|
-
string = described_class.inspect_object(
|
1183
|
-
SuperDiff::Test::Item.new(
|
1184
|
-
name: "mac and cheese",
|
1185
|
-
quantity: 2,
|
1186
|
-
),
|
1187
|
-
as_lines: false,
|
1188
|
-
)
|
1189
|
-
expect(string).to match(
|
1190
|
-
/\A#<SuperDiff::Test::Item:0x[a-z0-9]+ @name="mac and cheese", @quantity=2>\Z/,
|
1191
|
-
)
|
1192
|
-
end
|
1193
|
-
end
|
1194
|
-
|
1195
|
-
context "given as_lines: true" do
|
1196
|
-
it "returns an inspected version of the object as multiple Lines" do
|
1197
|
-
tiered_lines = described_class.inspect_object(
|
1198
|
-
SuperDiff::Test::Item.new(
|
1199
|
-
name: "mac and cheese",
|
1200
|
-
quantity: 2,
|
1880
|
+
indentation_level: 3,
|
1881
|
+
value: "#<SuperDiff::Test::Customer {",
|
1882
|
+
collection_bookend: :open
|
1201
1883
|
),
|
1202
|
-
as_lines: true,
|
1203
|
-
type: :delete,
|
1204
|
-
indentation_level: 1,
|
1205
|
-
)
|
1206
|
-
expect(tiered_lines).to match([
|
1207
1884
|
an_object_having_attributes(
|
1208
1885
|
type: :delete,
|
1209
|
-
indentation_level:
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
collection_bookend: :open,
|
1886
|
+
indentation_level: 4,
|
1887
|
+
prefix: "name: ",
|
1888
|
+
value: %("Marty McFly"),
|
1889
|
+
add_comma: true
|
1214
1890
|
),
|
1215
1891
|
an_object_having_attributes(
|
1216
1892
|
type: :delete,
|
1217
|
-
indentation_level:
|
1218
|
-
prefix:
|
1219
|
-
value:
|
1220
|
-
|
1893
|
+
indentation_level: 4,
|
1894
|
+
prefix: "shipping_address: ",
|
1895
|
+
value: "#<SuperDiff::Test::ShippingAddress {",
|
1896
|
+
collection_bookend: :open
|
1221
1897
|
),
|
1222
1898
|
an_object_having_attributes(
|
1223
1899
|
type: :delete,
|
1224
|
-
indentation_level:
|
1225
|
-
prefix:
|
1226
|
-
value: %(
|
1227
|
-
add_comma:
|
1900
|
+
indentation_level: 5,
|
1901
|
+
prefix: "line_1: ",
|
1902
|
+
value: %("123 Baltic Ave."),
|
1903
|
+
add_comma: true
|
1228
1904
|
),
|
1229
1905
|
an_object_having_attributes(
|
1230
1906
|
type: :delete,
|
1231
|
-
indentation_level:
|
1232
|
-
|
1233
|
-
|
1907
|
+
indentation_level: 5,
|
1908
|
+
prefix: "line_2: ",
|
1909
|
+
value: %(""),
|
1910
|
+
add_comma: true
|
1234
1911
|
),
|
1235
|
-
])
|
1236
|
-
end
|
1237
|
-
end
|
1238
|
-
end
|
1239
|
-
|
1240
|
-
context "containing other custom objects" do
|
1241
|
-
context "given as_lines: false" do
|
1242
|
-
it "returns an inspected version of the object" do
|
1243
|
-
string = described_class.inspect_object(
|
1244
|
-
SuperDiff::Test::Order.new([
|
1245
|
-
SuperDiff::Test::Item.new(name: "ham", quantity: 1),
|
1246
|
-
SuperDiff::Test::Item.new(name: "eggs", quantity: 2),
|
1247
|
-
SuperDiff::Test::Item.new(name: "cheese", quantity: 1),
|
1248
|
-
]),
|
1249
|
-
as_lines: false,
|
1250
|
-
)
|
1251
|
-
expect(string).to match(
|
1252
|
-
# rubocop:disable Metrics/LineLength
|
1253
|
-
/\A#<SuperDiff::Test::Order:0x[a-z0-9]+ @items=\[#<SuperDiff::Test::Item:0x[a-z0-9]+ @name="ham", @quantity=1>, #<SuperDiff::Test::Item:0x[a-z0-9]+ @name="eggs", @quantity=2>, #<SuperDiff::Test::Item:0x[a-z0-9]+ @name="cheese", @quantity=1>\]>\Z/,
|
1254
|
-
# rubocop:enable Metrics/LineLength
|
1255
|
-
)
|
1256
|
-
end
|
1257
|
-
end
|
1258
|
-
|
1259
|
-
context "given as_lines: true" do
|
1260
|
-
it "returns an inspected version of the object as multiple Lines" do
|
1261
|
-
tiered_lines = described_class.inspect_object(
|
1262
|
-
SuperDiff::Test::Order.new([
|
1263
|
-
SuperDiff::Test::Item.new(name: "ham", quantity: 1),
|
1264
|
-
SuperDiff::Test::Item.new(name: "eggs", quantity: 2),
|
1265
|
-
SuperDiff::Test::Item.new(name: "cheese", quantity: 1),
|
1266
|
-
]),
|
1267
|
-
as_lines: true,
|
1268
|
-
type: :delete,
|
1269
|
-
indentation_level: 1,
|
1270
|
-
)
|
1271
|
-
expect(tiered_lines).to match([
|
1272
1912
|
an_object_having_attributes(
|
1273
1913
|
type: :delete,
|
1274
|
-
indentation_level:
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
collection_bookend: :open,
|
1914
|
+
indentation_level: 5,
|
1915
|
+
prefix: "city: ",
|
1916
|
+
value: %("Hill Valley"),
|
1917
|
+
add_comma: true
|
1279
1918
|
),
|
1280
1919
|
an_object_having_attributes(
|
1281
1920
|
type: :delete,
|
1282
|
-
indentation_level:
|
1283
|
-
prefix:
|
1284
|
-
value: %(
|
1285
|
-
add_comma:
|
1286
|
-
collection_bookend: :open,
|
1921
|
+
indentation_level: 5,
|
1922
|
+
prefix: "state: ",
|
1923
|
+
value: %("CA"),
|
1924
|
+
add_comma: true
|
1287
1925
|
),
|
1288
1926
|
an_object_having_attributes(
|
1289
1927
|
type: :delete,
|
1290
|
-
indentation_level:
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
add_comma: false,
|
1295
|
-
collection_bookend: :open,
|
1928
|
+
indentation_level: 5,
|
1929
|
+
prefix: "zip: ",
|
1930
|
+
value: %("90382"),
|
1931
|
+
add_comma: false
|
1296
1932
|
),
|
1297
1933
|
an_object_having_attributes(
|
1298
1934
|
type: :delete,
|
1299
1935
|
indentation_level: 4,
|
1300
|
-
|
1301
|
-
value: %("ham"),
|
1936
|
+
value: "}>",
|
1302
1937
|
add_comma: true,
|
1938
|
+
collection_bookend: :close
|
1303
1939
|
),
|
1304
1940
|
an_object_having_attributes(
|
1305
1941
|
type: :delete,
|
1306
1942
|
indentation_level: 4,
|
1307
|
-
prefix:
|
1308
|
-
value: %(
|
1309
|
-
add_comma: false
|
1943
|
+
prefix: "phone: ",
|
1944
|
+
value: %("111-111-1111"),
|
1945
|
+
add_comma: false
|
1310
1946
|
),
|
1311
1947
|
an_object_having_attributes(
|
1312
1948
|
type: :delete,
|
1313
1949
|
indentation_level: 3,
|
1314
|
-
value:
|
1315
|
-
add_comma: true
|
1316
|
-
collection_bookend: :close,
|
1950
|
+
value: "}>",
|
1951
|
+
add_comma: true
|
1317
1952
|
),
|
1318
1953
|
an_object_having_attributes(
|
1319
1954
|
type: :delete,
|
1320
1955
|
indentation_level: 3,
|
1321
|
-
value:
|
1322
|
-
|
1323
|
-
),
|
1324
|
-
add_comma: false,
|
1325
|
-
collection_bookend: :open,
|
1956
|
+
value: "#<SuperDiff::Test::Customer {",
|
1957
|
+
collection_bookend: :open
|
1326
1958
|
),
|
1327
1959
|
an_object_having_attributes(
|
1328
1960
|
type: :delete,
|
1329
1961
|
indentation_level: 4,
|
1330
|
-
prefix:
|
1331
|
-
value: %("
|
1332
|
-
add_comma: true
|
1962
|
+
prefix: "name: ",
|
1963
|
+
value: %("Doc Brown"),
|
1964
|
+
add_comma: true
|
1333
1965
|
),
|
1334
1966
|
an_object_having_attributes(
|
1335
1967
|
type: :delete,
|
1336
1968
|
indentation_level: 4,
|
1337
|
-
prefix:
|
1338
|
-
value:
|
1339
|
-
|
1969
|
+
prefix: "shipping_address: ",
|
1970
|
+
value: "#<SuperDiff::Test::ShippingAddress {",
|
1971
|
+
collection_bookend: :open
|
1340
1972
|
),
|
1341
1973
|
an_object_having_attributes(
|
1342
1974
|
type: :delete,
|
1343
|
-
indentation_level:
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1975
|
+
indentation_level: 5,
|
1976
|
+
prefix: "line_1: ",
|
1977
|
+
value: %("456 Park Place"),
|
1978
|
+
add_comma: true
|
1347
1979
|
),
|
1348
1980
|
an_object_having_attributes(
|
1349
1981
|
type: :delete,
|
1350
|
-
indentation_level:
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1982
|
+
indentation_level: 5,
|
1983
|
+
prefix: "line_2: ",
|
1984
|
+
value: %(""),
|
1985
|
+
add_comma: true
|
1986
|
+
),
|
1987
|
+
an_object_having_attributes(
|
1988
|
+
type: :delete,
|
1989
|
+
indentation_level: 5,
|
1990
|
+
prefix: "city: ",
|
1991
|
+
value: %("Beverly Hills"),
|
1992
|
+
add_comma: true
|
1993
|
+
),
|
1994
|
+
an_object_having_attributes(
|
1995
|
+
type: :delete,
|
1996
|
+
indentation_level: 5,
|
1997
|
+
prefix: "state: ",
|
1998
|
+
value: %("CA"),
|
1999
|
+
add_comma: true
|
2000
|
+
),
|
2001
|
+
an_object_having_attributes(
|
2002
|
+
type: :delete,
|
2003
|
+
indentation_level: 5,
|
2004
|
+
prefix: "zip: ",
|
2005
|
+
value: %("90210"),
|
2006
|
+
add_comma: false
|
1356
2007
|
),
|
1357
2008
|
an_object_having_attributes(
|
1358
2009
|
type: :delete,
|
1359
2010
|
indentation_level: 4,
|
1360
|
-
|
1361
|
-
value: %("cheese"),
|
2011
|
+
value: "}>",
|
1362
2012
|
add_comma: true,
|
2013
|
+
collection_bookend: :close
|
1363
2014
|
),
|
1364
2015
|
an_object_having_attributes(
|
1365
2016
|
type: :delete,
|
1366
2017
|
indentation_level: 4,
|
1367
|
-
prefix:
|
1368
|
-
value: %(
|
1369
|
-
add_comma: false
|
2018
|
+
prefix: "phone: ",
|
2019
|
+
value: %("222-222-2222"),
|
2020
|
+
add_comma: false
|
1370
2021
|
),
|
1371
2022
|
an_object_having_attributes(
|
1372
2023
|
type: :delete,
|
1373
2024
|
indentation_level: 3,
|
1374
|
-
value:
|
2025
|
+
value: "}>",
|
1375
2026
|
add_comma: false,
|
1376
|
-
collection_bookend: :close
|
2027
|
+
collection_bookend: :close
|
1377
2028
|
),
|
1378
2029
|
an_object_having_attributes(
|
1379
2030
|
type: :delete,
|
1380
2031
|
indentation_level: 2,
|
1381
|
-
value:
|
1382
|
-
add_comma: false,
|
1383
|
-
collection_bookend: :close,
|
1384
|
-
),
|
1385
|
-
an_object_having_attributes(
|
1386
|
-
type: :delete,
|
1387
|
-
indentation_level: 1,
|
1388
|
-
value: %(}>),
|
2032
|
+
value: "]",
|
1389
2033
|
add_comma: false,
|
1390
|
-
collection_bookend: :close
|
2034
|
+
collection_bookend: :close
|
1391
2035
|
),
|
1392
|
-
])
|
1393
|
-
end
|
1394
|
-
end
|
1395
|
-
end
|
1396
|
-
|
1397
|
-
context "which is empty" do
|
1398
|
-
context "given as_lines: false" do
|
1399
|
-
it "returns an inspected version of the array" do
|
1400
|
-
string = described_class.inspect_object(
|
1401
|
-
SuperDiff::Test::EmptyClass.new,
|
1402
|
-
as_lines: false,
|
1403
|
-
)
|
1404
|
-
expect(string).to match(
|
1405
|
-
/#<SuperDiff::Test::EmptyClass:0x[a-z0-9]+>/,
|
1406
|
-
)
|
1407
|
-
end
|
1408
|
-
end
|
1409
|
-
|
1410
|
-
context "given as_lines: true" do
|
1411
|
-
it "returns an inspected version of the array" do
|
1412
|
-
inspection = described_class.inspect_object(
|
1413
|
-
SuperDiff::Test::EmptyClass.new,
|
1414
|
-
as_lines: true,
|
1415
|
-
type: :delete,
|
1416
|
-
indentation_level: 1
|
1417
|
-
)
|
1418
|
-
expect(inspection).to match([
|
1419
2036
|
an_object_having_attributes(
|
1420
2037
|
type: :delete,
|
1421
2038
|
indentation_level: 1,
|
1422
|
-
value:
|
1423
|
-
|
1424
|
-
),
|
2039
|
+
value: "}",
|
2040
|
+
collection_bookend: :close
|
1425
2041
|
)
|
1426
|
-
]
|
1427
|
-
end
|
1428
|
-
end
|
1429
|
-
end
|
1430
|
-
end
|
1431
|
-
|
1432
|
-
context "given a combination of all kinds of values" do
|
1433
|
-
context "given as_lines: false" do
|
1434
|
-
it "returns an inspected version of the object" do
|
1435
|
-
string = described_class.inspect_object(
|
1436
|
-
{
|
1437
|
-
state: :down,
|
1438
|
-
errors: [
|
1439
|
-
"Container A-234 is partially damaged",
|
1440
|
-
"Vessel B042 was attacked by raccoons",
|
1441
|
-
"Product FDK-3429 is out of stock",
|
1442
|
-
],
|
1443
|
-
mission_critical: true,
|
1444
|
-
serviceable: false,
|
1445
|
-
outstanding_orders: [
|
1446
|
-
SuperDiff::Test::Order.new([
|
1447
|
-
SuperDiff::Test::Item.new(name: "ham", quantity: 1),
|
1448
|
-
SuperDiff::Test::Item.new(name: "eggs", quantity: 2),
|
1449
|
-
SuperDiff::Test::Item.new(name: "cheese", quantity: 1),
|
1450
|
-
]),
|
1451
|
-
],
|
1452
|
-
customers: [
|
1453
|
-
SuperDiff::Test::Customer.new(
|
1454
|
-
name: "Marty McFly",
|
1455
|
-
shipping_address: SuperDiff::Test::ShippingAddress.new(
|
1456
|
-
line_1: "123 Baltic Ave.",
|
1457
|
-
line_2: "",
|
1458
|
-
city: "Hill Valley",
|
1459
|
-
state: "CA",
|
1460
|
-
zip: "90382",
|
1461
|
-
),
|
1462
|
-
phone: "111-111-1111",
|
1463
|
-
),
|
1464
|
-
SuperDiff::Test::Customer.new(
|
1465
|
-
name: "Doc Brown",
|
1466
|
-
shipping_address: SuperDiff::Test::ShippingAddress.new(
|
1467
|
-
line_1: "456 Park Place",
|
1468
|
-
line_2: "",
|
1469
|
-
city: "Beverly Hills",
|
1470
|
-
state: "CA",
|
1471
|
-
zip: "90210",
|
1472
|
-
),
|
1473
|
-
phone: "222-222-2222",
|
1474
|
-
),
|
1475
|
-
],
|
1476
|
-
},
|
1477
|
-
as_lines: false,
|
1478
|
-
)
|
1479
|
-
expect(string).to match(
|
1480
|
-
# rubocop:disable Metrics/LineLength
|
1481
|
-
/\A\{ state: :down, errors: \["Container A-234 is partially damaged", "Vessel B042 was attacked by raccoons", "Product FDK-3429 is out of stock"\], mission_critical: true, serviceable: false, outstanding_orders: \[#<SuperDiff::Test::Order:0x[a-z0-9]+ @items=\[#<SuperDiff::Test::Item:0x[a-z0-9]+ @name="ham", @quantity=1>, #<SuperDiff::Test::Item:0x[a-z0-9]+ @name="eggs", @quantity=2>, #<SuperDiff::Test::Item:0x[a-z0-9]+ @name="cheese", @quantity=1>\]>\], customers: \[#<SuperDiff::Test::Customer name: "Marty McFly", shipping_address: #<SuperDiff::Test::ShippingAddress line_1: "123 Baltic Ave.", line_2: "", city: "Hill Valley", state: "CA", zip: "90382">, phone: "111-111-1111">, #<SuperDiff::Test::Customer name: "Doc Brown", shipping_address: #<SuperDiff::Test::ShippingAddress line_1: "456 Park Place", line_2: "", city: "Beverly Hills", state: "CA", zip: "90210">, phone: "222-222-2222">\] \}\Z/,
|
1482
|
-
# rubocop:enable Metrics/LineLength
|
1483
|
-
)
|
1484
|
-
end
|
1485
|
-
end
|
1486
|
-
|
1487
|
-
context "given as_lines: true" do
|
1488
|
-
it "returns an inspected version of the object as multiple Lines" do
|
1489
|
-
tiered_lines = described_class.inspect_object(
|
1490
|
-
{
|
1491
|
-
state: :down,
|
1492
|
-
errors: [
|
1493
|
-
"Container A-234 is partially damaged",
|
1494
|
-
"Vessel B042 was attacked by raccoons",
|
1495
|
-
"Product FDK-3429 is out of stock",
|
1496
|
-
],
|
1497
|
-
mission_critical: true,
|
1498
|
-
serviceable: false,
|
1499
|
-
outstanding_orders: [
|
1500
|
-
SuperDiff::Test::Order.new([
|
1501
|
-
SuperDiff::Test::Item.new(name: "ham", quantity: 1),
|
1502
|
-
SuperDiff::Test::Item.new(name: "eggs", quantity: 2),
|
1503
|
-
SuperDiff::Test::Item.new(name: "cheese", quantity: 1),
|
1504
|
-
]),
|
1505
|
-
],
|
1506
|
-
customers: [
|
1507
|
-
SuperDiff::Test::Customer.new(
|
1508
|
-
name: "Marty McFly",
|
1509
|
-
shipping_address: SuperDiff::Test::ShippingAddress.new(
|
1510
|
-
line_1: "123 Baltic Ave.",
|
1511
|
-
line_2: "",
|
1512
|
-
city: "Hill Valley",
|
1513
|
-
state: "CA",
|
1514
|
-
zip: "90382",
|
1515
|
-
),
|
1516
|
-
phone: "111-111-1111",
|
1517
|
-
),
|
1518
|
-
SuperDiff::Test::Customer.new(
|
1519
|
-
name: "Doc Brown",
|
1520
|
-
shipping_address: SuperDiff::Test::ShippingAddress.new(
|
1521
|
-
line_1: "456 Park Place",
|
1522
|
-
line_2: "",
|
1523
|
-
city: "Beverly Hills",
|
1524
|
-
state: "CA",
|
1525
|
-
zip: "90210",
|
1526
|
-
),
|
1527
|
-
phone: "222-222-2222",
|
1528
|
-
),
|
1529
|
-
],
|
1530
|
-
},
|
1531
|
-
as_lines: true,
|
1532
|
-
type: :delete,
|
1533
|
-
indentation_level: 1,
|
2042
|
+
]
|
1534
2043
|
)
|
1535
|
-
expect(tiered_lines).to match([
|
1536
|
-
an_object_having_attributes(
|
1537
|
-
type: :delete,
|
1538
|
-
indentation_level: 1,
|
1539
|
-
value: %({),
|
1540
|
-
collection_bookend: :open,
|
1541
|
-
),
|
1542
|
-
an_object_having_attributes(
|
1543
|
-
type: :delete,
|
1544
|
-
indentation_level: 2,
|
1545
|
-
prefix: %(state: ),
|
1546
|
-
value: %(:down),
|
1547
|
-
add_comma: true,
|
1548
|
-
),
|
1549
|
-
an_object_having_attributes(
|
1550
|
-
type: :delete,
|
1551
|
-
indentation_level: 2,
|
1552
|
-
prefix: %(errors: ),
|
1553
|
-
value: %([),
|
1554
|
-
collection_bookend: :open,
|
1555
|
-
),
|
1556
|
-
an_object_having_attributes(
|
1557
|
-
type: :delete,
|
1558
|
-
indentation_level: 3,
|
1559
|
-
value: %("Container A-234 is partially damaged"),
|
1560
|
-
add_comma: true,
|
1561
|
-
),
|
1562
|
-
an_object_having_attributes(
|
1563
|
-
type: :delete,
|
1564
|
-
indentation_level: 3,
|
1565
|
-
value: %("Vessel B042 was attacked by raccoons"),
|
1566
|
-
add_comma: true,
|
1567
|
-
),
|
1568
|
-
an_object_having_attributes(
|
1569
|
-
type: :delete,
|
1570
|
-
indentation_level: 3,
|
1571
|
-
value: %("Product FDK-3429 is out of stock"),
|
1572
|
-
add_comma: false,
|
1573
|
-
),
|
1574
|
-
an_object_having_attributes(
|
1575
|
-
type: :delete,
|
1576
|
-
indentation_level: 2,
|
1577
|
-
value: %(]),
|
1578
|
-
collection_bookend: :close,
|
1579
|
-
),
|
1580
|
-
an_object_having_attributes(
|
1581
|
-
type: :delete,
|
1582
|
-
indentation_level: 2,
|
1583
|
-
prefix: %(mission_critical: ),
|
1584
|
-
value: %(true),
|
1585
|
-
add_comma: true,
|
1586
|
-
),
|
1587
|
-
an_object_having_attributes(
|
1588
|
-
type: :delete,
|
1589
|
-
indentation_level: 2,
|
1590
|
-
prefix: %(serviceable: ),
|
1591
|
-
value: %(false),
|
1592
|
-
add_comma: true,
|
1593
|
-
),
|
1594
|
-
an_object_having_attributes(
|
1595
|
-
type: :delete,
|
1596
|
-
indentation_level: 2,
|
1597
|
-
prefix: %(outstanding_orders: ),
|
1598
|
-
value: %([),
|
1599
|
-
collection_bookend: :open,
|
1600
|
-
),
|
1601
|
-
an_object_having_attributes(
|
1602
|
-
type: :delete,
|
1603
|
-
indentation_level: 3,
|
1604
|
-
value: a_string_matching(
|
1605
|
-
%r(#<SuperDiff::Test::Order:0x[a-f0-9]+ \{),
|
1606
|
-
),
|
1607
|
-
collection_bookend: :open,
|
1608
|
-
),
|
1609
|
-
an_object_having_attributes(
|
1610
|
-
type: :delete,
|
1611
|
-
indentation_level: 4,
|
1612
|
-
prefix: %(@items=),
|
1613
|
-
value: %([),
|
1614
|
-
collection_bookend: :open,
|
1615
|
-
),
|
1616
|
-
an_object_having_attributes(
|
1617
|
-
type: :delete,
|
1618
|
-
indentation_level: 5,
|
1619
|
-
value: a_string_matching(
|
1620
|
-
%r(#<SuperDiff::Test::Item:0x[a-f0-9]+ \{),
|
1621
|
-
),
|
1622
|
-
collection_bookend: :open,
|
1623
|
-
),
|
1624
|
-
an_object_having_attributes(
|
1625
|
-
type: :delete,
|
1626
|
-
indentation_level: 6,
|
1627
|
-
prefix: %(@name=),
|
1628
|
-
value: %("ham"),
|
1629
|
-
add_comma: true,
|
1630
|
-
),
|
1631
|
-
an_object_having_attributes(
|
1632
|
-
type: :delete,
|
1633
|
-
indentation_level: 6,
|
1634
|
-
prefix: %(@quantity=),
|
1635
|
-
value: %(1),
|
1636
|
-
add_comma: false,
|
1637
|
-
),
|
1638
|
-
an_object_having_attributes(
|
1639
|
-
type: :delete,
|
1640
|
-
indentation_level: 5,
|
1641
|
-
value: %(}>),
|
1642
|
-
collection_bookend: :close,
|
1643
|
-
),
|
1644
|
-
an_object_having_attributes(
|
1645
|
-
type: :delete,
|
1646
|
-
indentation_level: 5,
|
1647
|
-
value: a_string_matching(
|
1648
|
-
%r(#<SuperDiff::Test::Item:0x[a-f0-9]+ \{),
|
1649
|
-
),
|
1650
|
-
collection_bookend: :open,
|
1651
|
-
),
|
1652
|
-
an_object_having_attributes(
|
1653
|
-
type: :delete,
|
1654
|
-
indentation_level: 6,
|
1655
|
-
prefix: %(@name=),
|
1656
|
-
value: %("eggs"),
|
1657
|
-
add_comma: true,
|
1658
|
-
),
|
1659
|
-
an_object_having_attributes(
|
1660
|
-
type: :delete,
|
1661
|
-
indentation_level: 6,
|
1662
|
-
prefix: %(@quantity=),
|
1663
|
-
value: %(2),
|
1664
|
-
add_comma: false,
|
1665
|
-
),
|
1666
|
-
an_object_having_attributes(
|
1667
|
-
type: :delete,
|
1668
|
-
indentation_level: 5,
|
1669
|
-
value: %(}>),
|
1670
|
-
collection_bookend: :close,
|
1671
|
-
),
|
1672
|
-
an_object_having_attributes(
|
1673
|
-
type: :delete,
|
1674
|
-
indentation_level: 5,
|
1675
|
-
value: a_string_matching(
|
1676
|
-
%r(#<SuperDiff::Test::Item:0x[a-f0-9]+ \{),
|
1677
|
-
),
|
1678
|
-
collection_bookend: :open,
|
1679
|
-
),
|
1680
|
-
an_object_having_attributes(
|
1681
|
-
type: :delete,
|
1682
|
-
indentation_level: 6,
|
1683
|
-
prefix: %(@name=),
|
1684
|
-
value: %("cheese"),
|
1685
|
-
add_comma: true,
|
1686
|
-
),
|
1687
|
-
an_object_having_attributes(
|
1688
|
-
type: :delete,
|
1689
|
-
indentation_level: 6,
|
1690
|
-
prefix: %(@quantity=),
|
1691
|
-
value: %(1),
|
1692
|
-
add_comma: false,
|
1693
|
-
),
|
1694
|
-
an_object_having_attributes(
|
1695
|
-
type: :delete,
|
1696
|
-
indentation_level: 5,
|
1697
|
-
value: %(}>),
|
1698
|
-
collection_bookend: :close,
|
1699
|
-
),
|
1700
|
-
an_object_having_attributes(
|
1701
|
-
type: :delete,
|
1702
|
-
indentation_level: 4,
|
1703
|
-
value: %(]),
|
1704
|
-
collection_bookend: :close,
|
1705
|
-
),
|
1706
|
-
an_object_having_attributes(
|
1707
|
-
type: :delete,
|
1708
|
-
indentation_level: 3,
|
1709
|
-
value: %(}>),
|
1710
|
-
collection_bookend: :close,
|
1711
|
-
),
|
1712
|
-
an_object_having_attributes(
|
1713
|
-
type: :delete,
|
1714
|
-
indentation_level: 2,
|
1715
|
-
value: %(]),
|
1716
|
-
collection_bookend: :close,
|
1717
|
-
),
|
1718
|
-
an_object_having_attributes(
|
1719
|
-
type: :delete,
|
1720
|
-
indentation_level: 2,
|
1721
|
-
prefix: %(customers: ),
|
1722
|
-
value: %([),
|
1723
|
-
collection_bookend: :open,
|
1724
|
-
),
|
1725
|
-
an_object_having_attributes(
|
1726
|
-
type: :delete,
|
1727
|
-
indentation_level: 3,
|
1728
|
-
value: %(#<SuperDiff::Test::Customer {),
|
1729
|
-
collection_bookend: :open,
|
1730
|
-
),
|
1731
|
-
an_object_having_attributes(
|
1732
|
-
type: :delete,
|
1733
|
-
indentation_level: 4,
|
1734
|
-
prefix: %(name: ),
|
1735
|
-
value: %("Marty McFly"),
|
1736
|
-
add_comma: true,
|
1737
|
-
),
|
1738
|
-
an_object_having_attributes(
|
1739
|
-
type: :delete,
|
1740
|
-
indentation_level: 4,
|
1741
|
-
prefix: %(shipping_address: ),
|
1742
|
-
value: %(#<SuperDiff::Test::ShippingAddress {),
|
1743
|
-
collection_bookend: :open,
|
1744
|
-
),
|
1745
|
-
an_object_having_attributes(
|
1746
|
-
type: :delete,
|
1747
|
-
indentation_level: 5,
|
1748
|
-
prefix: %(line_1: ),
|
1749
|
-
value: %("123 Baltic Ave."),
|
1750
|
-
add_comma: true,
|
1751
|
-
),
|
1752
|
-
an_object_having_attributes(
|
1753
|
-
type: :delete,
|
1754
|
-
indentation_level: 5,
|
1755
|
-
prefix: %(line_2: ),
|
1756
|
-
value: %(""),
|
1757
|
-
add_comma: true,
|
1758
|
-
),
|
1759
|
-
an_object_having_attributes(
|
1760
|
-
type: :delete,
|
1761
|
-
indentation_level: 5,
|
1762
|
-
prefix: %(city: ),
|
1763
|
-
value: %("Hill Valley"),
|
1764
|
-
add_comma: true,
|
1765
|
-
),
|
1766
|
-
an_object_having_attributes(
|
1767
|
-
type: :delete,
|
1768
|
-
indentation_level: 5,
|
1769
|
-
prefix: %(state: ),
|
1770
|
-
value: %("CA"),
|
1771
|
-
add_comma: true,
|
1772
|
-
),
|
1773
|
-
an_object_having_attributes(
|
1774
|
-
type: :delete,
|
1775
|
-
indentation_level: 5,
|
1776
|
-
prefix: %(zip: ),
|
1777
|
-
value: %("90382"),
|
1778
|
-
add_comma: false,
|
1779
|
-
),
|
1780
|
-
an_object_having_attributes(
|
1781
|
-
type: :delete,
|
1782
|
-
indentation_level: 4,
|
1783
|
-
value: %(}>),
|
1784
|
-
add_comma: true,
|
1785
|
-
collection_bookend: :close,
|
1786
|
-
),
|
1787
|
-
an_object_having_attributes(
|
1788
|
-
type: :delete,
|
1789
|
-
indentation_level: 4,
|
1790
|
-
prefix: %(phone: ),
|
1791
|
-
value: %("111-111-1111"),
|
1792
|
-
add_comma: false,
|
1793
|
-
),
|
1794
|
-
an_object_having_attributes(
|
1795
|
-
type: :delete,
|
1796
|
-
indentation_level: 3,
|
1797
|
-
value: %(}>),
|
1798
|
-
add_comma: true,
|
1799
|
-
),
|
1800
|
-
an_object_having_attributes(
|
1801
|
-
type: :delete,
|
1802
|
-
indentation_level: 3,
|
1803
|
-
value: %(#<SuperDiff::Test::Customer {),
|
1804
|
-
collection_bookend: :open,
|
1805
|
-
),
|
1806
|
-
an_object_having_attributes(
|
1807
|
-
type: :delete,
|
1808
|
-
indentation_level: 4,
|
1809
|
-
prefix: %(name: ),
|
1810
|
-
value: %("Doc Brown"),
|
1811
|
-
add_comma: true,
|
1812
|
-
),
|
1813
|
-
an_object_having_attributes(
|
1814
|
-
type: :delete,
|
1815
|
-
indentation_level: 4,
|
1816
|
-
prefix: %(shipping_address: ),
|
1817
|
-
value: %(#<SuperDiff::Test::ShippingAddress {),
|
1818
|
-
collection_bookend: :open,
|
1819
|
-
),
|
1820
|
-
an_object_having_attributes(
|
1821
|
-
type: :delete,
|
1822
|
-
indentation_level: 5,
|
1823
|
-
prefix: %(line_1: ),
|
1824
|
-
value: %("456 Park Place"),
|
1825
|
-
add_comma: true,
|
1826
|
-
),
|
1827
|
-
an_object_having_attributes(
|
1828
|
-
type: :delete,
|
1829
|
-
indentation_level: 5,
|
1830
|
-
prefix: %(line_2: ),
|
1831
|
-
value: %(""),
|
1832
|
-
add_comma: true,
|
1833
|
-
),
|
1834
|
-
an_object_having_attributes(
|
1835
|
-
type: :delete,
|
1836
|
-
indentation_level: 5,
|
1837
|
-
prefix: %(city: ),
|
1838
|
-
value: %("Beverly Hills"),
|
1839
|
-
add_comma: true,
|
1840
|
-
),
|
1841
|
-
an_object_having_attributes(
|
1842
|
-
type: :delete,
|
1843
|
-
indentation_level: 5,
|
1844
|
-
prefix: %(state: ),
|
1845
|
-
value: %("CA"),
|
1846
|
-
add_comma: true,
|
1847
|
-
),
|
1848
|
-
an_object_having_attributes(
|
1849
|
-
type: :delete,
|
1850
|
-
indentation_level: 5,
|
1851
|
-
prefix: %(zip: ),
|
1852
|
-
value: %("90210"),
|
1853
|
-
add_comma: false,
|
1854
|
-
),
|
1855
|
-
an_object_having_attributes(
|
1856
|
-
type: :delete,
|
1857
|
-
indentation_level: 4,
|
1858
|
-
value: %(}>),
|
1859
|
-
add_comma: true,
|
1860
|
-
collection_bookend: :close,
|
1861
|
-
),
|
1862
|
-
an_object_having_attributes(
|
1863
|
-
type: :delete,
|
1864
|
-
indentation_level: 4,
|
1865
|
-
prefix: %(phone: ),
|
1866
|
-
value: %("222-222-2222"),
|
1867
|
-
add_comma: false,
|
1868
|
-
),
|
1869
|
-
an_object_having_attributes(
|
1870
|
-
type: :delete,
|
1871
|
-
indentation_level: 3,
|
1872
|
-
value: %(}>),
|
1873
|
-
add_comma: false,
|
1874
|
-
collection_bookend: :close,
|
1875
|
-
),
|
1876
|
-
an_object_having_attributes(
|
1877
|
-
type: :delete,
|
1878
|
-
indentation_level: 2,
|
1879
|
-
value: %(]),
|
1880
|
-
add_comma: false,
|
1881
|
-
collection_bookend: :close,
|
1882
|
-
),
|
1883
|
-
an_object_having_attributes(
|
1884
|
-
type: :delete,
|
1885
|
-
indentation_level: 1,
|
1886
|
-
value: %(}),
|
1887
|
-
collection_bookend: :close,
|
1888
|
-
),
|
1889
|
-
])
|
1890
2044
|
end
|
1891
2045
|
end
|
1892
2046
|
end
|
@@ -1894,7 +2048,7 @@ RSpec.describe SuperDiff, type: :unit do
|
|
1894
2048
|
context "given a data structure that refers to itself somewhere inside of it" do
|
1895
2049
|
context "given as_lines: false" do
|
1896
2050
|
it "replaces the reference with ∙∙∙" do
|
1897
|
-
value = [
|
2051
|
+
value = %w[a b c]
|
1898
2052
|
value.insert(1, value)
|
1899
2053
|
string = described_class.inspect_object(value, as_lines: false)
|
1900
2054
|
expect(string).to eq(%(["a", ∙∙∙, "b", "c"]))
|
@@ -1903,52 +2057,55 @@ RSpec.describe SuperDiff, type: :unit do
|
|
1903
2057
|
|
1904
2058
|
context "given as_lines: true" do
|
1905
2059
|
it "replaces the reference with ∙∙∙" do
|
1906
|
-
value = [
|
2060
|
+
value = %w[a b c]
|
1907
2061
|
value.insert(1, value)
|
1908
|
-
tiered_lines =
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
indentation_level: 1,
|
1913
|
-
)
|
1914
|
-
expect(tiered_lines).to match([
|
1915
|
-
an_object_having_attributes(
|
1916
|
-
type: :delete,
|
1917
|
-
indentation_level: 1,
|
1918
|
-
value: %([),
|
1919
|
-
collection_bookend: :open,
|
1920
|
-
),
|
1921
|
-
an_object_having_attributes(
|
1922
|
-
type: :delete,
|
1923
|
-
indentation_level: 2,
|
1924
|
-
value: %("a"),
|
1925
|
-
add_comma: true,
|
1926
|
-
),
|
1927
|
-
an_object_having_attributes(
|
1928
|
-
type: :delete,
|
1929
|
-
indentation_level: 2,
|
1930
|
-
value: %(∙∙∙),
|
1931
|
-
add_comma: true,
|
1932
|
-
),
|
1933
|
-
an_object_having_attributes(
|
1934
|
-
type: :delete,
|
1935
|
-
indentation_level: 2,
|
1936
|
-
value: %("b"),
|
1937
|
-
add_comma: true,
|
1938
|
-
),
|
1939
|
-
an_object_having_attributes(
|
1940
|
-
type: :delete,
|
1941
|
-
indentation_level: 2,
|
1942
|
-
value: %("c"),
|
1943
|
-
add_comma: false,
|
1944
|
-
),
|
1945
|
-
an_object_having_attributes(
|
2062
|
+
tiered_lines =
|
2063
|
+
described_class.inspect_object(
|
2064
|
+
value,
|
2065
|
+
as_lines: true,
|
1946
2066
|
type: :delete,
|
1947
|
-
indentation_level: 1
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
2067
|
+
indentation_level: 1
|
2068
|
+
)
|
2069
|
+
expect(tiered_lines).to match(
|
2070
|
+
[
|
2071
|
+
an_object_having_attributes(
|
2072
|
+
type: :delete,
|
2073
|
+
indentation_level: 1,
|
2074
|
+
value: "[",
|
2075
|
+
collection_bookend: :open
|
2076
|
+
),
|
2077
|
+
an_object_having_attributes(
|
2078
|
+
type: :delete,
|
2079
|
+
indentation_level: 2,
|
2080
|
+
value: %("a"),
|
2081
|
+
add_comma: true
|
2082
|
+
),
|
2083
|
+
an_object_having_attributes(
|
2084
|
+
type: :delete,
|
2085
|
+
indentation_level: 2,
|
2086
|
+
value: "∙∙∙",
|
2087
|
+
add_comma: true
|
2088
|
+
),
|
2089
|
+
an_object_having_attributes(
|
2090
|
+
type: :delete,
|
2091
|
+
indentation_level: 2,
|
2092
|
+
value: %("b"),
|
2093
|
+
add_comma: true
|
2094
|
+
),
|
2095
|
+
an_object_having_attributes(
|
2096
|
+
type: :delete,
|
2097
|
+
indentation_level: 2,
|
2098
|
+
value: %("c"),
|
2099
|
+
add_comma: false
|
2100
|
+
),
|
2101
|
+
an_object_having_attributes(
|
2102
|
+
type: :delete,
|
2103
|
+
indentation_level: 1,
|
2104
|
+
value: "]",
|
2105
|
+
collection_bookend: :close
|
2106
|
+
)
|
2107
|
+
]
|
2108
|
+
)
|
1952
2109
|
end
|
1953
2110
|
end
|
1954
2111
|
end
|