super_diff 0.5.3 → 0.8.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 (209) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +46 -20
  3. data/lib/super_diff.rb +46 -7
  4. data/lib/super_diff/active_record.rb +7 -7
  5. data/lib/super_diff/active_record/differs/active_record_relation.rb +3 -13
  6. data/lib/super_diff/active_record/object_inspection.rb +2 -6
  7. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +16 -0
  8. data/lib/super_diff/active_record/object_inspection/{inspectors → inspection_tree_builders}/active_record_model.rb +19 -20
  9. data/lib/super_diff/active_record/object_inspection/{inspectors → inspection_tree_builders}/active_record_relation.rb +9 -8
  10. data/lib/super_diff/active_record/operation_tree_flatteners.rb +10 -0
  11. data/lib/super_diff/active_record/operation_tree_flatteners/active_record_relation.rb +17 -0
  12. data/lib/super_diff/active_record/operation_trees/active_record_relation.rb +8 -7
  13. data/lib/super_diff/active_support.rb +8 -8
  14. data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +3 -13
  15. data/lib/super_diff/active_support/object_inspection.rb +2 -6
  16. data/lib/super_diff/active_support/object_inspection/{inspectors.rb → inspection_tree_builders.rb} +2 -2
  17. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +37 -0
  18. data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +17 -0
  19. data/lib/super_diff/active_support/operation_tree_flatteners.rb +10 -0
  20. data/lib/super_diff/active_support/operation_tree_flatteners/hash_with_indifferent_access.rb +17 -0
  21. data/lib/super_diff/active_support/operation_trees/hash_with_indifferent_access.rb +4 -7
  22. data/lib/super_diff/colorized_document_extensions.rb +9 -6
  23. data/lib/super_diff/configuration.rb +102 -19
  24. data/lib/super_diff/csi.rb +1 -1
  25. data/lib/super_diff/csi/four_bit_color.rb +0 -2
  26. data/lib/super_diff/diff_formatters/collection.rb +2 -2
  27. data/lib/super_diff/diff_formatters/multiline_string.rb +4 -4
  28. data/lib/super_diff/differs/array.rb +1 -1
  29. data/lib/super_diff/differs/base.rb +3 -21
  30. data/lib/super_diff/differs/custom_object.rb +1 -1
  31. data/lib/super_diff/differs/default_object.rb +1 -1
  32. data/lib/super_diff/differs/hash.rb +1 -1
  33. data/lib/super_diff/differs/main.rb +1 -7
  34. data/lib/super_diff/differs/multiline_string.rb +1 -1
  35. data/lib/super_diff/differs/time_like.rb +1 -1
  36. data/lib/super_diff/equality_matchers/array.rb +4 -4
  37. data/lib/super_diff/equality_matchers/default.rb +4 -4
  38. data/lib/super_diff/equality_matchers/hash.rb +4 -4
  39. data/lib/super_diff/equality_matchers/multiline_string.rb +4 -4
  40. data/lib/super_diff/equality_matchers/primitive.rb +6 -9
  41. data/lib/super_diff/equality_matchers/singleline_string.rb +4 -4
  42. data/lib/super_diff/gem_version.rb +45 -0
  43. data/lib/super_diff/helpers.rb +52 -2
  44. data/lib/super_diff/line.rb +83 -0
  45. data/lib/super_diff/object_inspection.rb +12 -9
  46. data/lib/super_diff/object_inspection/inspection_tree.rb +183 -81
  47. data/lib/super_diff/object_inspection/inspection_tree_builders.rb +44 -0
  48. data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +38 -0
  49. data/lib/super_diff/object_inspection/inspection_tree_builders/base.rb +27 -0
  50. data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +37 -0
  51. data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +63 -0
  52. data/lib/super_diff/object_inspection/{inspectors → inspection_tree_builders}/defaults.rb +1 -2
  53. data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +46 -0
  54. data/lib/super_diff/object_inspection/{inspectors → inspection_tree_builders}/main.rb +5 -10
  55. data/lib/super_diff/object_inspection/inspection_tree_builders/primitive.rb +21 -0
  56. data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +64 -0
  57. data/lib/super_diff/object_inspection/nodes.rb +33 -32
  58. data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +97 -0
  59. data/lib/super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines.rb +27 -0
  60. data/lib/super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines.rb +27 -0
  61. data/lib/super_diff/object_inspection/nodes/as_single_line.rb +33 -0
  62. data/lib/super_diff/object_inspection/nodes/base.rb +55 -20
  63. data/lib/super_diff/object_inspection/nodes/inspection.rb +47 -7
  64. data/lib/super_diff/object_inspection/nodes/nesting.rb +16 -5
  65. data/lib/super_diff/object_inspection/nodes/only_when.rb +54 -0
  66. data/lib/super_diff/object_inspection/nodes/text.rb +16 -2
  67. data/lib/super_diff/object_inspection/nodes/when_empty.rb +21 -6
  68. data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +20 -5
  69. data/lib/super_diff/object_inspection/nodes/when_rendering_to_lines.rb +27 -0
  70. data/lib/super_diff/object_inspection/nodes/when_rendering_to_string.rb +27 -0
  71. data/lib/super_diff/object_inspection/prefix_for_next_node.rb +6 -0
  72. data/lib/super_diff/object_inspection/prelude_for_next_node.rb +6 -0
  73. data/lib/super_diff/operation_tree_builders/array.rb +7 -10
  74. data/lib/super_diff/operation_tree_builders/base.rb +6 -6
  75. data/lib/super_diff/operation_tree_builders/custom_object.rb +5 -2
  76. data/lib/super_diff/operation_tree_builders/default_object.rb +1 -1
  77. data/lib/super_diff/operation_tree_builders/defaults.rb +1 -1
  78. data/lib/super_diff/operation_tree_builders/hash.rb +1 -8
  79. data/lib/super_diff/operation_tree_builders/multiline_string.rb +2 -6
  80. data/lib/super_diff/operation_tree_builders/time_like.rb +2 -2
  81. data/lib/super_diff/operation_tree_flatteners.rb +20 -0
  82. data/lib/super_diff/operation_tree_flatteners/array.rb +15 -0
  83. data/lib/super_diff/operation_tree_flatteners/base.rb +54 -0
  84. data/lib/super_diff/operation_tree_flatteners/collection.rb +139 -0
  85. data/lib/super_diff/operation_tree_flatteners/custom_object.rb +28 -0
  86. data/lib/super_diff/operation_tree_flatteners/default_object.rb +32 -0
  87. data/lib/super_diff/operation_tree_flatteners/hash.rb +41 -0
  88. data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +17 -0
  89. data/lib/super_diff/operation_trees/array.rb +4 -7
  90. data/lib/super_diff/operation_trees/base.rb +39 -16
  91. data/lib/super_diff/operation_trees/custom_object.rb +4 -8
  92. data/lib/super_diff/operation_trees/default_object.rb +28 -13
  93. data/lib/super_diff/operation_trees/hash.rb +4 -7
  94. data/lib/super_diff/operation_trees/main.rb +1 -1
  95. data/lib/super_diff/operation_trees/multiline_string.rb +4 -7
  96. data/lib/super_diff/operations/binary_operation.rb +1 -6
  97. data/lib/super_diff/operations/unary_operation.rb +2 -30
  98. data/lib/super_diff/recursion_guard.rb +3 -3
  99. data/lib/super_diff/rspec.rb +41 -13
  100. data/lib/super_diff/rspec/differs/collection_including.rb +4 -2
  101. data/lib/super_diff/rspec/differs/hash_including.rb +4 -2
  102. data/lib/super_diff/rspec/matcher_text_builders/base.rb +7 -7
  103. data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +6 -6
  104. data/lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb +1 -1
  105. data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +4 -4
  106. data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +1 -1
  107. data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +5 -5
  108. data/lib/super_diff/rspec/monkey_patches.rb +353 -306
  109. data/lib/super_diff/rspec/object_inspection.rb +4 -1
  110. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +44 -0
  111. data/lib/super_diff/rspec/object_inspection/{inspectors → inspection_tree_builders}/collection_containing_exactly.rb +9 -8
  112. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +34 -0
  113. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +103 -0
  114. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +36 -0
  115. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +26 -0
  116. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +26 -0
  117. data/lib/super_diff/rspec/object_inspection/{inspectors → inspection_tree_builders}/object_having_attributes.rb +10 -12
  118. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/primitive.rb +10 -0
  119. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/value_within.rb +33 -0
  120. data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +12 -4
  121. data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +10 -3
  122. data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +10 -3
  123. data/lib/super_diff/tiered_lines.rb +4 -0
  124. data/lib/super_diff/tiered_lines_elider.rb +490 -0
  125. data/lib/super_diff/tiered_lines_formatter.rb +79 -0
  126. data/lib/super_diff/version.rb +1 -1
  127. data/spec/examples.txt +407 -5
  128. data/spec/integration/rails/active_support_spec.rb +19 -0
  129. data/spec/integration/rspec/be_falsey_matcher_spec.rb +10 -10
  130. data/spec/integration/rspec/be_matcher_spec.rb +100 -100
  131. data/spec/integration/rspec/be_nil_matcher_spec.rb +10 -10
  132. data/spec/integration/rspec/be_predicate_matcher_spec.rb +103 -103
  133. data/spec/integration/rspec/be_truthy_matcher_spec.rb +10 -10
  134. data/spec/integration/rspec/contain_exactly_matcher_spec.rb +113 -107
  135. data/spec/integration/rspec/eq_matcher_spec.rb +223 -277
  136. data/spec/integration/rspec/have_attributes_matcher_spec.rb +138 -129
  137. data/spec/integration/rspec/have_predicate_matcher_spec.rb +65 -65
  138. data/spec/integration/rspec/include_matcher_spec.rb +73 -73
  139. data/spec/integration/rspec/match_array_matcher_spec.rb +126 -119
  140. data/spec/integration/rspec/match_matcher_spec.rb +362 -274
  141. data/spec/integration/rspec/raise_error_matcher_spec.rb +86 -86
  142. data/spec/integration/rspec/respond_to_matcher_spec.rb +240 -240
  143. data/spec/integration/rspec/third_party_matcher_spec.rb +8 -8
  144. data/spec/integration/rspec/unhandled_errors_spec.rb +5 -5
  145. data/spec/spec_helper.rb +33 -13
  146. data/spec/support/command_runner.rb +15 -25
  147. data/spec/support/helpers.rb +21 -0
  148. data/spec/support/integration/helpers.rb +8 -2
  149. data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +4 -4
  150. data/spec/support/integration/test_programs/base.rb +38 -10
  151. data/spec/support/integration/test_programs/rspec_active_record.rb +1 -1
  152. data/spec/support/integration/test_programs/rspec_active_support.rb +17 -0
  153. data/spec/support/integration/test_programs/rspec_rails.rb +1 -1
  154. data/spec/support/shared_examples/active_record.rb +109 -108
  155. data/spec/support/shared_examples/active_support.rb +65 -0
  156. data/spec/support/shared_examples/elided_diffs.rb +914 -0
  157. data/spec/support/shared_examples/hash_with_indifferent_access.rb +196 -232
  158. data/spec/support/unit/helpers.rb +15 -0
  159. data/spec/support/unit/matchers/match_output.rb +41 -0
  160. data/spec/unit/active_record/object_inspection_spec.rb +273 -0
  161. data/spec/unit/equality_matchers/main_spec.rb +445 -465
  162. data/spec/unit/helpers_spec.rb +61 -0
  163. data/spec/unit/operation_tree_flatteners/array_spec.rb +604 -0
  164. data/spec/unit/operation_tree_flatteners/custom_object_spec.rb +667 -0
  165. data/spec/unit/operation_tree_flatteners/default_object_spec.rb +687 -0
  166. data/spec/unit/operation_tree_flatteners/hash_spec.rb +632 -0
  167. data/spec/unit/operation_tree_flatteners/multiline_string_spec.rb +121 -0
  168. data/spec/unit/rspec/object_inspection_spec.rb +446 -0
  169. data/spec/unit/super_diff_spec.rb +1958 -0
  170. data/spec/unit/tiered_lines_elider_spec.rb +6356 -0
  171. data/spec/unit/tiered_lines_formatter_spec.rb +193 -0
  172. data/super_diff.gemspec +1 -1
  173. metadata +95 -50
  174. data/lib/super_diff/active_record/diff_formatters.rb +0 -10
  175. data/lib/super_diff/active_record/diff_formatters/active_record_relation.rb +0 -23
  176. data/lib/super_diff/active_record/object_inspection/inspectors.rb +0 -16
  177. data/lib/super_diff/active_support/diff_formatters.rb +0 -10
  178. data/lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb +0 -36
  179. data/lib/super_diff/active_support/object_inspection/inspectors/hash_with_indifferent_access.rb +0 -28
  180. data/lib/super_diff/diff_formatters.rb +0 -14
  181. data/lib/super_diff/diff_formatters/array.rb +0 -21
  182. data/lib/super_diff/diff_formatters/base.rb +0 -33
  183. data/lib/super_diff/diff_formatters/custom_object.rb +0 -30
  184. data/lib/super_diff/diff_formatters/default_object.rb +0 -46
  185. data/lib/super_diff/diff_formatters/defaults.rb +0 -10
  186. data/lib/super_diff/diff_formatters/hash.rb +0 -34
  187. data/lib/super_diff/diff_formatters/main.rb +0 -41
  188. data/lib/super_diff/object_inspection/inspectors.rb +0 -23
  189. data/lib/super_diff/object_inspection/inspectors/array.rb +0 -32
  190. data/lib/super_diff/object_inspection/inspectors/base.rb +0 -36
  191. data/lib/super_diff/object_inspection/inspectors/custom_object.rb +0 -37
  192. data/lib/super_diff/object_inspection/inspectors/default_object.rb +0 -61
  193. data/lib/super_diff/object_inspection/inspectors/hash.rb +0 -32
  194. data/lib/super_diff/object_inspection/inspectors/primitive.rb +0 -28
  195. data/lib/super_diff/object_inspection/inspectors/string.rb +0 -23
  196. data/lib/super_diff/object_inspection/inspectors/time_like.rb +0 -23
  197. data/lib/super_diff/object_inspection/nodes/break.rb +0 -15
  198. data/lib/super_diff/object_inspection/nodes/when_multiline.rb +0 -22
  199. data/lib/super_diff/object_inspection/nodes/when_singleline.rb +0 -24
  200. data/lib/super_diff/rspec/object_inspection/inspectors.rb +0 -40
  201. data/lib/super_diff/rspec/object_inspection/inspectors/collection_including.rb +0 -28
  202. data/lib/super_diff/rspec/object_inspection/inspectors/hash_including.rb +0 -31
  203. data/lib/super_diff/rspec/object_inspection/inspectors/instance_of.rb +0 -23
  204. data/lib/super_diff/rspec/object_inspection/inspectors/kind_of.rb +0 -23
  205. data/lib/super_diff/rspec/object_inspection/inspectors/primitive.rb +0 -13
  206. data/lib/super_diff/rspec/object_inspection/inspectors/value_within.rb +0 -29
  207. data/spec/support/object_id.rb +0 -27
  208. data/spec/support/ruby_versions.rb +0 -11
  209. data/spec/unit/object_inspection_spec.rb +0 -1168
