super_diff 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +65 -26
  3. data/lib/super_diff/active_record/differs/active_record_relation.rb +1 -2
  4. data/lib/super_diff/active_record/differs.rb +1 -1
  5. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +5 -13
  6. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +1 -3
  7. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +2 -2
  8. data/lib/super_diff/active_record/object_inspection.rb +1 -1
  9. data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +1 -2
  10. data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +1 -2
  11. data/lib/super_diff/active_record/operation_tree_builders.rb +2 -2
  12. data/lib/super_diff/active_record/operation_tree_flatteners.rb +1 -1
  13. data/lib/super_diff/active_record/operation_trees.rb +1 -1
  14. data/lib/super_diff/active_record.rb +7 -15
  15. data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +5 -6
  16. data/lib/super_diff/active_support/differs.rb +1 -1
  17. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +3 -9
  18. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +1 -1
  19. data/lib/super_diff/active_support/object_inspection.rb +1 -1
  20. data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +5 -6
  21. data/lib/super_diff/active_support/operation_tree_builders.rb +1 -1
  22. data/lib/super_diff/active_support/operation_tree_flatteners.rb +1 -1
  23. data/lib/super_diff/active_support/operation_trees.rb +1 -1
  24. data/lib/super_diff/active_support.rb +6 -11
  25. data/lib/super_diff/colorized_document_extensions.rb +2 -4
  26. data/lib/super_diff/configuration.rb +14 -8
  27. data/lib/super_diff/csi/color.rb +4 -4
  28. data/lib/super_diff/csi/colorized_document.rb +12 -16
  29. data/lib/super_diff/csi/document.rb +8 -19
  30. data/lib/super_diff/csi/eight_bit_color.rb +19 -19
  31. data/lib/super_diff/csi/four_bit_color.rb +82 -31
  32. data/lib/super_diff/csi/twenty_four_bit_color.rb +12 -11
  33. data/lib/super_diff/csi/uncolorized_document.rb +2 -6
  34. data/lib/super_diff/csi.rb +10 -14
  35. data/lib/super_diff/diff_formatters/collection.rb +35 -41
  36. data/lib/super_diff/differs/default_object.rb +1 -1
  37. data/lib/super_diff/differs/defaults.rb +1 -1
  38. data/lib/super_diff/differs/main.rb +2 -13
  39. data/lib/super_diff/equality_matchers/array.rb +10 -12
  40. data/lib/super_diff/equality_matchers/base.rb +1 -1
  41. data/lib/super_diff/equality_matchers/default.rb +2 -4
  42. data/lib/super_diff/equality_matchers/defaults.rb +1 -1
  43. data/lib/super_diff/equality_matchers/hash.rb +10 -12
  44. data/lib/super_diff/equality_matchers/multiline_string.rb +11 -13
  45. data/lib/super_diff/equality_matchers/primitive.rb +10 -12
  46. data/lib/super_diff/equality_matchers/singleline_string.rb +10 -12
  47. data/lib/super_diff/equality_matchers.rb +1 -1
  48. data/lib/super_diff/errors.rb +3 -3
  49. data/lib/super_diff/gem_version.rb +3 -3
  50. data/lib/super_diff/helpers.rb +10 -10
  51. data/lib/super_diff/implementation_checks.rb +2 -2
  52. data/lib/super_diff/line.rb +3 -3
  53. data/lib/super_diff/object_inspection/inspection_tree.rb +46 -60
  54. data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +2 -6
  55. data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +3 -9
  56. data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +5 -14
  57. data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +1 -1
  58. data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +4 -12
  59. data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +6 -23
  60. data/lib/super_diff/object_inspection/inspection_tree_builders.rb +9 -9
  61. data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +8 -20
  62. data/lib/super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines.rb +1 -5
  63. data/lib/super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines.rb +1 -5
  64. data/lib/super_diff/object_inspection/nodes/as_single_line.rb +3 -7
  65. data/lib/super_diff/object_inspection/nodes/base.rb +9 -14
  66. data/lib/super_diff/object_inspection/nodes/inspection.rb +26 -34
  67. data/lib/super_diff/object_inspection/nodes/nesting.rb +1 -1
  68. data/lib/super_diff/object_inspection/nodes/only_when.rb +2 -6
  69. data/lib/super_diff/object_inspection/nodes/text.rb +1 -5
  70. data/lib/super_diff/object_inspection/nodes/when_empty.rb +2 -6
  71. data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +2 -6
  72. data/lib/super_diff/object_inspection/nodes/when_rendering_to_lines.rb +1 -1
  73. data/lib/super_diff/object_inspection/nodes/when_rendering_to_string.rb +1 -5
  74. data/lib/super_diff/object_inspection/nodes.rb +7 -7
  75. data/lib/super_diff/object_inspection.rb +3 -3
  76. data/lib/super_diff/operation_tree_builders/array.rb +12 -11
  77. data/lib/super_diff/operation_tree_builders/base.rb +17 -15
  78. data/lib/super_diff/operation_tree_builders/custom_object.rb +8 -6
  79. data/lib/super_diff/operation_tree_builders/default_object.rb +29 -21
  80. data/lib/super_diff/operation_tree_builders/hash.rb +23 -24
  81. data/lib/super_diff/operation_tree_builders/main.rb +4 -11
  82. data/lib/super_diff/operation_tree_builders/multiline_string.rb +3 -3
  83. data/lib/super_diff/operation_tree_builders/time_like.rb +1 -11
  84. data/lib/super_diff/operation_tree_builders.rb +1 -1
  85. data/lib/super_diff/operation_tree_flatteners/base.rb +1 -5
  86. data/lib/super_diff/operation_tree_flatteners/collection.rb +13 -16
  87. data/lib/super_diff/operation_tree_flatteners/default_object.rb +1 -2
  88. data/lib/super_diff/operation_tree_flatteners/hash.rb +2 -10
  89. data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +2 -1
  90. data/lib/super_diff/operation_tree_flatteners.rb +3 -3
  91. data/lib/super_diff/operation_trees/base.rb +3 -5
  92. data/lib/super_diff/operation_trees/default_object.rb +1 -3
  93. data/lib/super_diff/operations/binary_operation.rb +2 -2
  94. data/lib/super_diff/operations/unary_operation.rb +1 -1
  95. data/lib/super_diff/rails.rb +2 -1
  96. data/lib/super_diff/recursion_guard.rb +5 -4
  97. data/lib/super_diff/rspec/augmented_matcher.rb +4 -5
  98. data/lib/super_diff/rspec/differ.rb +6 -13
  99. data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +3 -2
  100. data/lib/super_diff/rspec/differs/collection_including.rb +1 -1
  101. data/lib/super_diff/rspec/differs/hash_including.rb +1 -1
  102. data/lib/super_diff/rspec/differs.rb +3 -3
  103. data/lib/super_diff/rspec/matcher_text_builders/base.rb +13 -15
  104. data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +5 -7
  105. data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +3 -5
  106. data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +1 -5
  107. data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +2 -6
  108. data/lib/super_diff/rspec/matcher_text_builders.rb +5 -8
  109. data/lib/super_diff/rspec/matcher_text_template.rb +13 -16
  110. data/lib/super_diff/rspec/monkey_patches.rb +122 -116
  111. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +8 -6
  112. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +11 -16
  113. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +2 -1
  114. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +8 -6
  115. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +8 -6
  116. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +9 -9
  117. data/lib/super_diff/rspec/object_inspection.rb +1 -1
  118. data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +11 -10
  119. data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +7 -6
  120. data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +11 -10
  121. data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +22 -17
  122. data/lib/super_diff/rspec/operation_tree_builders.rb +4 -4
  123. data/lib/super_diff/rspec.rb +11 -13
  124. data/lib/super_diff/tiered_lines_elider.rb +87 -115
  125. data/lib/super_diff/tiered_lines_formatter.rb +5 -9
  126. data/lib/super_diff/version.rb +1 -1
  127. data/lib/super_diff.rb +4 -9
  128. data/spec/examples.txt +493 -485
  129. data/spec/integration/rails/active_record_spec.rb +3 -1
  130. data/spec/integration/rails/engines_spec.rb +20 -0
  131. data/spec/integration/rails/hash_with_indifferent_access_spec.rb +3 -1
  132. data/spec/integration/rspec/be_falsey_matcher_spec.rb +40 -35
  133. data/spec/integration/rspec/be_matcher_spec.rb +360 -320
  134. data/spec/integration/rspec/be_nil_matcher_spec.rb +38 -34
  135. data/spec/integration/rspec/be_predicate_matcher_spec.rb +376 -359
  136. data/spec/integration/rspec/be_truthy_matcher_spec.rb +38 -33
  137. data/spec/integration/rspec/contain_exactly_matcher_spec.rb +242 -239
  138. data/spec/integration/rspec/eq_matcher_spec.rb +595 -557
  139. data/spec/integration/rspec/have_attributes_matcher_spec.rb +294 -286
  140. data/spec/integration/rspec/have_predicate_matcher_spec.rb +291 -297
  141. data/spec/integration/rspec/include_matcher_spec.rb +317 -215
  142. data/spec/integration/rspec/match_array_matcher_spec.rb +276 -273
  143. data/spec/integration/rspec/match_matcher_spec.rb +847 -834
  144. data/spec/integration/rspec/raise_error_matcher_spec.rb +468 -453
  145. data/spec/integration/rspec/respond_to_matcher_spec.rb +702 -697
  146. data/spec/integration/rspec/third_party_matcher_spec.rb +142 -138
  147. data/spec/integration/rspec/unhandled_errors_spec.rb +88 -84
  148. data/spec/spec_helper.rb +17 -20
  149. data/spec/support/command_runner.rb +34 -57
  150. data/spec/support/integration/helpers.rb +35 -28
  151. data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +28 -23
  152. data/spec/support/integration/test_programs/base.rb +12 -17
  153. data/spec/support/integration/test_programs/plain.rb +6 -0
  154. data/spec/support/integration/test_programs/rspec_active_record.rb +4 -1
  155. data/spec/support/integration/test_programs/rspec_active_support.rb +4 -1
  156. data/spec/support/integration/test_programs/rspec_rails.rb +4 -1
  157. data/spec/support/integration/test_programs/rspec_rails_engine.rb +30 -0
  158. data/spec/support/models/active_record/person.rb +6 -4
  159. data/spec/support/models/active_record/shipping_address.rb +9 -10
  160. data/spec/support/models/customer.rb +2 -4
  161. data/spec/support/models/player.rb +3 -6
  162. data/spec/support/models/shipping_address.rb +4 -13
  163. data/spec/support/shared_examples/active_record.rb +232 -214
  164. data/spec/support/shared_examples/active_support.rb +53 -51
  165. data/spec/support/shared_examples/elided_diffs.rb +405 -381
  166. data/spec/support/shared_examples/hash_with_indifferent_access.rb +424 -388
  167. data/spec/support/shared_examples/key.rb +123 -0
  168. data/spec/support/unit/helpers.rb +1 -3
  169. data/spec/support/unit/matchers/match_output.rb +12 -13
  170. data/spec/unit/active_record/object_inspection_spec.rb +222 -206
  171. data/spec/unit/equality_matchers/main_spec.rb +1049 -984
  172. data/spec/unit/helpers_spec.rb +14 -21
  173. data/spec/unit/operation_tree_flatteners/array_spec.rb +557 -524
  174. data/spec/unit/operation_tree_flatteners/custom_object_spec.rb +619 -601
  175. data/spec/unit/operation_tree_flatteners/default_object_spec.rb +619 -621
  176. data/spec/unit/operation_tree_flatteners/hash_spec.rb +595 -556
  177. data/spec/unit/operation_tree_flatteners/multiline_string_spec.rb +102 -92
  178. data/spec/unit/rspec/matchers/be_compared_to_spec.rb +3 -3
  179. data/spec/unit/rspec/matchers/be_predicate_spec.rb +3 -3
  180. data/spec/unit/rspec/matchers/contain_exactly_spec.rb +1 -1
  181. data/spec/unit/rspec/matchers/have_attributes_spec.rb +1 -1
  182. data/spec/unit/rspec/matchers/have_predicate_spec.rb +2 -2
  183. data/spec/unit/rspec/matchers/include_spec.rb +2 -2
  184. data/spec/unit/rspec/matchers/match_array_spec.rb +2 -2
  185. data/spec/unit/rspec/matchers/raise_error_spec.rb +5 -5
  186. data/spec/unit/rspec/matchers/respond_to_spec.rb +23 -16
  187. data/spec/unit/rspec/object_inspection_spec.rb +349 -324
  188. data/spec/unit/super_diff_spec.rb +1542 -1449
  189. data/spec/unit/tiered_lines_elider_spec.rb +3508 -3536
  190. data/spec/unit/tiered_lines_formatter_spec.rb +54 -116
  191. data/super_diff.gemspec +13 -12
  192. metadata +73 -73
  193. data/spec/tmp/warnings_logger/all_warnings.txt +0 -2
