super_diff 0.13.0 → 0.14.0

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