@@ -1,7 +1,7 @@
1
1
  module SuperDiff
2
2
  module IntegrationTests
3
3
  module TestPrograms
4
- class RspecRails < Base
4
+ class RSpecRails < Base
5
5
  protected
6
6
 
7
7
  def test_plan_prelude
@@ -10,7 +10,7 @@ shared_examples_for "integration with ActiveRecord" do
10
10
  state: "CA",
11
11
  zip: "90382",
12
12
  )
13
- actual = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
13
+ actual = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
14
14
  line_1: "456 Ponderosa Ct.",
15
15
  city: "Oakland",
16
16
  state: "CA",
@@ -25,27 +25,27 @@ shared_examples_for "integration with ActiveRecord" do
25
25
  snippet: "expect(actual).to eq(expected)",
26
26
  expectation: proc {
27
27
  line do
28
- plain "Expected "
29
- beta %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234">|
28
+ plain %|Expected |
29
+ actual %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234">|
30
30
  end
31
31
 
32
32
  line do
33
- plain " to eq "
34
- alpha %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
33
+ plain %| to eq |
34
+ expected %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
35
35
  end
36
36
  },
37
37
  diff: proc {
38
- plain_line %| #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
39
- plain_line %| id: nil,|
40
- alpha_line %|- city: "Hill Valley",|
41
- beta_line %|+ city: "Oakland",|
42
- alpha_line %|- line_1: "123 Main St.",|
43
- beta_line %|+ line_1: "456 Ponderosa Ct.",|
44
- plain_line %| line_2: "",|
45
- plain_line %| state: "CA",|
46
- alpha_line %|- zip: "90382"|
47
- beta_line %|+ zip: "91234"|
48
- plain_line %| }>|
38
+ plain_line %| #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
39
+ plain_line %| id: nil,|
40
+ expected_line %|- city: "Hill Valley",|
41
+ actual_line %|+ city: "Oakland",|
42
+ expected_line %|- line_1: "123 Main St.",|
43
+ actual_line %|+ line_1: "456 Ponderosa Ct.",|
44
+ plain_line %| line_2: "",|
45
+ plain_line %| state: "CA",|
46
+ expected_line %|- zip: "90382"|
47
+ actual_line %|+ zip: "91234"|
48
+ plain_line %| }>|
49
49
  },