@@ -5,52 +5,54 @@ RSpec.describe SuperDiff, type: :unit do
5
5
  context "given a hash-including-<something>" do
6
6
  context "given as_lines: false" do
7
7
  it "returns an inspected version of the object" do
8
- string = described_class.inspect_object(
9
- a_hash_including(foo: "bar", baz: "qux"),
10
- as_lines: false,
11
- )
12
- expect(string).to eq(
13
- %(#<a hash including (foo: "bar", baz: "qux")>),
14
- )
8
+ string =
9
+ described_class.inspect_object(
10
+ a_hash_including(foo: "bar", baz: "qux"),
11
+ as_lines: false
12
+ )
13
+ expect(string).to eq(%(#<a hash including (foo: "bar", baz: "qux")>))
15
14
  end
16
15
  end
17
16
 
18
17
  context "given as_lines: true" do
19
18
  it "returns an inspected version of the object as multiple Lines" do
20
- tiered_lines = described_class.inspect_object(
21
- a_hash_including(foo: "bar", baz: "qux"),
22
- as_lines: true,
23
- type: :delete,
24
- indentation_level: 1,
25
- )
26
- expect(tiered_lines).to match([
27
- an_object_having_attributes(
28
- type: :delete,
29
- indentation_level: 1,
30
- value: %[#<a hash including (],
31
- collection_bookend: :open,
32
- ),
33
- an_object_having_attributes(
34
- type: :delete,
35
- indentation_level: 2,
36
- prefix: %[foo: ],
37
- value: %["bar"],
38
- add_comma: true,
39
- ),
40
- an_object_having_attributes(
41
- type: :delete,
42
- indentation_level: 2,
43
- prefix: %[baz: ],
44
- value: %["qux"],
45
- add_comma: false,
46
- ),
47
- an_object_having_attributes(
19
+ tiered_lines =
20
+ described_class.inspect_object(
21
+ a_hash_including(foo: "bar", baz: "qux"),
22
+ as_lines: true,
48
23
  type: :delete,
49
- indentation_level: 1,
50
- value: %[)>],
51
- collection_bookend: :close,
52
- ),
53
- ])
24
+ indentation_level: 1
25
+ )
26
+ expect(tiered_lines).to match(
27
+ [
28
+ an_object_having_attributes(
29
+ type: :delete,
30
+ indentation_level: 1,
31
+ value: "#<a hash including (",
32
+ collection_bookend: :open
33
+ ),
34
+ an_object_having_attributes(
35
+ type: :delete,
36
+ indentation_level: 2,
37
+ prefix: "foo: ",
38
+ value: %["bar"],
39
+ add_comma: true
40
+ ),
41
+ an_object_having_attributes(
42
+ type: :delete,
43
+ indentation_level: 2,
44
+ prefix: "baz: ",
45
+ value: %["qux"],
46
+ add_comma: false
47
+ ),
48
+ an_object_having_attributes(
49
+ type: :delete,
50
+ indentation_level: 1,
51
+ value: ")>",
52
+ collection_bookend: :close
53
+ )
54
+ ]
55
+ )
54
56
  end
55
57
  end
56
58
  end
@@ -58,56 +60,58 @@ RSpec.describe SuperDiff, type: :unit do
58
60
  context "given a collection-including-<something>" do
59
61
  context "given as_lines: false" do
60
62
  it "returns an inspected version of the object" do
61
- string = described_class.inspect_object(
62
- a_collection_including(1, 2, 3),
63
- as_lines: false,
64
- )
65
- expect(string).to eq(
66
- %(#<a collection including (1, 2, 3)>),
67
- )
63
+ string =
64
+ described_class.inspect_object(
65
+ a_collection_including(1, 2, 3),
66
+ as_lines: false
67
+ )
68
+ expect(string).to eq("#<a collection including (1, 2, 3)>")
68
69
  end
69
70
  end
70
71
 
71
72
  context "given as_lines: true" do
72
73
  it "returns an inspected version of the object as multiple Lines" do
73
- tiered_lines = described_class.inspect_object(
74
- a_collection_including(1, 2, 3),
75
- as_lines: true,
76
- type: :delete,
77
- indentation_level: 1,
78
- )
79
- expect(tiered_lines).to match([
80
- an_object_having_attributes(
81
- type: :delete,
82
- indentation_level: 1,
83
- value: %[#<a collection including (],
84
- collection_bookend: :open,
85
- ),
86
- an_object_having_attributes(
87
- type: :delete,
88
- indentation_level: 2,
89
- value: %[1],
90
- add_comma: true,
91
- ),
92
- an_object_having_attributes(
93
- type: :delete,
94
- indentation_level: 2,
95
- value: %[2],
96
- add_comma: true,
97
- ),
98
- an_object_having_attributes(
99
- type: :delete,
100
- indentation_level: 2,
101
- value: %[3],
102
- add_comma: false,
103
- ),
104
- an_object_having_attributes(
74
+ tiered_lines =
75
+ described_class.inspect_object(
76
+ a_collection_including(1, 2, 3),
77
+ as_lines: true,
105
78
  type: :delete,
106
- indentation_level: 1,
107
- value: %[)>],
108
- collection_bookend: :close,
109
- ),
110
- ])
79
+ indentation_level: 1
80
+ )
81
+ expect(tiered_lines).to match(
82
+ [
83
+ an_object_having_attributes(
84
+ type: :delete,
85
+ indentation_level: 1,
86
+ value: "#<a collection including (",
87
+ collection_bookend: :open
88
+ ),
89
+ an_object_having_attributes(
90
+ type: :delete,
91
+ indentation_level: 2,
92
+ value: "1",
93
+ add_comma: true
94
+ ),
95
+ an_object_having_attributes(
96
+ type: :delete,
97
+ indentation_level: 2,
98
+ value: "2",
99
+ add_comma: true
100
+ ),
101
+ an_object_having_attributes(
102
+ type: :delete,
103
+ indentation_level: 2,
104
+ value: "3",
105
+ add_comma: false
106
+ ),
107
+ an_object_having_attributes(
108
+ type: :delete,
109
+ indentation_level: 1,
110
+ value: ")>",
111
+ collection_bookend: :close
112
+ )
113
+ ]
114
+ )
111
115
  end
112
116
  end
113
117
  end
@@ -115,52 +119,56 @@ RSpec.describe SuperDiff, type: :unit do
115
119
  context "given a fuzzy object" do
116
120
  context "given as_lines: false" do
117
121
  it "returns an inspected version of the object" do
118
- string = described_class.inspect_object(
119
- an_object_having_attributes(foo: "bar", baz: "qux"),
120
- as_lines: false,
121
- )
122
+ string =
123
+ described_class.inspect_object(
124
+ an_object_having_attributes(foo: "bar", baz: "qux"),
125
+ as_lines: false
126
+ )
122
127
  expect(string).to eq(
123
- %(#<an object having attributes (foo: "bar", baz: "qux")>),
128
+ %(#<an object having attributes (foo: "bar", baz: "qux")>)
124
129
  )
125
130
  end
126
131
  end
127
132
 
128
133
  context "given as_lines: true" do
129
134
  it "returns an inspected version of the object as multiple Lines" do
130
- tiered_lines = described_class.inspect_object(
131
- an_object_having_attributes(foo: "bar", baz: "qux"),
132
- as_lines: true,
133
- type: :delete,
134
- indentation_level: 1,
135
- )
136
- expect(tiered_lines).to match([
137
- an_object_having_attributes(
138
- type: :delete,
139
- indentation_level: 1,
140
- value: %[#<an object having attributes (],
141
- collection_bookend: :open,
142
- ),
143
- an_object_having_attributes(
144
- type: :delete,
145
- indentation_level: 2,
146
- prefix: %[foo: ],
147
- value: %["bar"],
148
- add_comma: true,
149
- ),
150
- an_object_having_attributes(
151
- type: :delete,
152
- indentation_level: 2,
153
- prefix: %[baz: ],
154
- value: %["qux"],
155
- add_comma: false,
156
- ),
157
- an_object_having_attributes(
135
+ tiered_lines =
136
+ described_class.inspect_object(
137
+ an_object_having_attributes(foo: "bar", baz: "qux"),
138
+ as_lines: true,
158
139
  type: :delete,
159
- indentation_level: 1,
160
- value: %[)>],
161
- collection_bookend: :close,
162
- ),
163
- ])
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: "#<an object having attributes (",
148
+ collection_bookend: :open
149
+ ),
150
+ an_object_having_attributes(
151
+ type: :delete,
152
+ indentation_level: 2,
153
+ prefix: "foo: ",
154
+ value: %["bar"],
155
+ add_comma: true
156
+ ),
157
+ an_object_having_attributes(
158
+ type: :delete,
159
+ indentation_level: 2,
160
+ prefix: "baz: ",
161
+ value: %["qux"],
162
+ add_comma: false
163
+ ),
164
+ an_object_having_attributes(
165
+ type: :delete,
166
+ indentation_level: 1,
167
+ value: ")>",
168
+ collection_bookend: :close
169
+ )
170
+ ]
171
+ )
164
172
  end
165
173
  end
166
174
  end
@@ -168,56 +176,60 @@ RSpec.describe SuperDiff, type: :unit do
168
176
  context "given a collection-containing-exactly-<something>" do
169
177
  context "given as_lines: false" do
170
178
  it "returns an inspected version of the object" do
171
- string = described_class.inspect_object(
172
- a_collection_containing_exactly("foo", "bar", "baz"),
173
- as_lines: false,
174
- )
179
+ string =
180
+ described_class.inspect_object(
181
+ a_collection_containing_exactly("foo", "bar", "baz"),
182
+ as_lines: false
183
+ )
175
184
  expect(string).to eq(
176
- %(#<a collection containing exactly ("foo", "bar", "baz")>),
185
+ %(#<a collection containing exactly ("foo", "bar", "baz")>)
177
186
  )
178
187
  end
179
188
  end
180
189
 
181
190
  context "given as_lines: true" do
182
191
  it "returns an inspected version of the object as multiple Lines" do
183
- tiered_lines = described_class.inspect_object(
184
- a_collection_containing_exactly("foo", "bar", "baz"),
185
- as_lines: true,
186
- type: :delete,
187
- indentation_level: 1,
188
- )
189
- expect(tiered_lines).to match([
190
- an_object_having_attributes(
191
- type: :delete,
192
- indentation_level: 1,
193
- value: %[#<a collection containing exactly (],
194
- collection_bookend: :open,
195
- ),
196
- an_object_having_attributes(
197
- type: :delete,
198
- indentation_level: 2,
199
- value: %["foo"],
200
- add_comma: true,
201
- ),
202
- an_object_having_attributes(
203
- type: :delete,
204
- indentation_level: 2,
205
- value: %["bar"],
206
- add_comma: true,
207
- ),
208
- an_object_having_attributes(
209
- type: :delete,
210
- indentation_level: 2,
211
- value: %["baz"],
212
- add_comma: false,
213
- ),
214
- an_object_having_attributes(
192
+ tiered_lines =
193
+ described_class.inspect_object(
194
+ a_collection_containing_exactly("foo", "bar", "baz"),
195
+ as_lines: true,
215
196
  type: :delete,
216
- indentation_level: 1,
217
- value: %[)>],
218
- collection_bookend: :close,
219
- ),
220
- ])
197
+ indentation_level: 1
198
+ )
199
+ expect(tiered_lines).to match(
200
+ [
201
+ an_object_having_attributes(
202
+ type: :delete,
203
+ indentation_level: 1,
204
+ value: "#<a collection containing exactly (",
205
+ collection_bookend: :open
206
+ ),
207
+ an_object_having_attributes(
208
+ type: :delete,
209
+ indentation_level: 2,
210
+ value: %["foo"],
211
+ add_comma: true
212
+ ),
213
+ an_object_having_attributes(
214
+ type: :delete,
215
+ indentation_level: 2,
216
+ value: %["bar"],
217
+ add_comma: true
218
+ ),
219
+ an_object_having_attributes(
220
+ type: :delete,
221
+ indentation_level: 2,
222
+ value: %["baz"],
223
+ add_comma: false
224
+ ),
225
+ an_object_having_attributes(
226
+ type: :delete,
227
+ indentation_level: 1,
228
+ value: ")>",
229
+ collection_bookend: :close
230
+ )
231
+ ]
232
+ )
221
233
  end
222
234
  end
223
235
  end
@@ -225,29 +237,30 @@ RSpec.describe SuperDiff, type: :unit do
225
237
  context "given a kind-of-<something>" do
226
238
  context "given as_lines: false" do
227
239
  it "returns an inspected version of the object" do
228
- string = described_class.inspect_object(
229
- a_kind_of(Symbol),
230
- as_lines: false,
231
- )
232
- expect(string).to eq(%(#<a kind of Symbol>))
240
+ string =
241
+ described_class.inspect_object(a_kind_of(Symbol), as_lines: false)
242
+ expect(string).to eq("#<a kind of Symbol>")
233
243
  end
234
244
  end
235
245
 
236
246
  context "given as_lines: true" do
237
247
  it "returns an inspected version of the object as a single Line" do
238
- tiered_lines = described_class.inspect_object(
239
- a_kind_of(Symbol),
240
- as_lines: true,
241
- type: :delete,
242
- indentation_level: 1,
243
- )
244
- expect(tiered_lines).to match([
245
- an_object_having_attributes(
248
+ tiered_lines =
249
+ described_class.inspect_object(
250
+ a_kind_of(Symbol),
251
+ as_lines: true,
246
252
  type: :delete,
247
- indentation_level: 1,
248
- value: %[#<a kind of Symbol>],
249
- ),
250
- ])
253
+ indentation_level: 1
254
+ )
255
+ expect(tiered_lines).to match(
256
+ [
257
+ an_object_having_attributes(
258
+ type: :delete,
259
+ indentation_level: 1,
260
+ value: "#<a kind of Symbol>"
261
+ )
262
+ ]
263
+ )
251
264
  end
252
265
  end
253
266
  end
@@ -255,29 +268,33 @@ RSpec.describe SuperDiff, type: :unit do
255
268
  context "given an-instance-of-<something>" do
256
269
  context "given as_lines: false" do
257
270
  it "returns an inspected version of the object" do
258
- string = described_class.inspect_object(
259
- an_instance_of(Symbol),
260
- as_lines: false,
261
- )
262
- expect(string).to eq(%(#<an instance of Symbol>))
271
+ string =
272
+ described_class.inspect_object(
273
+ an_instance_of(Symbol),
274
+ as_lines: false
275
+ )
276
+ expect(string).to eq("#<an instance of Symbol>")
263
277
  end
264
278
  end
265
279
 
266
280
  context "given as_lines: true" do
267
281
  it "returns an inspected version of the object" do
268
- tiered_lines = described_class.inspect_object(
269
- an_instance_of(Symbol),
270
- as_lines: true,
271
- type: :delete,
272
- indentation_level: 1,
273
- )
274
- expect(tiered_lines).to match([
275
- an_object_having_attributes(
282
+ tiered_lines =
283
+ described_class.inspect_object(
284
+ an_instance_of(Symbol),
285
+ as_lines: true,
276
286
  type: :delete,
277
- indentation_level: 1,
278
- value: %[#<an instance of Symbol>],
279
- ),
280
- ])
287
+ indentation_level: 1
288
+ )
289
+ expect(tiered_lines).to match(
290
+ [
291
+ an_object_having_attributes(
292
+ type: :delete,
293
+ indentation_level: 1,
294
+ value: "#<an instance of Symbol>"
295
+ )
296
+ ]
297
+ )
281
298
  end
282
299
  end
283
300
  end
@@ -285,159 +302,167 @@ RSpec.describe SuperDiff, type: :unit do
285
302
  context "given a-value-within-<something>" do
286
303
  context "given as_lines: false" do
287
304
  it "returns an inspected version of the object" do
288
- string = described_class.inspect_object(
289
- a_value_within(1).of(Time.utc(2020, 4, 9)),
290
- as_lines: false,
291
- )
305
+ string =
306
+ described_class.inspect_object(
307
+ a_value_within(1).of(Time.utc(2020, 4, 9)),
308
+ as_lines: false
309
+ )
292
310
  expect(string).to eq(
293
- %(#<a value within 1 of #<Time 2020-04-09 00:00:00 +00:00 (UTC)>>),
311
+ "#<a value within 1 of #<Time 2020-04-09 00:00:00 +00:00 (UTC)>>"
294
312
  )
295
313
  end
296
314
  end
297
315
 
298
316
  context "given as_lines: true" do
299
317
  it "returns an inspected version of the object" do
300
- tiered_lines = described_class.inspect_object(
301
- a_value_within(1).of(Time.utc(2020, 4, 9)),
302
- as_lines: true,
303
- type: :delete,
304
- indentation_level: 1,
305
- )
306
- expect(tiered_lines).to match([
307
- an_object_having_attributes(
308
- type: :delete,
309
- indentation_level: 1,
310
- value: %(#<a value within 1 of #<Time {),
311
- add_comma: false,
312
- collection_bookend: :open,
313
- ),
314
- an_object_having_attributes(
315
- type: :delete,
316
- indentation_level: 2,
317
- value: %(year: 2020),
318
- add_comma: true,
319
- collection_bookend: nil,
320
- ),
321
- an_object_having_attributes(
322
- type: :delete,
323
- indentation_level: 2,
324
- value: %(month: 4),
325
- add_comma: true,
326
- collection_bookend: nil,
327
- ),
328
- an_object_having_attributes(
329
- type: :delete,
330
- indentation_level: 2,
331
- value: %(day: 9),
332
- add_comma: true,
333
- collection_bookend: nil,
334
- ),
335
- an_object_having_attributes(
336
- type: :delete,
337
- indentation_level: 2,
338
- value: %(hour: 0),
339
- add_comma: true,
340
- collection_bookend: nil,
341
- ),
342
- an_object_having_attributes(
343
- type: :delete,
344
- indentation_level: 2,
345
- value: %(min: 0),
346
- add_comma: true,
347
- collection_bookend: nil,
348
- ),
349
- an_object_having_attributes(
350
- type: :delete,
351
- indentation_level: 2,
352
- value: %(sec: 0),
353
- add_comma: true,
354
- collection_bookend: nil,
355
- ),
356
- an_object_having_attributes(
357
- type: :delete,
358
- indentation_level: 2,
359
- value: %(subsec: 0),
360
- add_comma: true,
361
- collection_bookend: nil,
362
- ),
363
- an_object_having_attributes(
364
- type: :delete,
365
- indentation_level: 2,
366
- value: %(zone: "UTC"),
367
- add_comma: true,
368
- collection_bookend: nil,
369
- ),
370
- an_object_having_attributes(
371
- type: :delete,
372
- indentation_level: 2,
373
- value: %(utc_offset: 0),
374
- add_comma: false,
375
- collection_bookend: nil,
376
- ),
377
- an_object_having_attributes(
378
- type: :delete,
379
- indentation_level: 1,
380
- value: %(}>>),
381
- add_comma: false,
382
- collection_bookend: :close,
383
- ),
384
- ])
385
- end
386
- end
387
- end
388
-
389
- # TODO: Test InstanceDouble, ClassDouble, ObjectDouble
390
- context "given a Double" do
391
- # TODO: Test named double
392
- context "that is anonymous" do
393
- context "given as_lines: false" do
394
- it "returns an inspected version of the object" do
395
- string = described_class.inspect_object(
396
- double(foo: "bar", baz: "qux"),
397
- as_lines: false,
398
- )
399
- expect(string).to eq(
400
- %(#<Double (anonymous) foo: "bar", baz: "qux">),
401
- )
402
- end
403
- end
404
-
405
- context "given as_lines: true" do
406
- it "returns an inspected version of the object as multiple Lines" do
407
- tiered_lines = described_class.inspect_object(
408
- double(foo: "bar", baz: "qux"),
318
+ tiered_lines =
319
+ described_class.inspect_object(
320
+ a_value_within(1).of(Time.utc(2020, 4, 9)),
409
321
  as_lines: true,
410
322
  type: :delete,
411
- indentation_level: 1,
323
+ indentation_level: 1
412
324
  )
413
- expect(tiered_lines).to match([
325
+ expect(tiered_lines).to match(
326
+ [
414
327
  an_object_having_attributes(
415
328
  type: :delete,
416
329
  indentation_level: 1,
417
- value: %(#<Double (anonymous) {),
418
- collection_bookend: :open,
330
+ value: "#<a value within 1 of #<Time {",
331
+ add_comma: false,
332
+ collection_bookend: :open
333
+ ),
334
+ an_object_having_attributes(
335
+ type: :delete,
336
+ indentation_level: 2,
337
+ value: "year: 2020",
338
+ add_comma: true,
339
+ collection_bookend: nil
340
+ ),
341
+ an_object_having_attributes(
342
+ type: :delete,
343
+ indentation_level: 2,
344
+ value: "month: 4",
345
+ add_comma: true,
346
+ collection_bookend: nil
347
+ ),
348
+ an_object_having_attributes(
349
+ type: :delete,
350
+ indentation_level: 2,
351
+ value: "day: 9",
352
+ add_comma: true,
353
+ collection_bookend: nil
354
+ ),
355
+ an_object_having_attributes(
356
+ type: :delete,
357
+ indentation_level: 2,
358
+ value: "hour: 0",
359
+ add_comma: true,
360
+ collection_bookend: nil
361
+ ),
362
+ an_object_having_attributes(
363
+ type: :delete,
364
+ indentation_level: 2,
365
+ value: "min: 0",
366
+ add_comma: true,
367
+ collection_bookend: nil
368
+ ),
369
+ an_object_having_attributes(
370
+ type: :delete,
371
+ indentation_level: 2,
372
+ value: "sec: 0",
373
+ add_comma: true,
374
+ collection_bookend: nil
419
375
  ),
420
376
  an_object_having_attributes(
421
377
  type: :delete,
422
378
  indentation_level: 2,
423
- prefix: %(foo: ),
424
- value: %("bar"),
379
+ value: "subsec: 0",
425
380
  add_comma: true,
381
+ collection_bookend: nil
426
382
  ),
427
383
  an_object_having_attributes(
428
384
  type: :delete,
429
385
  indentation_level: 2,
430
- prefix: %(baz: ),
431
- value: %("qux"),
386
+ value: %(zone: "UTC"),
387
+ add_comma: true,
388
+ collection_bookend: nil
389
+ ),
390
+ an_object_having_attributes(
391
+ type: :delete,
392
+ indentation_level: 2,
393
+ value: "utc_offset: 0",
432
394
  add_comma: false,
395
+ collection_bookend: nil
433
396
  ),
434
397
  an_object_having_attributes(
435
398
  type: :delete,
436
399
  indentation_level: 1,
437
- value: %(}>),
438
- collection_bookend: :close,
439
- ),
440
- ])
400
+ value: "}>>",
401
+ add_comma: false,
402
+ collection_bookend: :close
403
+ )
404
+ ]
405
+ )
406
+ end
407
+ end
408
+ end
409
+
410
+ # TODO: Test InstanceDouble, ClassDouble, ObjectDouble
411
+ context "given a Double" do
412
+ # TODO: Test named double
413
+ context "that is anonymous" do
414
+ context "given as_lines: false" do
415
+ it "returns an inspected version of the object" do
416
+ string =
417
+ described_class.inspect_object(
418
+ double(foo: "bar", baz: "qux"),
419
+ as_lines: false
420
+ )
421
+ expect(string).to eq(
422
+ %(#<Double (anonymous) foo: "bar", baz: "qux">)
423
+ )
424
+ end
425
+ end
426
+
427
+ context "given as_lines: true" do
428
+ it "returns an inspected version of the object as multiple Lines" do
429
+ tiered_lines =
430
+ described_class.inspect_object(
431
+ double(foo: "bar", baz: "qux"),
432
+ as_lines: true,
433
+ type: :delete,
434
+ indentation_level: 1
435
+ )
436
+ expect(tiered_lines).to match(
437
+ [
438
+ an_object_having_attributes(
439
+ type: :delete,
440
+ indentation_level: 1,
441
+ value: "#<Double (anonymous) {",
442
+ collection_bookend: :open
443
+ ),
444
+ an_object_having_attributes(
445
+ type: :delete,
446
+ indentation_level: 2,
447
+ prefix: "foo: ",
448
+ value: %("bar"),
449
+ add_comma: true
450
+ ),
451
+ an_object_having_attributes(
452
+ type: :delete,
453
+ indentation_level: 2,
454
+ prefix: "baz: ",
455
+ value: %("qux"),
456
+ add_comma: false
457
+ ),
458
+ an_object_having_attributes(
459
+ type: :delete,
460
+ indentation_level: 1,
461
+ value: "}>",
462
+ collection_bookend: :close
463
+ )
464
+ ]
465
+ )
441
466
  end
442
467
  end
443
468
  end