super_diff 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +65 -26
- data/lib/super_diff/active_record/differs/active_record_relation.rb +1 -2
- data/lib/super_diff/active_record/differs.rb +1 -1
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +5 -13
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +1 -3
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +2 -2
- data/lib/super_diff/active_record/object_inspection.rb +1 -1
- data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +1 -2
- data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +1 -2
- data/lib/super_diff/active_record/operation_tree_builders.rb +2 -2
- data/lib/super_diff/active_record/operation_tree_flatteners.rb +1 -1
- data/lib/super_diff/active_record/operation_trees.rb +1 -1
- data/lib/super_diff/active_record.rb +7 -15
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +5 -6
- data/lib/super_diff/active_support/differs.rb +1 -1
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +3 -9
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +1 -1
- data/lib/super_diff/active_support/object_inspection.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +5 -6
- data/lib/super_diff/active_support/operation_tree_builders.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_flatteners.rb +1 -1
- data/lib/super_diff/active_support/operation_trees.rb +1 -1
- data/lib/super_diff/active_support.rb +6 -11
- data/lib/super_diff/colorized_document_extensions.rb +2 -4
- data/lib/super_diff/configuration.rb +14 -8
- data/lib/super_diff/csi/color.rb +4 -4
- data/lib/super_diff/csi/colorized_document.rb +12 -16
- data/lib/super_diff/csi/document.rb +8 -19
- data/lib/super_diff/csi/eight_bit_color.rb +19 -19
- data/lib/super_diff/csi/four_bit_color.rb +82 -31
- data/lib/super_diff/csi/twenty_four_bit_color.rb +12 -11
- data/lib/super_diff/csi/uncolorized_document.rb +2 -6
- data/lib/super_diff/csi.rb +10 -14
- data/lib/super_diff/diff_formatters/collection.rb +35 -41
- data/lib/super_diff/differs/default_object.rb +1 -1
- data/lib/super_diff/differs/defaults.rb +1 -1
- data/lib/super_diff/differs/main.rb +2 -13
- data/lib/super_diff/equality_matchers/array.rb +10 -12
- data/lib/super_diff/equality_matchers/base.rb +1 -1
- data/lib/super_diff/equality_matchers/default.rb +2 -4
- data/lib/super_diff/equality_matchers/defaults.rb +1 -1
- data/lib/super_diff/equality_matchers/hash.rb +10 -12
- data/lib/super_diff/equality_matchers/multiline_string.rb +11 -13
- data/lib/super_diff/equality_matchers/primitive.rb +10 -12
- data/lib/super_diff/equality_matchers/singleline_string.rb +10 -12
- data/lib/super_diff/equality_matchers.rb +1 -1
- data/lib/super_diff/errors.rb +3 -3
- data/lib/super_diff/gem_version.rb +3 -3
- data/lib/super_diff/helpers.rb +10 -10
- data/lib/super_diff/implementation_checks.rb +2 -2
- data/lib/super_diff/line.rb +3 -3
- data/lib/super_diff/object_inspection/inspection_tree.rb +46 -60
- data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +2 -6
- data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +3 -9
- data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +5 -14
- data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +1 -1
- data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +4 -12
- data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +6 -23
- data/lib/super_diff/object_inspection/inspection_tree_builders.rb +9 -9
- data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +8 -20
- data/lib/super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/as_single_line.rb +3 -7
- data/lib/super_diff/object_inspection/nodes/base.rb +9 -14
- data/lib/super_diff/object_inspection/nodes/inspection.rb +26 -34
- data/lib/super_diff/object_inspection/nodes/nesting.rb +1 -1
- data/lib/super_diff/object_inspection/nodes/only_when.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/text.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/when_empty.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_lines.rb +1 -1
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_string.rb +1 -5
- data/lib/super_diff/object_inspection/nodes.rb +7 -7
- data/lib/super_diff/object_inspection.rb +3 -3
- data/lib/super_diff/operation_tree_builders/array.rb +12 -11
- data/lib/super_diff/operation_tree_builders/base.rb +17 -15
- data/lib/super_diff/operation_tree_builders/custom_object.rb +8 -6
- data/lib/super_diff/operation_tree_builders/default_object.rb +29 -21
- data/lib/super_diff/operation_tree_builders/hash.rb +23 -24
- data/lib/super_diff/operation_tree_builders/main.rb +4 -11
- data/lib/super_diff/operation_tree_builders/multiline_string.rb +3 -3
- data/lib/super_diff/operation_tree_builders/time_like.rb +1 -11
- data/lib/super_diff/operation_tree_builders.rb +1 -1
- data/lib/super_diff/operation_tree_flatteners/base.rb +1 -5
- data/lib/super_diff/operation_tree_flatteners/collection.rb +13 -16
- data/lib/super_diff/operation_tree_flatteners/default_object.rb +1 -2
- data/lib/super_diff/operation_tree_flatteners/hash.rb +2 -10
- data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +2 -1
- data/lib/super_diff/operation_tree_flatteners.rb +3 -3
- data/lib/super_diff/operation_trees/base.rb +3 -5
- data/lib/super_diff/operation_trees/default_object.rb +1 -3
- data/lib/super_diff/operations/binary_operation.rb +2 -2
- data/lib/super_diff/operations/unary_operation.rb +1 -1
- data/lib/super_diff/rails.rb +2 -1
- data/lib/super_diff/recursion_guard.rb +5 -4
- data/lib/super_diff/rspec/augmented_matcher.rb +4 -5
- data/lib/super_diff/rspec/differ.rb +6 -13
- data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +3 -2
- data/lib/super_diff/rspec/differs/collection_including.rb +1 -1
- data/lib/super_diff/rspec/differs/hash_including.rb +1 -1
- data/lib/super_diff/rspec/differs.rb +3 -3
- data/lib/super_diff/rspec/matcher_text_builders/base.rb +13 -15
- data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +5 -7
- data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +3 -5
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +1 -5
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +2 -6
- data/lib/super_diff/rspec/matcher_text_builders.rb +5 -8
- data/lib/super_diff/rspec/matcher_text_template.rb +13 -16
- data/lib/super_diff/rspec/monkey_patches.rb +122 -116
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +11 -16
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +2 -1
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +9 -9
- data/lib/super_diff/rspec/object_inspection.rb +1 -1
- data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +11 -10
- data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +7 -6
- data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +11 -10
- data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +22 -17
- data/lib/super_diff/rspec/operation_tree_builders.rb +4 -4
- data/lib/super_diff/rspec.rb +11 -13
- data/lib/super_diff/tiered_lines_elider.rb +87 -115
- data/lib/super_diff/tiered_lines_formatter.rb +5 -9
- data/lib/super_diff/version.rb +1 -1
- data/lib/super_diff.rb +4 -9
- data/spec/examples.txt +493 -485
- data/spec/integration/rails/active_record_spec.rb +3 -1
- data/spec/integration/rails/engines_spec.rb +20 -0
- data/spec/integration/rails/hash_with_indifferent_access_spec.rb +3 -1
- data/spec/integration/rspec/be_falsey_matcher_spec.rb +40 -35
- data/spec/integration/rspec/be_matcher_spec.rb +360 -320
- data/spec/integration/rspec/be_nil_matcher_spec.rb +38 -34
- data/spec/integration/rspec/be_predicate_matcher_spec.rb +376 -359
- data/spec/integration/rspec/be_truthy_matcher_spec.rb +38 -33
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +242 -239
- data/spec/integration/rspec/eq_matcher_spec.rb +595 -557
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +294 -286
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +291 -297
- data/spec/integration/rspec/include_matcher_spec.rb +317 -215
- data/spec/integration/rspec/match_array_matcher_spec.rb +276 -273
- data/spec/integration/rspec/match_matcher_spec.rb +847 -834
- data/spec/integration/rspec/raise_error_matcher_spec.rb +468 -453
- data/spec/integration/rspec/respond_to_matcher_spec.rb +702 -697
- data/spec/integration/rspec/third_party_matcher_spec.rb +142 -138
- data/spec/integration/rspec/unhandled_errors_spec.rb +88 -84
- data/spec/spec_helper.rb +17 -20
- data/spec/support/command_runner.rb +34 -57
- data/spec/support/integration/helpers.rb +35 -28
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +28 -23
- data/spec/support/integration/test_programs/base.rb +12 -17
- data/spec/support/integration/test_programs/plain.rb +6 -0
- data/spec/support/integration/test_programs/rspec_active_record.rb +4 -1
- data/spec/support/integration/test_programs/rspec_active_support.rb +4 -1
- data/spec/support/integration/test_programs/rspec_rails.rb +4 -1
- data/spec/support/integration/test_programs/rspec_rails_engine.rb +30 -0
- data/spec/support/models/active_record/person.rb +6 -4
- data/spec/support/models/active_record/shipping_address.rb +9 -10
- data/spec/support/models/customer.rb +2 -4
- data/spec/support/models/player.rb +3 -6
- data/spec/support/models/shipping_address.rb +4 -13
- data/spec/support/shared_examples/active_record.rb +232 -214
- data/spec/support/shared_examples/active_support.rb +53 -51
- data/spec/support/shared_examples/elided_diffs.rb +405 -381
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +424 -388
- data/spec/support/shared_examples/key.rb +123 -0
- data/spec/support/unit/helpers.rb +1 -3
- data/spec/support/unit/matchers/match_output.rb +12 -13
- data/spec/unit/active_record/object_inspection_spec.rb +222 -206
- data/spec/unit/equality_matchers/main_spec.rb +1049 -984
- data/spec/unit/helpers_spec.rb +14 -21
- data/spec/unit/operation_tree_flatteners/array_spec.rb +557 -524
- data/spec/unit/operation_tree_flatteners/custom_object_spec.rb +619 -601
- data/spec/unit/operation_tree_flatteners/default_object_spec.rb +619 -621
- data/spec/unit/operation_tree_flatteners/hash_spec.rb +595 -556
- data/spec/unit/operation_tree_flatteners/multiline_string_spec.rb +102 -92
- data/spec/unit/rspec/matchers/be_compared_to_spec.rb +3 -3
- data/spec/unit/rspec/matchers/be_predicate_spec.rb +3 -3
- data/spec/unit/rspec/matchers/contain_exactly_spec.rb +1 -1
- data/spec/unit/rspec/matchers/have_attributes_spec.rb +1 -1
- data/spec/unit/rspec/matchers/have_predicate_spec.rb +2 -2
- data/spec/unit/rspec/matchers/include_spec.rb +2 -2
- data/spec/unit/rspec/matchers/match_array_spec.rb +2 -2
- data/spec/unit/rspec/matchers/raise_error_spec.rb +5 -5
- data/spec/unit/rspec/matchers/respond_to_spec.rb +23 -16
- data/spec/unit/rspec/object_inspection_spec.rb +349 -324
- data/spec/unit/super_diff_spec.rb +1542 -1449
- data/spec/unit/tiered_lines_elider_spec.rb +3508 -3536
- data/spec/unit/tiered_lines_formatter_spec.rb +54 -116
- data/super_diff.gemspec +13 -12
- metadata +73 -73
- data/spec/tmp/warnings_logger/all_warnings.txt +0 -2
@@ -3,122 +3,129 @@ require "spec_helper"
|
|
3
3
|
RSpec.describe SuperDiff::OperationTreeFlatteners::Array do
|
4
4
|
context "given an empty tree" do
|
5
5
|
it "returns a set of lines which are simply the open token and close token" do
|
6
|
-
expect(described_class.call([])).to match(
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
6
|
+
expect(described_class.call([])).to match(
|
7
|
+
[
|
8
|
+
an_object_having_attributes(
|
9
|
+
type: :noop,
|
10
|
+
indentation_level: 0,
|
11
|
+
prefix: "",
|
12
|
+
value: "[",
|
13
|
+
collection_bookend: :open,
|
14
|
+
complete_bookend: :open
|
15
|
+
),
|
16
|
+
an_object_having_attributes(
|
17
|
+
type: :noop,
|
18
|
+
indentation_level: 0,
|
19
|
+
prefix: "",
|
20
|
+
value: "]",
|
21
|
+
collection_bookend: :close,
|
22
|
+
complete_bookend: :close
|
23
|
+
)
|
24
|
+
]
|
25
|
+
)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
29
|
context "given a tree of only noops" do
|
28
30
|
it "returns a series of lines from inspecting each value, creating multiple lines upon encountering inner data structures" do
|
29
31
|
collection = Array.new(3) { :some_value }
|
30
|
-
operation_tree =
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
32
|
+
operation_tree =
|
33
|
+
SuperDiff::OperationTrees::Array.new(
|
34
|
+
[
|
35
|
+
double(
|
36
|
+
:operation,
|
37
|
+
name: :noop,
|
38
|
+
collection: collection,
|
39
|
+
value: "foo",
|
40
|
+
index: 0
|
41
|
+
),
|
42
|
+
double(
|
43
|
+
:operation,
|
44
|
+
name: :noop,
|
45
|
+
collection: collection,
|
46
|
+
value: ["one fish", "two fish"],
|
47
|
+
index: 1
|
48
|
+
),
|
49
|
+
double(
|
50
|
+
:operation,
|
51
|
+
name: :noop,
|
52
|
+
collection: collection,
|
53
|
+
value: "bar",
|
54
|
+
index: 2
|
55
|
+
)
|
56
|
+
]
|
57
|
+
)
|
53
58
|
|
54
59
|
flattened_operation_tree = described_class.call(operation_tree)
|
55
60
|
|
56
|
-
expect(flattened_operation_tree).to match(
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
61
|
+
expect(flattened_operation_tree).to match(
|
62
|
+
[
|
63
|
+
an_object_having_attributes(
|
64
|
+
type: :noop,
|
65
|
+
indentation_level: 0,
|
66
|
+
prefix: "",
|
67
|
+
value: "[",
|
68
|
+
collection_bookend: :open,
|
69
|
+
complete_bookend: :open,
|
70
|
+
add_comma: false
|
71
|
+
),
|
72
|
+
an_object_having_attributes(
|
73
|
+
type: :noop,
|
74
|
+
indentation_level: 1,
|
75
|
+
prefix: "",
|
76
|
+
value: %("foo"),
|
77
|
+
add_comma: true
|
78
|
+
),
|
79
|
+
an_object_having_attributes(
|
80
|
+
type: :noop,
|
81
|
+
indentation_level: 1,
|
82
|
+
prefix: "",
|
83
|
+
value: "[",
|
84
|
+
collection_bookend: :open,
|
85
|
+
complete_bookend: nil,
|
86
|
+
add_comma: false
|
87
|
+
),
|
88
|
+
an_object_having_attributes(
|
89
|
+
type: :noop,
|
90
|
+
indentation_level: 2,
|
91
|
+
prefix: "",
|
92
|
+
value: %("one fish"),
|
93
|
+
add_comma: true
|
94
|
+
),
|
95
|
+
an_object_having_attributes(
|
96
|
+
type: :noop,
|
97
|
+
indentation_level: 2,
|
98
|
+
prefix: "",
|
99
|
+
value: %("two fish"),
|
100
|
+
add_comma: false
|
101
|
+
),
|
102
|
+
an_object_having_attributes(
|
103
|
+
type: :noop,
|
104
|
+
indentation_level: 1,
|
105
|
+
prefix: "",
|
106
|
+
value: "]",
|
107
|
+
collection_bookend: :close,
|
108
|
+
complete_bookend: nil,
|
109
|
+
add_comma: true
|
110
|
+
),
|
111
|
+
an_object_having_attributes(
|
112
|
+
type: :noop,
|
113
|
+
indentation_level: 1,
|
114
|
+
prefix: "",
|
115
|
+
value: %("bar"),
|
116
|
+
add_comma: false
|
117
|
+
),
|
118
|
+
an_object_having_attributes(
|
119
|
+
type: :noop,
|
120
|
+
indentation_level: 0,
|
121
|
+
prefix: "",
|
122
|
+
value: "]",
|
123
|
+
collection_bookend: :close,
|
124
|
+
complete_bookend: :close,
|
125
|
+
add_comma: false
|
126
|
+
)
|
127
|
+
]
|
128
|
+
)
|
122
129
|
end
|
123
130
|
end
|
124
131
|
|
@@ -126,126 +133,131 @@ RSpec.describe SuperDiff::OperationTreeFlatteners::Array do
|
|
126
133
|
it "returns a series of lines from inspecting each value, creating multiple lines upon encountering inner data structures" do
|
127
134
|
expected = Array.new(3) { :some_value }
|
128
135
|
actual = Array.new(4) { :some_value }
|
129
|
-
operation_tree =
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
136
|
+
operation_tree =
|
137
|
+
SuperDiff::OperationTrees::Array.new(
|
138
|
+
[
|
139
|
+
double(
|
140
|
+
:operation,
|
141
|
+
name: :delete,
|
142
|
+
collection: expected,
|
143
|
+
value: "foo",
|
144
|
+
index: 0
|
145
|
+
),
|
146
|
+
double(
|
147
|
+
:operation,
|
148
|
+
name: :insert,
|
149
|
+
collection: actual,
|
150
|
+
value: "zoo",
|
151
|
+
index: 0
|
152
|
+
),
|
153
|
+
double(
|
154
|
+
:operation,
|
155
|
+
name: :noop,
|
156
|
+
collection: actual,
|
157
|
+
value: ["one fish", "two fish"],
|
158
|
+
index: 1
|
159
|
+
),
|
160
|
+
double(
|
161
|
+
:operation,
|
162
|
+
name: :noop,
|
163
|
+
collection: actual,
|
164
|
+
value: "bar",
|
165
|
+
index: 2
|
166
|
+
),
|
167
|
+
double(
|
168
|
+
:operation,
|
169
|
+
name: :insert,
|
170
|
+
collection: actual,
|
171
|
+
value: "baz",
|
172
|
+
index: 3
|
173
|
+
)
|
174
|
+
]
|
175
|
+
)
|
166
176
|
|
167
177
|
flattened_operation_tree = described_class.call(operation_tree)
|
168
178
|
|
169
|
-
expect(flattened_operation_tree).to match(
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
179
|
+
expect(flattened_operation_tree).to match(
|
180
|
+
[
|
181
|
+
an_object_having_attributes(
|
182
|
+
type: :noop,
|
183
|
+
indentation_level: 0,
|
184
|
+
prefix: "",
|
185
|
+
value: "[",
|
186
|
+
collection_bookend: :open,
|
187
|
+
complete_bookend: :open,
|
188
|
+
add_comma: false
|
189
|
+
),
|
190
|
+
an_object_having_attributes(
|
191
|
+
type: :delete,
|
192
|
+
indentation_level: 1,
|
193
|
+
prefix: "",
|
194
|
+
value: %("foo"),
|
195
|
+
add_comma: true
|
196
|
+
),
|
197
|
+
an_object_having_attributes(
|
198
|
+
type: :insert,
|
199
|
+
indentation_level: 1,
|
200
|
+
prefix: "",
|
201
|
+
value: %("zoo"),
|
202
|
+
add_comma: true
|
203
|
+
),
|
204
|
+
an_object_having_attributes(
|
205
|
+
type: :noop,
|
206
|
+
indentation_level: 1,
|
207
|
+
prefix: "",
|
208
|
+
value: "[",
|
209
|
+
collection_bookend: :open,
|
210
|
+
complete_bookend: nil,
|
211
|
+
add_comma: false
|
212
|
+
),
|
213
|
+
an_object_having_attributes(
|
214
|
+
type: :noop,
|
215
|
+
indentation_level: 2,
|
216
|
+
prefix: "",
|
217
|
+
value: %("one fish"),
|
218
|
+
add_comma: true
|
219
|
+
),
|
220
|
+
an_object_having_attributes(
|
221
|
+
type: :noop,
|
222
|
+
indentation_level: 2,
|
223
|
+
prefix: "",
|
224
|
+
value: %("two fish"),
|
225
|
+
add_comma: false
|
226
|
+
),
|
227
|
+
an_object_having_attributes(
|
228
|
+
type: :noop,
|
229
|
+
indentation_level: 1,
|
230
|
+
prefix: "",
|
231
|
+
value: "]",
|
232
|
+
collection_bookend: :close,
|
233
|
+
complete_bookend: nil,
|
234
|
+
add_comma: true
|
235
|
+
),
|
236
|
+
an_object_having_attributes(
|
237
|
+
type: :noop,
|
238
|
+
indentation_level: 1,
|
239
|
+
prefix: "",
|
240
|
+
value: %("bar"),
|
241
|
+
add_comma: true
|
242
|
+
),
|
243
|
+
an_object_having_attributes(
|
244
|
+
type: :insert,
|
245
|
+
indentation_level: 1,
|
246
|
+
prefix: "",
|
247
|
+
value: %("baz"),
|
248
|
+
add_comma: false
|
249
|
+
),
|
250
|
+
an_object_having_attributes(
|
251
|
+
type: :noop,
|
252
|
+
indentation_level: 0,
|
253
|
+
prefix: "",
|
254
|
+
value: "]",
|
255
|
+
collection_bookend: :close,
|
256
|
+
complete_bookend: :close,
|
257
|
+
add_comma: false
|
258
|
+
)
|
259
|
+
]
|
260
|
+
)
|
249
261
|
end
|
250
262
|
end
|
251
263
|
|
@@ -253,129 +265,137 @@ RSpec.describe SuperDiff::OperationTreeFlatteners::Array do
|
|
253
265
|
it "splits change operations into multiple lines" do
|
254
266
|
collection = Array.new(3) { :some_value }
|
255
267
|
subcollection = Array.new(2) { :some_value }
|
256
|
-
operation_tree =
|
257
|
-
|
258
|
-
|
259
|
-
name: :noop,
|
260
|
-
collection: collection,
|
261
|
-
value: "foo",
|
262
|
-
index: 0,
|
263
|
-
),
|
264
|
-
double(
|
265
|
-
:operation,
|
266
|
-
name: :change,
|
267
|
-
left_collection: collection,
|
268
|
-
left_index: 1,
|
269
|
-
right_collection: collection,
|
270
|
-
right_index: 1,
|
271
|
-
children: SuperDiff::OperationTrees::Array.new([
|
268
|
+
operation_tree =
|
269
|
+
SuperDiff::OperationTrees::Array.new(
|
270
|
+
[
|
272
271
|
double(
|
273
272
|
:operation,
|
274
273
|
name: :noop,
|
275
|
-
collection:
|
276
|
-
value: "
|
277
|
-
index: 0
|
274
|
+
collection: collection,
|
275
|
+
value: "foo",
|
276
|
+
index: 0
|
278
277
|
),
|
279
278
|
double(
|
280
279
|
:operation,
|
281
|
-
name: :
|
282
|
-
|
283
|
-
|
284
|
-
|
280
|
+
name: :change,
|
281
|
+
left_collection: collection,
|
282
|
+
left_index: 1,
|
283
|
+
right_collection: collection,
|
284
|
+
right_index: 1,
|
285
|
+
children:
|
286
|
+
SuperDiff::OperationTrees::Array.new(
|
287
|
+
[
|
288
|
+
double(
|
289
|
+
:operation,
|
290
|
+
name: :noop,
|
291
|
+
collection: subcollection,
|
292
|
+
value: "one fish",
|
293
|
+
index: 0
|
294
|
+
),
|
295
|
+
double(
|
296
|
+
:operation,
|
297
|
+
name: :delete,
|
298
|
+
collection: subcollection,
|
299
|
+
value: "two fish",
|
300
|
+
index: 1
|
301
|
+
),
|
302
|
+
double(
|
303
|
+
:operation,
|
304
|
+
name: :insert,
|
305
|
+
collection: subcollection,
|
306
|
+
value: "blue fish",
|
307
|
+
index: 1
|
308
|
+
)
|
309
|
+
]
|
310
|
+
)
|
285
311
|
),
|
286
312
|
double(
|
287
313
|
:operation,
|
288
|
-
name: :
|
289
|
-
collection:
|
290
|
-
value: "
|
291
|
-
index:
|
292
|
-
)
|
293
|
-
]
|
294
|
-
)
|
295
|
-
double(
|
296
|
-
:operation,
|
297
|
-
name: :noop,
|
298
|
-
collection: collection,
|
299
|
-
value: "bar",
|
300
|
-
index: 2,
|
301
|
-
),
|
302
|
-
])
|
314
|
+
name: :noop,
|
315
|
+
collection: collection,
|
316
|
+
value: "bar",
|
317
|
+
index: 2
|
318
|
+
)
|
319
|
+
]
|
320
|
+
)
|
303
321
|
|
304
322
|
flattened_operation_tree = described_class.call(operation_tree)
|
305
323
|
|
306
|
-
expect(flattened_operation_tree).to match(
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
324
|
+
expect(flattened_operation_tree).to match(
|
325
|
+
[
|
326
|
+
an_object_having_attributes(
|
327
|
+
type: :noop,
|
328
|
+
indentation_level: 0,
|
329
|
+
prefix: "",
|
330
|
+
value: "[",
|
331
|
+
collection_bookend: :open,
|
332
|
+
complete_bookend: :open,
|
333
|
+
add_comma: false
|
334
|
+
),
|
335
|
+
an_object_having_attributes(
|
336
|
+
type: :noop,
|
337
|
+
indentation_level: 1,
|
338
|
+
prefix: "",
|
339
|
+
value: %("foo"),
|
340
|
+
add_comma: true
|
341
|
+
),
|
342
|
+
an_object_having_attributes(
|
343
|
+
type: :noop,
|
344
|
+
indentation_level: 1,
|
345
|
+
prefix: "",
|
346
|
+
value: "[",
|
347
|
+
collection_bookend: :open,
|
348
|
+
complete_bookend: nil,
|
349
|
+
add_comma: false
|
350
|
+
),
|
351
|
+
an_object_having_attributes(
|
352
|
+
type: :noop,
|
353
|
+
indentation_level: 2,
|
354
|
+
prefix: "",
|
355
|
+
value: %("one fish"),
|
356
|
+
add_comma: true
|
357
|
+
),
|
358
|
+
an_object_having_attributes(
|
359
|
+
type: :delete,
|
360
|
+
indentation_level: 2,
|
361
|
+
prefix: "",
|
362
|
+
value: %("two fish"),
|
363
|
+
add_comma: false
|
364
|
+
),
|
365
|
+
an_object_having_attributes(
|
366
|
+
type: :insert,
|
367
|
+
indentation_level: 2,
|
368
|
+
prefix: "",
|
369
|
+
value: %("blue fish"),
|
370
|
+
add_comma: false
|
371
|
+
),
|
372
|
+
an_object_having_attributes(
|
373
|
+
type: :noop,
|
374
|
+
indentation_level: 1,
|
375
|
+
prefix: "",
|
376
|
+
value: "]",
|
377
|
+
collection_bookend: :close,
|
378
|
+
complete_bookend: nil,
|
379
|
+
add_comma: true
|
380
|
+
),
|
381
|
+
an_object_having_attributes(
|
382
|
+
type: :noop,
|
383
|
+
indentation_level: 1,
|
384
|
+
prefix: "",
|
385
|
+
value: %("bar"),
|
386
|
+
add_comma: false
|
387
|
+
),
|
388
|
+
an_object_having_attributes(
|
389
|
+
type: :noop,
|
390
|
+
indentation_level: 0,
|
391
|
+
prefix: "",
|
392
|
+
value: "]",
|
393
|
+
collection_bookend: :close,
|
394
|
+
complete_bookend: :close,
|
395
|
+
add_comma: false
|
396
|
+
)
|
397
|
+
]
|
398
|
+
)
|
379
399
|
end
|
380
400
|
end
|
381
401
|
|
@@ -385,87 +405,92 @@ RSpec.describe SuperDiff::OperationTreeFlatteners::Array do
|
|
385
405
|
right_collection = Array.new(2) { :some_value }
|
386
406
|
right_collection << right_collection
|
387
407
|
|
388
|
-
operation_tree =
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
408
|
+
operation_tree =
|
409
|
+
SuperDiff::OperationTrees::Array.new(
|
410
|
+
[
|
411
|
+
double(
|
412
|
+
:operation,
|
413
|
+
name: :noop,
|
414
|
+
collection: right_collection,
|
415
|
+
value: "foo",
|
416
|
+
index: 0
|
417
|
+
),
|
418
|
+
double(
|
419
|
+
:operation,
|
420
|
+
name: :noop,
|
421
|
+
collection: right_collection,
|
422
|
+
value: "bar",
|
423
|
+
index: 1
|
424
|
+
),
|
425
|
+
double(
|
426
|
+
:operation,
|
427
|
+
name: :delete,
|
428
|
+
collection: left_collection,
|
429
|
+
value: "baz",
|
430
|
+
index: 2
|
431
|
+
),
|
432
|
+
double(
|
433
|
+
:operation,
|
434
|
+
name: :insert,
|
435
|
+
collection: right_collection,
|
436
|
+
value: right_collection,
|
437
|
+
index: 2
|
438
|
+
)
|
439
|
+
]
|
440
|
+
)
|
418
441
|
|
419
442
|
flattened_operation_tree = described_class.call(operation_tree)
|
420
443
|
|
421
|
-
expect(flattened_operation_tree).to match(
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
444
|
+
expect(flattened_operation_tree).to match(
|
445
|
+
[
|
446
|
+
an_object_having_attributes(
|
447
|
+
type: :noop,
|
448
|
+
indentation_level: 0,
|
449
|
+
prefix: "",
|
450
|
+
value: "[",
|
451
|
+
collection_bookend: :open,
|
452
|
+
complete_bookend: :open,
|
453
|
+
add_comma: false
|
454
|
+
),
|
455
|
+
an_object_having_attributes(
|
456
|
+
type: :noop,
|
457
|
+
indentation_level: 1,
|
458
|
+
prefix: "",
|
459
|
+
value: %("foo"),
|
460
|
+
add_comma: true
|
461
|
+
),
|
462
|
+
an_object_having_attributes(
|
463
|
+
type: :noop,
|
464
|
+
indentation_level: 1,
|
465
|
+
prefix: "",
|
466
|
+
value: %("bar"),
|
467
|
+
add_comma: true
|
468
|
+
),
|
469
|
+
an_object_having_attributes(
|
470
|
+
type: :delete,
|
471
|
+
indentation_level: 1,
|
472
|
+
prefix: "",
|
473
|
+
value: %("baz"),
|
474
|
+
add_comma: false
|
475
|
+
),
|
476
|
+
an_object_having_attributes(
|
477
|
+
type: :insert,
|
478
|
+
indentation_level: 1,
|
479
|
+
prefix: "",
|
480
|
+
value: "∙∙∙",
|
481
|
+
add_comma: false
|
482
|
+
),
|
483
|
+
an_object_having_attributes(
|
484
|
+
type: :noop,
|
485
|
+
indentation_level: 0,
|
486
|
+
prefix: "",
|
487
|
+
value: "]",
|
488
|
+
collection_bookend: :close,
|
489
|
+
complete_bookend: :close,
|
490
|
+
add_comma: false
|
491
|
+
)
|
492
|
+
]
|
493
|
+
)
|
469
494
|
end
|
470
495
|
end
|
471
496
|
|
@@ -476,129 +501,137 @@ RSpec.describe SuperDiff::OperationTreeFlatteners::Array do
|
|
476
501
|
right_subcollection = Array.new(1) { :some_value }
|
477
502
|
right_subcollection << right_subcollection
|
478
503
|
|
479
|
-
operation_tree =
|
480
|
-
|
481
|
-
|
482
|
-
name: :noop,
|
483
|
-
collection: collection,
|
484
|
-
value: "foo",
|
485
|
-
index: 0,
|
486
|
-
),
|
487
|
-
double(
|
488
|
-
:operation,
|
489
|
-
name: :change,
|
490
|
-
left_collection: collection,
|
491
|
-
left_index: 1,
|
492
|
-
right_collection: collection,
|
493
|
-
right_index: 1,
|
494
|
-
children: SuperDiff::OperationTrees::Array.new([
|
504
|
+
operation_tree =
|
505
|
+
SuperDiff::OperationTrees::Array.new(
|
506
|
+
[
|
495
507
|
double(
|
496
508
|
:operation,
|
497
509
|
name: :noop,
|
498
|
-
collection:
|
499
|
-
value: "
|
500
|
-
index: 0
|
510
|
+
collection: collection,
|
511
|
+
value: "foo",
|
512
|
+
index: 0
|
501
513
|
),
|
502
514
|
double(
|
503
515
|
:operation,
|
504
|
-
name: :
|
505
|
-
|
506
|
-
|
507
|
-
|
516
|
+
name: :change,
|
517
|
+
left_collection: collection,
|
518
|
+
left_index: 1,
|
519
|
+
right_collection: collection,
|
520
|
+
right_index: 1,
|
521
|
+
children:
|
522
|
+
SuperDiff::OperationTrees::Array.new(
|
523
|
+
[
|
524
|
+
double(
|
525
|
+
:operation,
|
526
|
+
name: :noop,
|
527
|
+
collection: right_subcollection,
|
528
|
+
value: "bar",
|
529
|
+
index: 0
|
530
|
+
),
|
531
|
+
double(
|
532
|
+
:operation,
|
533
|
+
name: :delete,
|
534
|
+
collection: left_subcollection,
|
535
|
+
value: "baz",
|
536
|
+
index: 1
|
537
|
+
),
|
538
|
+
double(
|
539
|
+
:operation,
|
540
|
+
name: :insert,
|
541
|
+
collection: right_subcollection,
|
542
|
+
value: right_subcollection,
|
543
|
+
index: 1
|
544
|
+
)
|
545
|
+
]
|
546
|
+
)
|
508
547
|
),
|
509
548
|
double(
|
510
549
|
:operation,
|
511
|
-
name: :
|
512
|
-
collection:
|
513
|
-
value:
|
514
|
-
index:
|
515
|
-
)
|
516
|
-
]
|
517
|
-
)
|
518
|
-
double(
|
519
|
-
:operation,
|
520
|
-
name: :noop,
|
521
|
-
collection: collection,
|
522
|
-
value: "qux",
|
523
|
-
index: 2,
|
524
|
-
),
|
525
|
-
])
|
550
|
+
name: :noop,
|
551
|
+
collection: collection,
|
552
|
+
value: "qux",
|
553
|
+
index: 2
|
554
|
+
)
|
555
|
+
]
|
556
|
+
)
|
526
557
|
|
527
558
|
flattened_operation_tree = described_class.call(operation_tree)
|
528
559
|
|
529
|
-
expect(flattened_operation_tree).to match(
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
560
|
+
expect(flattened_operation_tree).to match(
|
561
|
+
[
|
562
|
+
an_object_having_attributes(
|
563
|
+
type: :noop,
|
564
|
+
indentation_level: 0,
|
565
|
+
prefix: "",
|
566
|
+
value: "[",
|
567
|
+
collection_bookend: :open,
|
568
|
+
complete_bookend: :open,
|
569
|
+
add_comma: false
|
570
|
+
),
|
571
|
+
an_object_having_attributes(
|
572
|
+
type: :noop,
|
573
|
+
indentation_level: 1,
|
574
|
+
prefix: "",
|
575
|
+
value: %("foo"),
|
576
|
+
add_comma: true
|
577
|
+
),
|
578
|
+
an_object_having_attributes(
|
579
|
+
type: :noop,
|
580
|
+
indentation_level: 1,
|
581
|
+
prefix: "",
|
582
|
+
value: "[",
|
583
|
+
collection_bookend: :open,
|
584
|
+
complete_bookend: nil,
|
585
|
+
add_comma: false
|
586
|
+
),
|
587
|
+
an_object_having_attributes(
|
588
|
+
type: :noop,
|
589
|
+
indentation_level: 2,
|
590
|
+
prefix: "",
|
591
|
+
value: %("bar"),
|
592
|
+
add_comma: true
|
593
|
+
),
|
594
|
+
an_object_having_attributes(
|
595
|
+
type: :delete,
|
596
|
+
indentation_level: 2,
|
597
|
+
prefix: "",
|
598
|
+
value: %("baz"),
|
599
|
+
add_comma: false
|
600
|
+
),
|
601
|
+
an_object_having_attributes(
|
602
|
+
type: :insert,
|
603
|
+
indentation_level: 2,
|
604
|
+
prefix: "",
|
605
|
+
value: "∙∙∙",
|
606
|
+
add_comma: false
|
607
|
+
),
|
608
|
+
an_object_having_attributes(
|
609
|
+
type: :noop,
|
610
|
+
indentation_level: 1,
|
611
|
+
prefix: "",
|
612
|
+
value: "]",
|
613
|
+
collection_bookend: :close,
|
614
|
+
complete_bookend: nil,
|
615
|
+
add_comma: true
|
616
|
+
),
|
617
|
+
an_object_having_attributes(
|
618
|
+
type: :noop,
|
619
|
+
indentation_level: 1,
|
620
|
+
prefix: "",
|
621
|
+
value: %("qux"),
|
622
|
+
add_comma: false
|
623
|
+
),
|
624
|
+
an_object_having_attributes(
|
625
|
+
type: :noop,
|
626
|
+
indentation_level: 0,
|
627
|
+
prefix: "",
|
628
|
+
value: "]",
|
629
|
+
collection_bookend: :close,
|
630
|
+
complete_bookend: :close,
|
631
|
+
add_comma: false
|
632
|
+
)
|
633
|
+
]
|
634
|
+
)
|
602
635
|
end
|
603
636
|
end
|
604
637
|
end
|