50
50
  )
51
51
 
@@ -66,7 +66,7 @@ shared_examples_for "integration with ActiveRecord" do
66
66
  state: "CA",
67
67
  zip: "90382",
68
68
  )
69
- actual = SuperDiff::Test::Models::ActiveRecord::Person.new(
69
+ actual = SuperDiff::Test::Models::ActiveRecord::Person.new(
70
70
  name: "Elliot",
71
71
  age: 31,
72
72
  )
@@ -80,13 +80,13 @@ shared_examples_for "integration with ActiveRecord" do
80
80
  newline_before_expectation: true,
81
81
  expectation: proc {
82
82
  line do
83
- plain "Expected "
84
- beta %|#<SuperDiff::Test::Models::ActiveRecord::Person id: nil, age: 31, name: "Elliot">|
83
+ plain %|Expected |
84
+ actual %|#<SuperDiff::Test::Models::ActiveRecord::Person id: nil, age: 31, name: "Elliot">|
85
85
  end
86
86
 
87
87
  line do
88
- plain " to eq "
89
- alpha %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
88
+ plain %| to eq |
89
+ expected %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
90
90
  end
91
91
  },
92
92
  )
@@ -108,7 +108,7 @@ shared_examples_for "integration with ActiveRecord" do
108
108
  state: "CA",
109
109
  zip: "90382"
110
110
  )
111
- actual = nil
111
+ actual = nil
112
112
  expect(actual).to eq(expected)
113
113
  TEST
114
114
  program = make_program(snippet, color_enabled: color_enabled)
@@ -119,13 +119,13 @@ shared_examples_for "integration with ActiveRecord" do
119
119
  newline_before_expectation: true,
120
120
  expectation: proc {
121
121
  line do
122
- plain "Expected "
123
- beta %|nil|
122
+ plain %|Expected |
123
+ actual %|nil|
124
124
  end
125
125
 
126
126
  line do
127
- plain " to eq "
128
- alpha %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
127
+ plain %| to eq |
128
+ expected %|#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">|
129
129
  end
130
130
  },
131
131
  )
@@ -150,7 +150,7 @@ shared_examples_for "integration with ActiveRecord" do
150
150
  zip: "90382",
151
151
  )
152
152
  }
153
- actual = {
153
+ actual = {
154
154
  name: "Marty McFly",
155
155
  shipping_address: SuperDiff::Test::Models::ActiveRecord::ShippingAddress.new(
156
156
  line_1: "456 Ponderosa Ct.",
@@ -168,30 +168,30 @@ shared_examples_for "integration with ActiveRecord" do
168
168
  snippet: "expect(actual).to eq(expected)",
169
169
  expectation: proc {
170
170
  line do
171
- plain "Expected "
172
- beta %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234"> }|
171
+ plain %|Expected |
172
+ actual %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234"> }|
173
173
  end
174
174
 
175
175
  line do
176
- plain " to eq "
177
- alpha %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382"> }|
176
+ plain %| to eq |
177
+ expected %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382"> }|
178
178
  end
179
179
  },
180
180
  diff: proc {
181
- plain_line %| {|
182
- plain_line %| name: "Marty McFly",|
183
- plain_line %| shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
184
- plain_line %| id: nil,|
185
- alpha_line %|- city: "Hill Valley",|
186
- beta_line %|+ city: "Oakland",|
187
- alpha_line %|- line_1: "123 Main St.",|
188
- beta_line %|+ line_1: "456 Ponderosa Ct.",|
189
- plain_line %| line_2: "",|
190
- plain_line %| state: "CA",|
191
- alpha_line %|- zip: "90382"|
192
- beta_line %|+ zip: "91234"|
193
- plain_line %| }>|
194
- plain_line %| }|
181
+ plain_line %| {|
182
+ plain_line %| name: "Marty McFly",|
183
+ plain_line %| shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
184
+ plain_line %| id: nil,|
185
+ expected_line %|- city: "Hill Valley",|
186
+ actual_line %|+ city: "Oakland",|
187
+ expected_line %|- line_1: "123 Main St.",|
188
+ actual_line %|+ line_1: "456 Ponderosa Ct.",|
189
+ plain_line %| line_2: "",|
190
+ plain_line %| state: "CA",|
191
+ expected_line %|- zip: "90382"|
192
+ actual_line %|+ zip: "91234"|
193
+ plain_line %| }>|
194
+ plain_line %| }|
195
195
  },
196
196
  )
197
197
 
@@ -215,7 +215,7 @@ shared_examples_for "integration with ActiveRecord" do
215
215
  zip: "90382",
216
216
  )
217
217
  }
218
- actual = {
218
+ actual = {
219
219
  name: "Marty McFly",
220
220
  shipping_address: SuperDiff::Test::Models::ActiveRecord::Person.new(
221
221
  name: "Elliot",
@@ -231,32 +231,32 @@ shared_examples_for "integration with ActiveRecord" do
231
231
  snippet: "expect(actual).to eq(expected)",
232
232
  expectation: proc {
233
233
  line do
234
- plain "Expected "
235
- beta %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::Person id: nil, age: 31, name: "Elliot"> }|
234
+ plain %|Expected |
235
+ actual %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::Person id: nil, age: 31, name: "Elliot"> }|
236
236
  end
237
237
 
238
238
  line do
239
- plain " to eq "
240
- alpha %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382"> }|
239
+ plain %| to eq |
240
+ expected %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: nil, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382"> }|
241
241
  end
242
242
  },
243
243
  diff: proc {
244
- plain_line %| {|
245
- plain_line %| name: "Marty McFly",|
246
- alpha_line %|- shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
247
- alpha_line %|- id: nil,|
248
- alpha_line %|- city: "Hill Valley",|
249
- alpha_line %|- line_1: "123 Main St.",|
250
- alpha_line %|- line_2: "",|
251
- alpha_line %|- state: "CA",|
252
- alpha_line %|- zip: "90382"|
253
- alpha_line %|- }>|
254
- beta_line %|+ shipping_address: #<SuperDiff::Test::Models::ActiveRecord::Person {|
255
- beta_line %|+ id: nil,|
256
- beta_line %|+ age: 31,|
257
- beta_line %|+ name: "Elliot"|
258
- beta_line %|+ }>|
259
- plain_line %| }|
244
+ plain_line %| {|
245
+ plain_line %| name: "Marty McFly",|
246
+ expected_line %|- shipping_address: #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
247
+ expected_line %|- id: nil,|
248
+ expected_line %|- city: "Hill Valley",|
249
+ expected_line %|- line_1: "123 Main St.",|
250
+ expected_line %|- line_2: "",|
251
+ expected_line %|- state: "CA",|
252
+ expected_line %|- zip: "90382"|
253
+ expected_line %|- }>|
254
+ actual_line %|+ shipping_address: #<SuperDiff::Test::Models::ActiveRecord::Person {|
255
+ actual_line %|+ id: nil,|
256
+ actual_line %|+ age: 31,|
257
+ actual_line %|+ name: "Elliot"|
258
+ actual_line %|+ }>|
259
+ plain_line %| }|
260
260
  },
261
261
  )
262
262
 
@@ -287,7 +287,7 @@ shared_examples_for "integration with ActiveRecord" do
287
287
  )
288
288
  ]
289
289
  expected = [shipping_addresses.first]
290
- actual = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.all
290
+ actual = SuperDiff::Test::Models::ActiveRecord::ShippingAddress.all
291
291
  expect(actual).to eq(expected)
292
292
  TEST
293
293
  program = make_program(snippet, color_enabled: color_enabled)
@@ -297,34 +297,34 @@ shared_examples_for "integration with ActiveRecord" do
297
297
  snippet: "expect(actual).to eq(expected)",
298
298
  expectation: proc {
299
299
  line do
300
- plain "Expected "
301
- beta %|#<ActiveRecord::Relation [#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 1, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">, #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 2, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234">]>|
300
+ plain %|Expected |
301
+ actual %|#<ActiveRecord::Relation [#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 1, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">, #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 2, city: "Oakland", line_1: "456 Ponderosa Ct.", line_2: "", state: "CA", zip: "91234">]>|
302
302
  end
303
303
 
304
304
  line do
305
- plain " to eq "
306
- alpha %|[#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 1, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">]|
305
+ plain %| to eq |
306
+ expected %|[#<SuperDiff::Test::Models::ActiveRecord::ShippingAddress id: 1, city: "Hill Valley", line_1: "123 Main St.", line_2: "", state: "CA", zip: "90382">]|
307
307
  end
308
308
  },
309
309
  diff: proc {
310
- plain_line %| #<ActiveRecord::Relation [|
311
- plain_line %| #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
312
- plain_line %| id: 1,|
313
- plain_line %| city: "Hill Valley",|
314
- plain_line %| line_1: "123 Main St.",|
315
- plain_line %| line_2: "",|
316
- plain_line %| state: "CA",|
317
- plain_line %| zip: "90382"|
318
- plain_line %| }>,|
319
- beta_line %|+ #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
320
- beta_line %|+ id: 2,|
321
- beta_line %|+ city: "Oakland",|
322
- beta_line %|+ line_1: "456 Ponderosa Ct.",|
323
- beta_line %|+ line_2: "",|
324
- beta_line %|+ state: "CA",|
325
- beta_line %|+ zip: "91234"|
326
- beta_line %|+ }>|
327
- plain_line %| ]>|
310
+ plain_line %| #<ActiveRecord::Relation [|
311
+ plain_line %| #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
312
+ plain_line %| id: 1,|
313
+ plain_line %| city: "Hill Valley",|
314
+ plain_line %| line_1: "123 Main St.",|
315
+ plain_line %| line_2: "",|
316
+ plain_line %| state: "CA",|
317
+ plain_line %| zip: "90382"|
318
+ plain_line %| }>,|
319
+ actual_line %|+ #<SuperDiff::Test::Models::ActiveRecord::ShippingAddress {|
320
+ actual_line %|+ id: 2,|
321
+ actual_line %|+ city: "Oakland",|
322
+ actual_line %|+ line_1: "456 Ponderosa Ct.",|
323
+ actual_line %|+ line_2: "",|
324
+ actual_line %|+ state: "CA",|
325
+ actual_line %|+ zip: "91234"|
326
+ actual_line %|+ }>|
327
+ plain_line %| ]>|
328
328
  },
329
329
  )
330
330
 
@@ -354,7 +354,7 @@ shared_examples_for "integration with ActiveRecord" do
354
354
  )
355
355
  ]
356
356
 
357
- actual = [
357
+ actual = [
358
358
  SuperDiff::Test::Models::ActiveRecord::Query.new(
359
359
  results: SuperDiff::Test::Models::ActiveRecord::Person.all
360
360
  )
@@ -371,30 +371,31 @@ shared_examples_for "integration with ActiveRecord" do
371
371
  newline_before_expectation: true,
372
372
  expectation: proc {
373
373
  line do
374
- plain "Expected "
375
- beta %|[#<SuperDiff::Test::Models::ActiveRecord::Query @results=#<ActiveRecord::Relation [#<SuperDiff::Test::Models::ActiveRecord::Person id: 1, name: "Murphy", age: 20>]>>]|
374
+ plain %|Expected |
375
+ actual %|[#<SuperDiff::Test::Models::ActiveRecord::Query @results=#<ActiveRecord::Relation [#<SuperDiff::Test::Models::ActiveRecord::Person id: 1, age: 20, name: "Murphy">]>>]|
376
376
  end
377
377
 
378
378
  line do
379
- plain "to match "
380
- alpha %|[#<an object having attributes (results: [#<an object having attributes (name: "John", age: 19)>])>]|
379
+ plain %|to match |
380
+ expected %|[#<an object having attributes (results: [#<an object having attributes (name: "John", age: 19)>])>]|
381
381
  end
382
382
  },
383
383
  diff: proc {
384
- plain_line %| [|
385
- plain_line %| #<SuperDiff::Test::Models::ActiveRecord::Query {|
386
- plain_line %| @results=#<ActiveRecord::Relation [|
387
- plain_line %| #<SuperDiff::Test::Models::ActiveRecord::Person {|
388
- plain_line %| id: 1,|
389
- # alpha_line %|- age: 19,| # TODO
390
- alpha_line %|- age: 19|
391
- beta_line %|+ age: 20,|
392
- alpha_line %|- name: "John"|
393
- beta_line %|+ name: "Murphy"|
394
- plain_line %| }>|
395
- plain_line %| ]>|
396
- plain_line %| }>|
397
- plain_line %| ]|
384
+ plain_line %| [|
385
+ plain_line %| #<SuperDiff::Test::Models::ActiveRecord::Query {|
386
+ plain_line %| @results=#<ActiveRecord::Relation [|
387
+ plain_line %| #<SuperDiff::Test::Models::ActiveRecord::Person {|
388
+ plain_line %| id: 1,|
389
+ # expected_line %|- age: 19,| # TODO
390
+ expected_line %|- age: 19|
391
+ actual_line %|+ age: 20,|
392
+ # expected_line %|- name: "John"| # TODO
393
+ expected_line %|- name: "John",|
394
+ actual_line %|+ name: "Murphy"|
395
+ plain_line %| }>|
396
+ plain_line %| ]>|
397
+ plain_line %| }>|
398
+ plain_line %| ]|
398
399
  },
399
400
  )
400
401
 
@@ -0,0 +1,65 @@
1
+ shared_examples_for "integration with ActiveSupport" do
2
+ context "when comparing two different Time and ActiveSupport::TimeWithZone instances", active_record: true do
3
+ it "produces the correct failure message when used in the positive" do
4
+ as_both_colored_and_uncolored do |color_enabled|
5
+ snippet = <<~RUBY
6
+ expected = Time.utc(2011, 12, 13, 14, 15, 16)
7
+ actual = Time.utc(2011, 12, 13, 15, 15, 16).in_time_zone("Europe/Stockholm")
8
+ expect(expected).to eq(actual)
9
+ RUBY
10
+ program = make_rspec_rails_test_program(
11
+ snippet,
12
+ color_enabled: color_enabled,
13
+ )
14
+
15
+ expected_output = build_expected_output(
16
+ color_enabled: color_enabled,
17
+ snippet: %|expect(expected).to eq(actual)|,
18
+ expectation: proc {
19
+ line do
20
+ plain %|Expected |
21
+ actual %|#<Time 2011-12-13 14:15:16 +00:00 (UTC)>|
22
+ end
23
+
24
+ line do
25
+ plain %| to eq |
26
+ expected %|#<ActiveSupport::TimeWithZone 2011-12-13 16:15:16 +01:00 (CET)>|
27
+ end
28
+ },
29
+ diff: proc {
30
+ plain_line %| #<Time {|
31
+ plain_line %| year: 2011,|
32
+ plain_line %| month: 12,|
33
+ plain_line %| day: 13,|
34
+ expected_line %|- hour: 16,|
35
+ actual_line %|+ hour: 14,|
36
+ plain_line %| min: 15,|
37
+ plain_line %| sec: 16,|
38
+ plain_line %| subsec: 0,|
39
+ expected_line %|- zone: \"CET\",|
40
+ actual_line %|+ zone: \"UTC\",|
41
+ expected_line %|- utc_offset: 3600,|
42
+ actual_line %|+ utc_offset: 0,|
43
+ plain_line %| utc: #<Time {|
44
+ plain_line %| year: 2011,|
45
+ plain_line %| month: 12,|
46
+ plain_line %| day: 13,|
47
+ expected_line %|- hour: 15,|
48
+ actual_line %|+ hour: 14,|
49
+ plain_line %| min: 15,|
50
+ plain_line %| sec: 16,|
51
+ plain_line %| subsec: 0,|
52
+ plain_line %| zone: "UTC",|
53
+ plain_line %| utc_offset: 0|
54
+ plain_line %| }>|
55
+ plain_line %| }>|
56
+ },
57
+ )
58
+
59
+ expect(program).
60
+ to produce_output_when_run(expected_output).
61
+ in_color(color_enabled)
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,914 @@
1
+ shared_examples_for "a matcher that supports elided diffs" do
2
+ context "when comparing two one-dimensional data structures which feature a changed section flanked by unchanged sections" do
3
+ context "if diff_elision_enabled is set to true" do
4
+ it "elides the unchanged sections, preserving <maximum> number of lines within all unchanged sections (including the elision marker)" do
5
+ as_both_colored_and_uncolored do |color_enabled|
6
+ snippet = <<~TEST.strip
7
+ expected = [
8
+ "Afghanistan",
9
+ "Aland Islands",
10
+ "Albania",
11
+ "Algeria",
12
+ "American Samoa",
13
+ "Andorra",
14
+ "Angola",
15
+ "Antarctica",
16
+ "Antigua And Barbuda",
17
+ "Argentina",
18
+ "Armenia",
19
+ "Aruba",
20
+ "Australia"
21
+ ]
22
+ actual = [
23
+ "Afghanistan",
24
+ "Aland Islands",
25
+ "Albania",
26
+ "Algeria",
27
+ "American Samoa",
28
+ "Andorra",
29
+ "Anguilla",
30
+ "Antarctica",
31
+ "Antigua And Barbuda",
32
+ "Argentina",
33
+ "Armenia",
34
+ "Aruba",
35
+ "Australia"
36
+ ]
37
+ expect(actual).to #{matcher}(expected)
38
+ TEST
39
+ program = make_plain_test_program(
40
+ snippet,
41
+ color_enabled: color_enabled,
42
+ configuration: {
43
+ diff_elision_enabled: true,
44
+ diff_elision_maximum: 3,
45
+ },
46
+ )
47
+
48
+ expected_output = build_expected_output(
49
+ color_enabled: color_enabled,
50
+ snippet: %|expect(actual).to #{matcher}(expected)|,
51
+ newline_before_expectation: true,
52
+ expectation: proc {
53
+ line do
54
+ plain "Expected "
55
+ # rubocop:disable Layout/LineLength
56
+ actual %|["Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia"]|
57
+ # rubocop:enable Layout/LineLength
58
+ end
59
+
60
+ line do
61
+ plain " to eq "
62
+ # rubocop:disable Layout/LineLength
63
+ expected %|["Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia"]|
64
+ # rubocop:enable Layout/LineLength
65
+ end
66
+ },
67
+ diff: proc {
68
+ plain_line %| [|
69
+ elision_marker_line %| # ...|
70
+ plain_line %| "American Samoa",|
71
+ plain_line %| "Andorra",|
72
+ expected_line %|- "Angola",|
73
+ actual_line %|+ "Anguilla",|
74
+ plain_line %| "Antarctica",|
75
+ plain_line %| "Antigua And Barbuda",|
76
+ elision_marker_line %| # ...|
77
+ plain_line %| ]|
78
+ },
79
+ )
80
+
81
+ expect(program).
82
+ to produce_output_when_run(expected_output).
83
+ in_color(color_enabled)
84
+ end
85
+ end
86
+ end
87
+
88
+ context "if diff_elision_enabled is set to false" do
89
+ it "does not elide anything" do
90
+ as_both_colored_and_uncolored do |color_enabled|
91
+ snippet = <<~TEST.strip
92
+ expected = [
93
+ "Afghanistan",
94
+ "Aland Islands",
95
+ "Albania",
96
+ "Algeria",
97
+ "American Samoa",
98
+ "Andorra",
99
+ "Angola",
100
+ "Antarctica",
101
+ "Antigua And Barbuda",
102
+ "Argentina",
103
+ "Armenia",
104
+ "Aruba",
105
+ "Australia"
106
+ ]
107
+ actual = [
108
+ "Afghanistan",
109
+ "Aland Islands",
110
+ "Albania",
111
+ "Algeria",
112
+ "American Samoa",
113
+ "Andorra",
114
+ "Anguilla",
115
+ "Antarctica",
116
+ "Antigua And Barbuda",
117
+ "Argentina",
118
+ "Armenia",
119
+ "Aruba",
120
+ "Australia"
121
+ ]
122
+ expect(actual).to #{matcher}(expected)
123
+ TEST
124
+ program = make_plain_test_program(
125
+ snippet,
126
+ color_enabled: color_enabled,
127
+ configuration: {
128
+ diff_elision_enabled: false,
129
+ diff_elision_maximum: 3,
130
+ },
131
+ )
132
+
133
+ expected_output = build_expected_output(
134
+ color_enabled: color_enabled,
135
+ snippet: %|expect(actual).to #{matcher}(expected)|,
136
+ newline_before_expectation: true,
137
+ expectation: proc {
138
+ line do
139
+ plain "Expected "
140
+ # rubocop:disable Layout/LineLength
141
+ actual %|["Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia"]|
142
+ # rubocop:enable Layout/LineLength
143
+ end
144
+
145
+ line do
146
+ plain " to eq "
147
+ # rubocop:disable Layout/LineLength
148
+ expected %|["Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia"]|
149
+ # rubocop:enable Layout/LineLength
150
+ end
151
+ },
152
+ diff: proc {
153
+ plain_line %| [|
154
+ plain_line %| "Afghanistan",|
155
+ plain_line %| "Aland Islands",|
156
+ plain_line %| "Albania",|
157
+ plain_line %| "Algeria",|
158
+ plain_line %| "American Samoa",|
159
+ plain_line %| "Andorra",|
160
+ expected_line %|- "Angola",|
161
+ actual_line %|+ "Anguilla",|
162
+ plain_line %| "Antarctica",|
163
+ plain_line %| "Antigua And Barbuda",|
164
+ plain_line %| "Argentina",|
165
+ plain_line %| "Armenia",|
166
+ plain_line %| "Aruba",|
167
+ plain_line %| "Australia"|
168
+ plain_line %| ]|
169
+ },
170
+ )
171
+
172
+ expect(program).
173
+ to produce_output_when_run(expected_output).
174
+ in_color(color_enabled)
175
+ end
176
+ end
177
+ end
178
+ end
179
+
180
+ context "when comparing two one-dimensional data structures which feature a unchanged section flanked by changed sections" do
181
+ context "if diff_elision_enabled is set to true" do
182
+ it "elides the unchanged sections, preserving <maximum> number of lines within all unchanged sections (including the elision marker)" do
183
+ as_both_colored_and_uncolored do |color_enabled|
184
+ snippet = <<~TEST.strip
185
+ expected = [
186
+ "Afghanistan",
187
+ "Aland Islands",
188
+ "Albania",
189
+ "Algeria",
190
+ "American Samoa",
191
+ "Andorra",
192
+ "Angola",
193
+ "Anguilla",
194
+ "Antarctica",
195
+ "Antigua And Barbuda",
196
+ "Argentina",
197
+ "Armenia",
198
+ "Aruba",
199
+ "Australia"
200
+ ]
201
+ actual = [
202
+ "Zambia",
203
+ "Aland Islands",
204
+ "Albania",
205
+ "Algeria",
206
+ "American Samoa",
207
+ "Andorra",
208
+ "Angola",
209
+ "Anguilla",
210
+ "Antarctica",
211
+ "Antigua And Barbuda",
212
+ "Argentina",
213
+ "Armenia",
214
+ "Aruba",
215
+ "Zimbabwe"
216
+ ]
217
+ expect(actual).to #{matcher}(expected)
218
+ TEST
219
+ program = make_plain_test_program(
220
+ snippet,
221
+ color_enabled: color_enabled,
222
+ configuration: {
223
+ diff_elision_enabled: true,
224
+ diff_elision_maximum: 3,
225
+ },
226
+ )
227
+
228
+ expected_output = build_expected_output(
229
+ color_enabled: color_enabled,
230
+ snippet: %|expect(actual).to #{matcher}(expected)|,
231
+ newline_before_expectation: true,
232
+ expectation: proc {
233
+ line do
234
+ plain "Expected "
235
+ # rubocop:disable Layout/LineLength
236
+ actual %|["Zambia", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Zimbabwe"]|
237
+ # rubocop:enable Layout/LineLength
238
+ end
239
+
240
+ line do
241
+ plain " to eq "
242
+ # rubocop:disable Layout/LineLength
243
+ expected %|["Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia"]|
244
+ # rubocop:enable Layout/LineLength
245
+ end
246
+ },
247
+ diff: proc {
248
+ plain_line %| [|
249
+ expected_line %|- "Afghanistan",|
250
+ actual_line %|+ "Zambia",|
251
+ plain_line %| "Aland Islands",|
252
+ elision_marker_line %| # ...|
253
+ plain_line %| "Aruba",|
254
+ expected_line %|- "Australia"|
255
+ actual_line %|+ "Zimbabwe"|
256
+ plain_line %| ]|
257
+ },
258
+ )
259
+
260
+ expect(program).
261
+ to produce_output_when_run(expected_output).
262
+ in_color(color_enabled)
263
+ end
264
+ end
265
+ end
266
+
267
+ context "if diff_elision_enabled is set to false" do
268
+ it "does not elide anything" do
269
+ as_both_colored_and_uncolored do |color_enabled|
270
+ snippet = <<~TEST.strip
271
+ expected = [
272
+ "Afghanistan",
273
+ "Aland Islands",
274
+ "Albania",
275
+ "Algeria",
276
+ "American Samoa",
277
+ "Andorra",
278
+ "Angola",
279
+ "Anguilla",
280
+ "Antarctica",
281
+ "Antigua And Barbuda",
282
+ "Argentina",
283
+ "Armenia",
284
+ "Aruba",
285
+ "Australia"
286
+ ]
287
+ actual = [
288
+ "Zambia",
289
+ "Aland Islands",
290
+ "Albania",
291
+ "Algeria",
292
+ "American Samoa",
293
+ "Andorra",
294
+ "Angola",
295
+ "Anguilla",
296
+ "Antarctica",
297
+ "Antigua And Barbuda",
298
+ "Argentina",
299
+ "Armenia",
300
+ "Aruba",
301
+ "Zimbabwe"
302
+ ]
303
+ expect(actual).to #{matcher}(expected)
304
+ TEST
305
+ program = make_plain_test_program(
306
+ snippet,
307
+ color_enabled: color_enabled,
308
+ configuration: {
309
+ diff_elision_enabled: false,
310
+ diff_elision_maximum: 3,
311
+ },
312
+ )
313
+
314
+ expected_output = build_expected_output(
315
+ color_enabled: color_enabled,
316
+ snippet: %|expect(actual).to #{matcher}(expected)|,
317
+ newline_before_expectation: true,
318
+ expectation: proc {
319
+ line do
320
+ plain "Expected "
321
+ # rubocop:disable Layout/LineLength
322
+ actual %|["Zambia", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Zimbabwe"]|
323
+ # rubocop:enable Layout/LineLength
324
+ end
325
+
326
+ line do
327
+ plain " to eq "
328
+ # rubocop:disable Layout/LineLength
329
+ expected %|["Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia"]|
330
+ # rubocop:enable Layout/LineLength
331
+ end
332
+ },
333
+ diff: proc {
334
+ plain_line %| [|
335
+ expected_line %|- "Afghanistan",|
336
+ actual_line %|+ "Zambia",|
337
+ plain_line %| "Aland Islands",|
338
+ plain_line %| "Albania",|
339
+ plain_line %| "Algeria",|
340
+ plain_line %| "American Samoa",|
341
+ plain_line %| "Andorra",|
342
+ plain_line %| "Angola",|
343
+ plain_line %| "Anguilla",|
344
+ plain_line %| "Antarctica",|
345
+ plain_line %| "Antigua And Barbuda",|
346
+ plain_line %| "Argentina",|
347
+ plain_line %| "Armenia",|
348
+ plain_line %| "Aruba",|
349
+ expected_line %|- "Australia"|
350
+ actual_line %|+ "Zimbabwe"|
351
+ plain_line %| ]|
352
+ },
353
+ )
354
+
355
+ expect(program).
356
+ to produce_output_when_run(expected_output).
357
+ in_color(color_enabled)
358
+ end
359
+ end
360
+ end
361
+ end
362
+
363
+ context "when comparing two multi-dimensional data structures which feature large unchanged sections" do
364
+ context "if diff_elision_enabled is set to true" do
365
+ it "elides the unchanged sections, preserving <maximum> number of lines within all unchanged sections (including the elision marker)" do
366
+ # TODO see if we can correct the order of the keys here so it's not
367
+ # totally weird
368
+ as_both_colored_and_uncolored do |color_enabled|
369
+ snippet = <<~TEST.strip
370
+ expected = [
371
+ {
372
+ "user_id": "18949452",
373
+ "user": {
374
+ "id": 18949452,
375
+ "name": "Financial Times",
376
+ "screen_name": "FT",
377
+ "location": "London",
378
+ "entities": {
379
+ "url": {
380
+ "urls": [
381
+ {
382
+ "url": "http://t.co/dnhLQpd9BY",
383
+ "expanded_url": "http://www.ft.com/",
384
+ "display_url": "ft.com",
385
+ "indices": [
386
+ 0,
387
+ 22
388
+ ]
389
+ }
390
+ ]
391
+ },
392
+ "description": {
393
+ "urls": [
394
+ {
395
+ "url": "https://t.co/5BsmLs9y1Z",
396
+ "expanded_url": "http://FT.com",
397
+ "indices": [
398
+ 65,
399
+ 88
400
+ ]
401
+ }
402
+ ]
403
+ }
404
+ },
405
+ "listed_count": 37009,
406
+ "created_at": "Tue Jan 13 19:28:24 +0000 2009",
407
+ "favourites_count": 38,
408
+ "utc_offset": nil,
409
+ "time_zone": nil,
410
+ "geo_enabled": false,
411
+ "verified": true,
412
+ "statuses_count": 273860,
413
+ "media_count": 51044,
414
+ "contributors_enabled": false,
415
+ "is_translator": false,
416
+ "is_translation_enabled": false,
417
+ "profile_background_color": "FFF1E0",
418
+ "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
419
+ "profile_background_tile": false,
420
+ "profile_image_url": "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
421
+ "profile_image_url_https": "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
422
+ "profile_banner_url": "https://pbs.twimg.com/profile_banners/18949452/1581526592",
423
+ "profile_image_extensions": {
424
+ "mediaStats": {
425
+ "r": {
426
+ "missing": nil
427
+ },
428
+ "ttl": -1
429
+ }
430
+ },
431
+ "profile_banner_extensions": {},
432
+ "blocking": false,
433
+ "blocked_by": false,
434
+ "want_retweets": false,
435
+ "advertiser_account_type": "none",
436
+ "advertiser_account_service_levels": [],
437
+ "profile_interstitial_type": "",
438
+ "business_profile_state": "none",
439
+ "translator_type": "none",
440
+ "followed_by": false,
441
+ "ext": {
442
+ "highlightedLabel": {
443
+ "ttl": -1
444
+ }
445
+ },
446
+ "require_some_consent": false
447
+ },
448
+ "token": "117"
449
+ }
450
+ ]
451
+ actual = [
452
+ {
453
+ "user_id": "18949452",
454
+ "user": {
455
+ "id": 18949452,
456
+ "name": "Financial Times",
457
+ "screen_name": "FT",
458
+ "location": "London",
459
+ "url": "http://t.co/dnhLQpd9BY",
460
+ "entities": {
461
+ "url": {
462
+ "urls": [
463
+ {
464
+ "url": "http://t.co/dnhLQpd9BY",
465
+ "expanded_url": "http://www.ft.com/",
466
+ "display_url": "ft.com",
467
+ "indices": [
468
+ 0,
469
+ 22
470
+ ]
471
+ }
472
+ ]
473
+ },
474
+ "description": {
475
+ "urls": [
476
+ {
477
+ "url": "https://t.co/5BsmLs9y1Z",
478
+ "display_url": "FT.com",
479
+ "indices": [
480
+ 65,
481
+ 88
482
+ ]
483
+ }
484
+ ]
485
+ }
486
+ },
487
+ "protected": false,
488
+ "listed_count": 37009,
489
+ "created_at": "Tue Jan 13 19:28:24 +0000 2009",
490
+ "favourites_count": 38,
491
+ "utc_offset": nil,
492
+ "time_zone": nil,
493
+ "geo_enabled": false,
494
+ "verified": true,
495
+ "statuses_count": 273860,
496
+ "media_count": 51044,
497
+ "contributors_enabled": false,
498
+ "is_translator": false,
499
+ "is_translation_enabled": false,
500
+ "profile_background_color": "FFF1E0",
501
+ "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
502
+ "profile_image_url_https": "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
503
+ "profile_banner_url": "https://pbs.twimg.com/profile_banners/18949452/1581526592",
504
+ "profile_image_extensions": {
505
+ "mediaStats": {
506
+ "r": {
507
+ "missing": nil
508
+ },
509
+ "ttl": -1
510
+ }
511
+ },
512
+ "profile_banner_extensions": {},
513
+ "blocking": false,
514
+ "blocked_by": false,
515
+ "want_retweets": false,
516
+ "advertiser_account_type": "none",
517
+ "profile_interstitial_type": "",
518
+ "business_profile_state": "none",
519
+ "translator_type": "none",
520
+ "followed_by": false,
521
+ "ext": {
522
+ "highlightedLabel": {
523
+ "ttl": -1
524
+ }
525
+ },
526
+ "require_some_consent": false
527
+ },
528
+ "token": "117"
529
+ }
530
+ ]
531
+ expect(actual).to #{matcher}(expected)
532
+ TEST
533
+ program = make_plain_test_program(
534
+ snippet,
535
+ color_enabled: color_enabled,
536
+ configuration: {
537
+ diff_elision_enabled: true,
538
+ diff_elision_maximum: 10,
539
+ },
540
+ )
541
+
542
+ expected_output = build_expected_output(
543
+ color_enabled: color_enabled,
544
+ snippet: %|expect(actual).to #{matcher}(expected)|,
545
+ newline_before_expectation: true,
546
+ expectation: proc {
547
+ line do
548
+ plain "Expected "
549
+ # rubocop:disable Layout/LineLength
550
+ actual %<[{ user_id: "18949452", user: { id: 18949452, name: "Financial Times", screen_name: "FT", location: "London", url: "http://t.co/dnhLQpd9BY", entities: { url: { urls: [{ url: "http://t.co/dnhLQpd9BY", expanded_url: "http://www.ft.com/", display_url: "ft.com", indices: [0, 22] }] }, description: { urls: [{ url: "https://t.co/5BsmLs9y1Z", display_url: "FT.com", indices: [65, 88] }] } }, protected: false, listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, utc_offset: nil, time_zone: nil, geo_enabled: false, verified: true, statuses_count: 273860, media_count: 51044, contributors_enabled: false, is_translator: false, is_translation_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url: "http://abs.twimg.com/images/themes/theme1/bg.png", profile_image_url_https: "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592", profile_image_extensions: { mediaStats: { r: { missing: nil }, ttl: -1 } }, profile_banner_extensions: {}, blocking: false, blocked_by: false, want_retweets: false, advertiser_account_type: "none", profile_interstitial_type: "", business_profile_state: "none", translator_type: "none", followed_by: false, ext: { highlightedLabel: { ttl: -1 } }, require_some_consent: false }, token: "117" }]>
551
+ # rubocop:enable Layout/LineLength
552
+ end
553
+
554
+ line do
555
+ plain " to eq "
556
+ # rubocop:disable Layout/LineLength
557
+ expected %<[{ user_id: "18949452", user: { id: 18949452, name: "Financial Times", screen_name: "FT", location: "London", entities: { url: { urls: [{ url: "http://t.co/dnhLQpd9BY", expanded_url: "http://www.ft.com/", display_url: "ft.com", indices: [0, 22] }] }, description: { urls: [{ url: "https://t.co/5BsmLs9y1Z", expanded_url: "http://FT.com", indices: [65, 88] }] } }, listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, utc_offset: nil, time_zone: nil, geo_enabled: false, verified: true, statuses_count: 273860, media_count: 51044, contributors_enabled: false, is_translator: false, is_translation_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_tile: false, profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", profile_image_url_https: "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592", profile_image_extensions: { mediaStats: { r: { missing: nil }, ttl: -1 } }, profile_banner_extensions: {}, blocking: false, blocked_by: false, want_retweets: false, advertiser_account_type: "none", advertiser_account_service_levels: [], profile_interstitial_type: "", business_profile_state: "none", translator_type: "none", followed_by: false, ext: { highlightedLabel: { ttl: -1 } }, require_some_consent: false }, token: "117" }]>
558
+ # rubocop:enable Layout/LineLength
559
+ end
560
+ },
561
+ diff: proc {
562
+ plain_line %| [|
563
+ plain_line %| {|
564
+ plain_line %| user_id: "18949452",|
565
+ plain_line %| user: {|
566
+ plain_line %| id: 18949452,|
567
+ plain_line %| name: "Financial Times",|
568
+ plain_line %| screen_name: "FT",|
569
+ plain_line %| location: "London",|
570
+ actual_line %|+ url: "http://t.co/dnhLQpd9BY",|
571
+ plain_line %| entities: {|
572
+ plain_line %| url: {|
573
+ plain_line %| urls: [|
574
+ elision_marker_line %| # ...|
575
+ plain_line %| ]|
576
+ plain_line %| },|
577
+ plain_line %| description: {|
578
+ plain_line %| urls: [|
579
+ plain_line %| {|
580
+ elision_marker_line %| # ...|
581
+ expected_line %|- expanded_url: "http://FT.com",|
582
+ actual_line %|+ display_url: "FT.com",|
583
+ plain_line %| indices: [|
584
+ plain_line %| 65,|
585
+ plain_line %| 88|
586
+ plain_line %| ]|
587
+ plain_line %| }|
588
+ plain_line %| ]|
589
+ plain_line %| }|
590
+ plain_line %| },|
591
+ actual_line %|+ protected: false,|
592
+ elision_marker_line %| # ...|
593
+ expected_line %|- profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",|
594
+ expected_line %|- profile_background_tile: false,|
595
+ expected_line %|- profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",|
596
+ actual_line %|+ profile_background_image_url: "http://abs.twimg.com/images/themes/theme1/bg.png",|
597
+ plain_line %| profile_image_url_https: "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",|
598
+ plain_line %| profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592",|
599
+ plain_line %| profile_image_extensions: {|
600
+ elision_marker_line %| # ...|
601
+ plain_line %| },|
602
+ plain_line %| profile_banner_extensions: {},|
603
+ plain_line %| blocking: false,|
604
+ plain_line %| blocked_by: false,|
605
+ plain_line %| want_retweets: false,|
606
+ plain_line %| advertiser_account_type: "none",|
607
+ expected_line %|- advertiser_account_service_levels: [],|
608
+ elision_marker_line %| # ...|
609
+ plain_line %| },|
610
+ plain_line %| token: "117"|
611
+ plain_line %| }|
612
+ plain_line %| ]|
613
+ },
614
+ )
615
+
616
+ expect(program).
617
+ to produce_output_when_run(expected_output).
618
+ in_color(color_enabled)
619
+ end
620
+ end
621
+ end
622
+
623
+ context "if diff_elision_enabled is set to false" do
624
+ it "does not elide anything" do
625
+ as_both_colored_and_uncolored do |color_enabled|
626
+ snippet = <<~TEST.strip
627
+ expected = [
628
+ {
629
+ "user_id": "18949452",
630
+ "user": {
631
+ "id": 18949452,
632
+ "name": "Financial Times",
633
+ "screen_name": "FT",
634
+ "location": "London",
635
+ "entities": {
636
+ "url": {
637
+ "urls": [
638
+ {
639
+ "url": "http://t.co/dnhLQpd9BY",
640
+ "expanded_url": "http://www.ft.com/",
641
+ "display_url": "ft.com",
642
+ "indices": [
643
+ 0,
644
+ 22
645
+ ]
646
+ }
647
+ ]
648
+ },
649
+ "description": {
650
+ "urls": [
651
+ {
652
+ "url": "https://t.co/5BsmLs9y1Z",
653
+ "expanded_url": "http://FT.com",
654
+ "indices": [
655
+ 65,
656
+ 88
657
+ ]
658
+ }
659
+ ]
660
+ }
661
+ },
662
+ "listed_count": 37009,
663
+ "created_at": "Tue Jan 13 19:28:24 +0000 2009",
664
+ "favourites_count": 38,
665
+ "utc_offset": nil,
666
+ "time_zone": nil,
667
+ "geo_enabled": false,
668
+ "verified": true,
669
+ "statuses_count": 273860,
670
+ "media_count": 51044,
671
+ "contributors_enabled": false,
672
+ "is_translator": false,
673
+ "is_translation_enabled": false,
674
+ "profile_background_color": "FFF1E0",
675
+ "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
676
+ "profile_background_tile": false,
677
+ "profile_image_url": "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
678
+ "profile_image_url_https": "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
679
+ "profile_banner_url": "https://pbs.twimg.com/profile_banners/18949452/1581526592",
680
+ "profile_image_extensions": {
681
+ "mediaStats": {
682
+ "r": {
683
+ "missing": nil
684
+ },
685
+ "ttl": -1
686
+ }
687
+ },
688
+ "profile_banner_extensions": {},
689
+ "blocking": false,
690
+ "blocked_by": false,
691
+ "want_retweets": false,
692
+ "advertiser_account_type": "none",
693
+ "advertiser_account_service_levels": [],
694
+ "profile_interstitial_type": "",
695
+ "business_profile_state": "none",
696
+ "translator_type": "none",
697
+ "followed_by": false,
698
+ "ext": {
699
+ "highlightedLabel": {
700
+ "ttl": -1
701
+ }
702
+ },
703
+ "require_some_consent": false
704
+ },
705
+ "token": "117"
706
+ }
707
+ ]
708
+ actual = [
709
+ {
710
+ "user_id": "18949452",
711
+ "user": {
712
+ "id": 18949452,
713
+ "name": "Financial Times",
714
+ "screen_name": "FT",
715
+ "location": "London",
716
+ "url": "http://t.co/dnhLQpd9BY",
717
+ "entities": {
718
+ "url": {
719
+ "urls": [
720
+ {
721
+ "url": "http://t.co/dnhLQpd9BY",
722
+ "expanded_url": "http://www.ft.com/",
723
+ "display_url": "ft.com",
724
+ "indices": [
725
+ 0,
726
+ 22
727
+ ]
728
+ }
729
+ ]
730
+ },
731
+ "description": {
732
+ "urls": [
733
+ {
734
+ "url": "https://t.co/5BsmLs9y1Z",
735
+ "display_url": "FT.com",
736
+ "indices": [
737
+ 65,
738
+ 88
739
+ ]
740
+ }
741
+ ]
742
+ }
743
+ },
744
+ "protected": false,
745
+ "listed_count": 37009,
746
+ "created_at": "Tue Jan 13 19:28:24 +0000 2009",
747
+ "favourites_count": 38,
748
+ "utc_offset": nil,
749
+ "time_zone": nil,
750
+ "geo_enabled": false,
751
+ "verified": true,
752
+ "statuses_count": 273860,
753
+ "media_count": 51044,
754
+ "contributors_enabled": false,
755
+ "is_translator": false,
756
+ "is_translation_enabled": false,
757
+ "profile_background_color": "FFF1E0",
758
+ "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
759
+ "profile_image_url_https": "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",
760
+ "profile_banner_url": "https://pbs.twimg.com/profile_banners/18949452/1581526592",
761
+ "profile_image_extensions": {
762
+ "mediaStats": {
763
+ "r": {
764
+ "missing": nil
765
+ },
766
+ "ttl": -1
767
+ }
768
+ },
769
+ "profile_banner_extensions": {},
770
+ "blocking": false,
771
+ "blocked_by": false,
772
+ "want_retweets": false,
773
+ "advertiser_account_type": "none",
774
+ "profile_interstitial_type": "",
775
+ "business_profile_state": "none",
776
+ "translator_type": "none",
777
+ "followed_by": false,
778
+ "ext": {
779
+ "highlightedLabel": {
780
+ "ttl": -1
781
+ }
782
+ },
783
+ "require_some_consent": false
784
+ },
785
+ "token": "117"
786
+ }
787
+ ]
788
+ expect(actual).to #{matcher}(expected)
789
+ TEST
790
+ program = make_plain_test_program(
791
+ snippet,
792
+ color_enabled: color_enabled,
793
+ configuration: {
794
+ diff_elision_enabled: false,
795
+ diff_elision_maximum: 10,
796
+ },
797
+ )
798
+
799
+ expected_output = build_expected_output(
800
+ color_enabled: color_enabled,
801
+ snippet: %|expect(actual).to #{matcher}(expected)|,
802
+ newline_before_expectation: true,
803
+ expectation: proc {
804
+ line do
805
+ plain "Expected "
806
+ # rubocop:disable Layout/LineLength
807
+ actual %<[{ user_id: "18949452", user: { id: 18949452, name: "Financial Times", screen_name: "FT", location: "London", url: "http://t.co/dnhLQpd9BY", entities: { url: { urls: [{ url: "http://t.co/dnhLQpd9BY", expanded_url: "http://www.ft.com/", display_url: "ft.com", indices: [0, 22] }] }, description: { urls: [{ url: "https://t.co/5BsmLs9y1Z", display_url: "FT.com", indices: [65, 88] }] } }, protected: false, listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, utc_offset: nil, time_zone: nil, geo_enabled: false, verified: true, statuses_count: 273860, media_count: 51044, contributors_enabled: false, is_translator: false, is_translation_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url: "http://abs.twimg.com/images/themes/theme1/bg.png", profile_image_url_https: "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592", profile_image_extensions: { mediaStats: { r: { missing: nil }, ttl: -1 } }, profile_banner_extensions: {}, blocking: false, blocked_by: false, want_retweets: false, advertiser_account_type: "none", profile_interstitial_type: "", business_profile_state: "none", translator_type: "none", followed_by: false, ext: { highlightedLabel: { ttl: -1 } }, require_some_consent: false }, token: "117" }]>
808
+ # rubocop:enable Layout/LineLength
809
+ end
810
+
811
+ line do
812
+ plain " to eq "
813
+ # rubocop:disable Layout/LineLength
814
+ expected %<[{ user_id: "18949452", user: { id: 18949452, name: "Financial Times", screen_name: "FT", location: "London", entities: { url: { urls: [{ url: "http://t.co/dnhLQpd9BY", expanded_url: "http://www.ft.com/", display_url: "ft.com", indices: [0, 22] }] }, description: { urls: [{ url: "https://t.co/5BsmLs9y1Z", expanded_url: "http://FT.com", indices: [65, 88] }] } }, listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, utc_offset: nil, time_zone: nil, geo_enabled: false, verified: true, statuses_count: 273860, media_count: 51044, contributors_enabled: false, is_translator: false, is_translation_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_tile: false, profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", profile_image_url_https: "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592", profile_image_extensions: { mediaStats: { r: { missing: nil }, ttl: -1 } }, profile_banner_extensions: {}, blocking: false, blocked_by: false, want_retweets: false, advertiser_account_type: "none", advertiser_account_service_levels: [], profile_interstitial_type: "", business_profile_state: "none", translator_type: "none", followed_by: false, ext: { highlightedLabel: { ttl: -1 } }, require_some_consent: false }, token: "117" }]>
815
+ # rubocop:enable Layout/LineLength
816
+ end
817
+ },
818
+ diff: proc {
819
+ plain_line %| [|
820
+ plain_line %| {|
821
+ plain_line %| user_id: "18949452",|
822
+ plain_line %| user: {|
823
+ plain_line %| id: 18949452,|
824
+ plain_line %| name: "Financial Times",|
825
+ plain_line %| screen_name: "FT",|
826
+ plain_line %| location: "London",|
827
+ actual_line %|+ url: "http://t.co/dnhLQpd9BY",|
828
+ plain_line %| entities: {|
829
+ plain_line %| url: {|
830
+ plain_line %| urls: [|
831
+ plain_line %| {|
832
+ plain_line %| url: "http://t.co/dnhLQpd9BY",|
833
+ plain_line %| expanded_url: "http://www.ft.com/",|
834
+ plain_line %| display_url: "ft.com",|
835
+ plain_line %| indices: [|
836
+ plain_line %| 0,|
837
+ plain_line %| 22|
838
+ plain_line %| ]|
839
+ plain_line %| }|
840
+ plain_line %| ]|
841
+ plain_line %| },|
842
+ plain_line %| description: {|
843
+ plain_line %| urls: [|
844
+ plain_line %| {|
845
+ plain_line %| url: "https://t.co/5BsmLs9y1Z",|
846
+ expected_line %|- expanded_url: "http://FT.com",|
847
+ actual_line %|+ display_url: "FT.com",|
848
+ plain_line %| indices: [|
849
+ plain_line %| 65,|
850
+ plain_line %| 88|
851
+ plain_line %| ]|
852
+ plain_line %| }|
853
+ plain_line %| ]|
854
+ plain_line %| }|
855
+ plain_line %| },|
856
+ actual_line %|+ protected: false,|
857
+ plain_line %| listed_count: 37009,|
858
+ plain_line %| created_at: "Tue Jan 13 19:28:24 +0000 2009",|
859
+ plain_line %| favourites_count: 38,|
860
+ plain_line %| utc_offset: nil,|
861
+ plain_line %| time_zone: nil,|
862
+ plain_line %| geo_enabled: false,|
863
+ plain_line %| verified: true,|
864
+ plain_line %| statuses_count: 273860,|
865
+ plain_line %| media_count: 51044,|
866
+ plain_line %| contributors_enabled: false,|
867
+ plain_line %| is_translator: false,|
868
+ plain_line %| is_translation_enabled: false,|
869
+ plain_line %| profile_background_color: "FFF1E0",|
870
+ expected_line %|- profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",|
871
+ expected_line %|- profile_background_tile: false,|
872
+ expected_line %|- profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",|
873
+ actual_line %|+ profile_background_image_url: "http://abs.twimg.com/images/themes/theme1/bg.png",|
874
+ plain_line %| profile_image_url_https: "https://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",|
875
+ plain_line %| profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592",|
876
+ plain_line %| profile_image_extensions: {|
877
+ plain_line %| mediaStats: {|
878
+ plain_line %| r: {|
879
+ plain_line %| missing: nil|
880
+ plain_line %| },|
881
+ plain_line %| ttl: -1|
882
+ plain_line %| }|
883
+ plain_line %| },|
884
+ plain_line %| profile_banner_extensions: {},|
885
+ plain_line %| blocking: false,|
886
+ plain_line %| blocked_by: false,|
887
+ plain_line %| want_retweets: false,|
888
+ plain_line %| advertiser_account_type: "none",|
889
+ expected_line %|- advertiser_account_service_levels: [],|
890
+ plain_line %| profile_interstitial_type: "",|
891
+ plain_line %| business_profile_state: "none",|
892
+ plain_line %| translator_type: "none",|
893
+ plain_line %| followed_by: false,|
894
+ plain_line %| ext: {|
895
+ plain_line %| highlightedLabel: {|
896
+ plain_line %| ttl: -1|
897
+ plain_line %| }|
898
+ plain_line %| },|
899
+ plain_line %| require_some_consent: false|
900
+ plain_line %| },|
901
+ plain_line %| token: "117"|
902
+ plain_line %| }|
903
+ plain_line %| ]|
904
+ },
905
+ )
906
+
907
+ expect(program).
908
+ to produce_output_when_run(expected_output).
909
+ in_color(color_enabled)
910
+ end
911
+ end
912
+ end
913
+ end
914
+ end