super_diff 0.10.0 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +19 -166
  3. data/lib/super_diff/active_record/differs/active_record_relation.rb +1 -1
  4. data/lib/super_diff/active_record/inspection_tree_builders/active_record_model.rb +57 -0
  5. data/lib/super_diff/active_record/inspection_tree_builders/active_record_relation.rb +34 -0
  6. data/lib/super_diff/active_record/inspection_tree_builders.rb +14 -0
  7. data/lib/super_diff/active_record/monkey_patches.rb +6 -3
  8. data/lib/super_diff/active_record/object_inspection.rb +16 -4
  9. data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +6 -2
  10. data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +1 -1
  11. data/lib/super_diff/active_record/operation_tree_flatteners/active_record_relation.rb +1 -1
  12. data/lib/super_diff/active_record/operation_trees/active_record_relation.rb +1 -1
  13. data/lib/super_diff/active_record.rb +12 -16
  14. data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +1 -1
  15. data/lib/super_diff/active_support/inspection_tree_builders/hash_with_indifferent_access.rb +44 -0
  16. data/lib/super_diff/active_support/inspection_tree_builders/ordered_options.rb +44 -0
  17. data/lib/super_diff/active_support/inspection_tree_builders.rb +14 -0
  18. data/lib/super_diff/active_support/object_inspection.rb +16 -4
  19. data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +1 -1
  20. data/lib/super_diff/active_support/operation_tree_flatteners/hash_with_indifferent_access.rb +1 -1
  21. data/lib/super_diff/active_support/operation_trees/hash_with_indifferent_access.rb +1 -1
  22. data/lib/super_diff/active_support.rb +11 -14
  23. data/lib/super_diff/basic/diff_formatters/collection.rb +135 -0
  24. data/lib/super_diff/basic/diff_formatters/multiline_string.rb +34 -0
  25. data/lib/super_diff/basic/diff_formatters.rb +11 -0
  26. data/lib/super_diff/basic/differs/array.rb +17 -0
  27. data/lib/super_diff/basic/differs/custom_object.rb +19 -0
  28. data/lib/super_diff/basic/differs/date_like.rb +17 -0
  29. data/lib/super_diff/basic/differs/default_object.rb +24 -0
  30. data/lib/super_diff/basic/differs/hash.rb +17 -0
  31. data/lib/super_diff/basic/differs/multiline_string.rb +18 -0
  32. data/lib/super_diff/basic/differs/time_like.rb +17 -0
  33. data/lib/super_diff/basic/differs.rb +24 -0
  34. data/lib/super_diff/basic/inspection_tree_builders/array.rb +53 -0
  35. data/lib/super_diff/basic/inspection_tree_builders/custom_object.rb +41 -0
  36. data/lib/super_diff/basic/inspection_tree_builders/date_like.rb +51 -0
  37. data/lib/super_diff/basic/inspection_tree_builders/default_object.rb +77 -0
  38. data/lib/super_diff/basic/inspection_tree_builders/hash.rb +63 -0
  39. data/lib/super_diff/basic/inspection_tree_builders/primitive.rb +19 -0
  40. data/lib/super_diff/basic/inspection_tree_builders/time_like.rb +58 -0
  41. data/lib/super_diff/basic/inspection_tree_builders.rb +20 -0
  42. data/lib/super_diff/basic/operation_tree_builders/array.rb +111 -0
  43. data/lib/super_diff/basic/operation_tree_builders/custom_object.rb +42 -0
  44. data/lib/super_diff/basic/operation_tree_builders/date_like.rb +17 -0
  45. data/lib/super_diff/basic/operation_tree_builders/default_object.rb +117 -0
  46. data/lib/super_diff/basic/operation_tree_builders/hash.rb +222 -0
  47. data/lib/super_diff/basic/operation_tree_builders/multiline_string.rb +90 -0
  48. data/lib/super_diff/basic/operation_tree_builders/time_like.rb +26 -0
  49. data/lib/super_diff/basic/operation_tree_builders.rb +34 -0
  50. data/lib/super_diff/basic/operation_tree_flatteners/array.rb +17 -0
  51. data/lib/super_diff/basic/operation_tree_flatteners/collection.rb +140 -0
  52. data/lib/super_diff/basic/operation_tree_flatteners/custom_object.rb +30 -0
  53. data/lib/super_diff/basic/operation_tree_flatteners/default_object.rb +32 -0
  54. data/lib/super_diff/basic/operation_tree_flatteners/hash.rb +35 -0
  55. data/lib/super_diff/basic/operation_tree_flatteners/multiline_string.rb +20 -0
  56. data/lib/super_diff/basic/operation_tree_flatteners.rb +24 -0
  57. data/lib/super_diff/basic/operation_trees/array.rb +17 -0
  58. data/lib/super_diff/basic/operation_trees/custom_object.rb +17 -0
  59. data/lib/super_diff/basic/operation_trees/default_object.rb +42 -0
  60. data/lib/super_diff/basic/operation_trees/hash.rb +17 -0
  61. data/lib/super_diff/basic/operation_trees/multiline_string.rb +17 -0
  62. data/lib/super_diff/basic/operation_trees.rb +25 -0
  63. data/lib/super_diff/basic.rb +48 -0
  64. data/lib/super_diff/{differs/base.rb → core/abstract_differ.rb} +2 -2
  65. data/lib/super_diff/core/abstract_inspection_tree_builder.rb +26 -0
  66. data/lib/super_diff/{operation_trees/base.rb → core/abstract_operation_tree.rb} +6 -2
  67. data/lib/super_diff/{operation_tree_builders/base.rb → core/abstract_operation_tree_builder.rb} +4 -8
  68. data/lib/super_diff/{operation_tree_flatteners/base.rb → core/abstract_operation_tree_flattener.rb} +2 -2
  69. data/lib/super_diff/{operations → core}/binary_operation.rb +1 -1
  70. data/lib/super_diff/core/colorized_document_extensions.rb +20 -0
  71. data/lib/super_diff/core/configuration.rb +192 -0
  72. data/lib/super_diff/core/differ_dispatcher.rb +31 -0
  73. data/lib/super_diff/core/gem_version.rb +47 -0
  74. data/lib/super_diff/core/helpers.rb +88 -0
  75. data/lib/super_diff/core/implementation_checks.rb +21 -0
  76. data/lib/super_diff/{object_inspection → core}/inspection_tree.rb +32 -26
  77. data/lib/super_diff/core/inspection_tree_builder_dispatcher.rb +23 -0
  78. data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/as_lines_when_rendering_to_lines.rb +12 -5
  79. data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/as_prefix_when_rendering_to_lines.rb +3 -3
  80. data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/as_prelude_when_rendering_to_lines.rb +3 -3
  81. data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/as_single_line.rb +3 -3
  82. data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/base.rb +2 -2
  83. data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/inspection.rb +7 -11
  84. data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/nesting.rb +2 -2
  85. data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/only_when.rb +2 -2
  86. data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/text.rb +2 -2
  87. data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/when_empty.rb +2 -2
  88. data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/when_non_empty.rb +2 -2
  89. data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/when_rendering_to_lines.rb +2 -2
  90. data/lib/super_diff/{object_inspection/nodes → core/inspection_tree_nodes}/when_rendering_to_string.rb +2 -2
  91. data/lib/super_diff/core/inspection_tree_nodes.rb +55 -0
  92. data/lib/super_diff/core/line.rb +85 -0
  93. data/lib/super_diff/{errors → core}/no_differ_available_error.rb +1 -1
  94. data/lib/super_diff/core/no_inspection_tree_builder_available_error.rb +21 -0
  95. data/lib/super_diff/core/no_operation_tree_available_error.rb +20 -0
  96. data/lib/super_diff/{errors/no_operational_sequencer_available_error.rb → core/no_operation_tree_builder_available_error.rb} +6 -4
  97. data/lib/super_diff/{operation_tree_builders/main.rb → core/operation_tree_builder_dispatcher.rb} +9 -13
  98. data/lib/super_diff/core/operation_tree_finder.rb +27 -0
  99. data/lib/super_diff/core/prefix_for_next_inspection_tree_node.rb +6 -0
  100. data/lib/super_diff/core/prelude_for_next_inspection_tree_node.rb +6 -0
  101. data/lib/super_diff/core/recursion_guard.rb +52 -0
  102. data/lib/super_diff/core/tiered_lines.rb +6 -0
  103. data/lib/super_diff/core/tiered_lines_elider.rb +472 -0
  104. data/lib/super_diff/core/tiered_lines_formatter.rb +77 -0
  105. data/lib/super_diff/{operations → core}/unary_operation.rb +1 -1
  106. data/lib/super_diff/core.rb +69 -0
  107. data/lib/super_diff/differs.rb +19 -11
  108. data/lib/super_diff/equality_matchers/array.rb +3 -3
  109. data/lib/super_diff/equality_matchers/default.rb +8 -3
  110. data/lib/super_diff/equality_matchers/hash.rb +3 -3
  111. data/lib/super_diff/equality_matchers/multiline_string.rb +3 -3
  112. data/lib/super_diff/equality_matchers/primitive.rb +3 -3
  113. data/lib/super_diff/equality_matchers/singleline_string.rb +2 -2
  114. data/lib/super_diff/errors.rb +12 -12
  115. data/lib/super_diff/object_inspection.rb +63 -14
  116. data/lib/super_diff/operation_tree_builders.rb +19 -14
  117. data/lib/super_diff/operation_tree_flatteners.rb +19 -16
  118. data/lib/super_diff/operation_trees.rb +19 -9
  119. data/lib/super_diff/operations.rb +12 -2
  120. data/lib/super_diff/rspec/augmented_matcher.rb +1 -1
  121. data/lib/super_diff/rspec/differ.rb +4 -5
  122. data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +1 -1
  123. data/lib/super_diff/rspec/differs/collection_including.rb +1 -1
  124. data/lib/super_diff/rspec/differs/hash_including.rb +1 -1
  125. data/lib/super_diff/rspec/differs/object_having_attributes.rb +1 -1
  126. data/lib/super_diff/rspec/inspection_tree_builders/collection_containing_exactly.rb +34 -0
  127. data/lib/super_diff/rspec/inspection_tree_builders/collection_including.rb +40 -0
  128. data/lib/super_diff/rspec/inspection_tree_builders/double.rb +100 -0
  129. data/lib/super_diff/rspec/inspection_tree_builders/generic_describable_matcher.rb +17 -0
  130. data/lib/super_diff/rspec/inspection_tree_builders/hash_including.rb +40 -0
  131. data/lib/super_diff/rspec/inspection_tree_builders/instance_of.rb +25 -0
  132. data/lib/super_diff/rspec/inspection_tree_builders/kind_of.rb +25 -0
  133. data/lib/super_diff/rspec/inspection_tree_builders/object_having_attributes.rb +34 -0
  134. data/lib/super_diff/rspec/inspection_tree_builders/primitive.rb +9 -0
  135. data/lib/super_diff/rspec/inspection_tree_builders/value_within.rb +30 -0
  136. data/lib/super_diff/rspec/inspection_tree_builders.rb +40 -0
  137. data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +3 -7
  138. data/lib/super_diff/rspec/monkey_patches.rb +59 -8
  139. data/lib/super_diff/rspec/object_inspection.rb +14 -4
  140. data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +4 -4
  141. data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +1 -1
  142. data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +1 -1
  143. data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +2 -2
  144. data/lib/super_diff/rspec.rb +28 -25
  145. data/lib/super_diff/version.rb +1 -1
  146. data/lib/super_diff.rb +78 -21
  147. data/spec/examples.txt +704 -493
  148. data/spec/integration/rails/engines_spec.rb +8 -3
  149. data/spec/integration/rspec/contain_exactly_matcher_spec.rb +19 -19
  150. data/spec/integration/rspec/eq_matcher_spec.rb +111 -39
  151. data/spec/integration/rspec/generic_describable_matchers_spec.rb +177 -0
  152. data/spec/integration/rspec/have_attributes_matcher_spec.rb +25 -25
  153. data/spec/integration/rspec/include_matcher_spec.rb +23 -23
  154. data/spec/integration/rspec/magic_metadata_spec.rb +51 -0
  155. data/spec/integration/rspec/match_array_matcher_spec.rb +30 -30
  156. data/spec/integration/rspec/match_matcher_spec.rb +93 -93
  157. data/spec/integration/rspec/raise_error_matcher_spec.rb +813 -69
  158. data/spec/internal/log/test.log +0 -0
  159. data/spec/spec_helper.rb +3 -0
  160. data/spec/support/integration/helpers.rb +19 -11
  161. data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +1 -1
  162. data/spec/support/integration/matchers.rb +34 -0
  163. data/spec/support/integration/test_programs/base.rb +6 -6
  164. data/spec/support/integration/test_programs/rspec_rails_engine.rb +3 -13
  165. data/spec/support/models/active_record/person.rb +8 -1
  166. data/spec/support/shared_examples/active_record.rb +38 -38
  167. data/spec/support/shared_examples/active_support.rb +125 -4
  168. data/spec/support/shared_examples/elided_diffs.rb +48 -48
  169. data/spec/support/shared_examples/hash_with_indifferent_access.rb +88 -88
  170. data/spec/support/shared_examples/key.rb +10 -10
  171. data/spec/support/unit/helpers.rb +12 -1
  172. data/spec/support/unit/matchers/be_deprecated_in_favor_of.rb +39 -0
  173. data/spec/unit/active_record/object_inspection_spec.rb +5 -5
  174. data/spec/unit/active_support/object_inspection_spec.rb +170 -0
  175. data/spec/unit/{operation_tree_flatteners → basic/operation_tree_flatteners}/array_spec.rb +8 -8
  176. data/spec/unit/{operation_tree_flatteners → basic/operation_tree_flatteners}/custom_object_spec.rb +9 -9
  177. data/spec/unit/{operation_tree_flatteners → basic/operation_tree_flatteners}/default_object_spec.rb +9 -9
  178. data/spec/unit/{operation_tree_flatteners → basic/operation_tree_flatteners}/hash_spec.rb +8 -8
  179. data/spec/unit/{operation_tree_flatteners → basic/operation_tree_flatteners}/multiline_string_spec.rb +4 -4
  180. data/spec/unit/{helpers_spec.rb → core/helpers_spec.rb} +2 -2
  181. data/spec/unit/{tiered_lines_elider_spec.rb → core/tiered_lines_elider_spec.rb} +2 -2
  182. data/spec/unit/{tiered_lines_formatter_spec.rb → core/tiered_lines_formatter_spec.rb} +1 -1
  183. data/spec/unit/deprecations_spec.rb +176 -0
  184. data/spec/unit/equality_matchers/main_spec.rb +5 -5
  185. data/spec/unit/rspec/matchers/raise_error_spec.rb +43 -11
  186. data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +91 -0
  187. data/spec/unit/rspec/object_inspection_spec.rb +2 -2
  188. data/spec/unit/super_diff_spec.rb +64 -0
  189. data/super_diff.gemspec +6 -0
  190. metadata +137 -112
  191. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +0 -39
  192. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +0 -27
  193. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +0 -16
  194. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +0 -31
  195. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +0 -12
  196. data/lib/super_diff/colorized_document_extensions.rb +0 -18
  197. data/lib/super_diff/configuration.rb +0 -149
  198. data/lib/super_diff/diff_formatters/collection.rb +0 -132
  199. data/lib/super_diff/diff_formatters/multiline_string.rb +0 -31
  200. data/lib/super_diff/differs/array.rb +0 -15
  201. data/lib/super_diff/differs/custom_object.rb +0 -17
  202. data/lib/super_diff/differs/default_object.rb +0 -19
  203. data/lib/super_diff/differs/defaults.rb +0 -12
  204. data/lib/super_diff/differs/empty.rb +0 -13
  205. data/lib/super_diff/differs/hash.rb +0 -15
  206. data/lib/super_diff/differs/main.rb +0 -31
  207. data/lib/super_diff/differs/multiline_string.rb +0 -16
  208. data/lib/super_diff/differs/time_like.rb +0 -15
  209. data/lib/super_diff/errors/no_diff_formatter_available_error.rb +0 -21
  210. data/lib/super_diff/gem_version.rb +0 -45
  211. data/lib/super_diff/helpers.rb +0 -86
  212. data/lib/super_diff/implementation_checks.rb +0 -19
  213. data/lib/super_diff/line.rb +0 -83
  214. data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +0 -34
  215. data/lib/super_diff/object_inspection/inspection_tree_builders/base.rb +0 -27
  216. data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +0 -31
  217. data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +0 -54
  218. data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +0 -14
  219. data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +0 -38
  220. data/lib/super_diff/object_inspection/inspection_tree_builders/main.rb +0 -30
  221. data/lib/super_diff/object_inspection/inspection_tree_builders/primitive.rb +0 -21
  222. data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +0 -47
  223. data/lib/super_diff/object_inspection/inspection_tree_builders.rb +0 -44
  224. data/lib/super_diff/object_inspection/nodes.rb +0 -50
  225. data/lib/super_diff/object_inspection/prefix_for_next_node.rb +0 -6
  226. data/lib/super_diff/object_inspection/prelude_for_next_node.rb +0 -6
  227. data/lib/super_diff/operation_tree_builders/array.rb +0 -107
  228. data/lib/super_diff/operation_tree_builders/custom_object.rb +0 -40
  229. data/lib/super_diff/operation_tree_builders/default_object.rb +0 -119
  230. data/lib/super_diff/operation_tree_builders/defaults.rb +0 -5
  231. data/lib/super_diff/operation_tree_builders/hash.rb +0 -218
  232. data/lib/super_diff/operation_tree_builders/multiline_string.rb +0 -86
  233. data/lib/super_diff/operation_tree_builders/time_like.rb +0 -24
  234. data/lib/super_diff/operation_tree_flatteners/array.rb +0 -15
  235. data/lib/super_diff/operation_tree_flatteners/collection.rb +0 -136
  236. data/lib/super_diff/operation_tree_flatteners/custom_object.rb +0 -28
  237. data/lib/super_diff/operation_tree_flatteners/default_object.rb +0 -31
  238. data/lib/super_diff/operation_tree_flatteners/hash.rb +0 -33
  239. data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +0 -18
  240. data/lib/super_diff/operation_trees/array.rb +0 -15
  241. data/lib/super_diff/operation_trees/custom_object.rb +0 -15
  242. data/lib/super_diff/operation_trees/default_object.rb +0 -40
  243. data/lib/super_diff/operation_trees/defaults.rb +0 -5
  244. data/lib/super_diff/operation_trees/hash.rb +0 -15
  245. data/lib/super_diff/operation_trees/main.rb +0 -35
  246. data/lib/super_diff/operation_trees/multiline_string.rb +0 -15
  247. data/lib/super_diff/recursion_guard.rb +0 -50
  248. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_containing_exactly.rb +0 -29
  249. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +0 -36
  250. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +0 -98
  251. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +0 -37
  252. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +0 -28
  253. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +0 -28
  254. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/object_having_attributes.rb +0 -29
  255. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/primitive.rb +0 -10
  256. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/value_within.rb +0 -33
  257. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +0 -44
  258. data/lib/super_diff/tiered_lines.rb +0 -4
  259. data/lib/super_diff/tiered_lines_elider.rb +0 -462
  260. data/lib/super_diff/tiered_lines_formatter.rb +0 -75
@@ -6,8 +6,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
6
6
  it "produces the correct failure message when used in the positive" do
7
7
  as_both_colored_and_uncolored do |color_enabled|
8
8
  snippet = <<~TEST.strip
9
- expected = a_hash_including(city: "Hill Valley")
10
9
  actual = { city: "Burbank" }
10
+ expected = a_hash_including(city: "Hill Valley")
11
11
  expect(actual).to match(expected)
12
12
  TEST
13
13
  program =
@@ -45,8 +45,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
45
45
  it "produces the correct failure message when used in the negative" do
46
46
  as_both_colored_and_uncolored do |color_enabled|
47
47
  snippet = <<~TEST.strip
48
- expected = a_hash_including(city: "Burbank")
49
48
  actual = { city: "Burbank" }
49
+ expected = a_hash_including(city: "Burbank")
50
50
  expect(actual).not_to match(expected)
51
51
  TEST
52
52
  program =
@@ -79,16 +79,16 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
79
79
  it "produces the correct failure message when used in the positive" do
80
80
  as_both_colored_and_uncolored do |color_enabled|
81
81
  snippet = <<~TEST.strip
82
- expected = a_hash_including(
83
- city: "Hill Valley",
84
- zip: "90382"
85
- )
86
82
  actual = {
87
83
  line_1: "123 Main St.",
88
84
  city: "Burbank",
89
85
  state: "CA",
90
86
  zip: "90210"
91
87
  }
88
+ expected = a_hash_including(
89
+ city: "Hill Valley",
90
+ zip: "90382"
91
+ )
92
92
  expect(actual).to match(expected)
93
93
  TEST
94
94
  program =
@@ -132,16 +132,16 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
132
132
  it "produces the correct failure message when used in the negative" do
133
133
  as_both_colored_and_uncolored do |color_enabled|
134
134
  snippet = <<~TEST.strip
135
- expected = a_hash_including(
136
- city: "Burbank",
137
- zip: "90210"
138
- )
139
135
  actual = {
140
136
  line_1: "123 Main St.",
141
137
  city: "Burbank",
142
138
  state: "CA",
143
139
  zip: "90210"
144
140
  }
141
+ expected = a_hash_including(
142
+ city: "Burbank",
143
+ zip: "90210"
144
+ )
145
145
  expect(actual).not_to match(expected)
146
146
  TEST
147
147
  program =
@@ -179,13 +179,6 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
179
179
  it "produces the correct failure message when used in the positive" do
180
180
  as_both_colored_and_uncolored do |color_enabled|
181
181
  snippet = <<~TEST.strip
182
- expected = {
183
- name: "Marty McFly",
184
- address: a_hash_including(
185
- city: "Hill Valley",
186
- zip: "90382"
187
- )
188
- }
189
182
  actual = {
190
183
  name: "Marty McFly",
191
184
  address: {
@@ -195,6 +188,13 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
195
188
  zip: "90210"
196
189
  }
197
190
  }
191
+ expected = {
192
+ name: "Marty McFly",
193
+ address: a_hash_including(
194
+ city: "Hill Valley",
195
+ zip: "90382"
196
+ )
197
+ }
198
198
  expect(actual).to match(expected)
199
199
  TEST
200
200
  program =
@@ -241,13 +241,6 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
241
241
  it "produces the correct failure message when used in the negative" do
242
242
  as_both_colored_and_uncolored do |color_enabled|
243
243
  snippet = <<~TEST.strip
244
- expected = {
245
- name: "Marty McFly",
246
- address: a_hash_including(
247
- city: "Burbank",
248
- zip: "90210"
249
- )
250
- }
251
244
  actual = {
252
245
  name: "Marty McFly",
253
246
  address: {
@@ -257,6 +250,13 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
257
250
  zip: "90210"
258
251
  }
259
252
  }
253
+ expected = {
254
+ name: "Marty McFly",
255
+ address: a_hash_including(
256
+ city: "Burbank",
257
+ zip: "90210"
258
+ )
259
+ }
260
260
  expect(actual).not_to match(expected)
261
261
  TEST
262
262
  program =
@@ -292,6 +292,10 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
292
292
  it "produces the correct failure message" do
293
293
  as_both_colored_and_uncolored do |color_enabled|
294
294
  snippet = <<~TEST.strip
295
+ actual = {
296
+ name: "Marty McFly",
297
+ address: nil
298
+ }
295
299
  expected = {
296
300
  name: "Marty McFly",
297
301
  address: a_hash_including(
@@ -299,10 +303,6 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
299
303
  zip: "90382"
300
304
  )
301
305
  }
302
- actual = {
303
- name: "Marty McFly",
304
- address: nil
305
- }
306
306
  expect(actual).to match(expected)
307
307
  TEST
308
308
  program =
@@ -351,8 +351,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
351
351
  it "produces the correct failure message" do
352
352
  as_both_colored_and_uncolored do |color_enabled|
353
353
  snippet = <<~TEST.strip
354
- expected = hash_including(city: "Hill Valley")
355
354
  actual = { city: "Burbank" }
355
+ expected = hash_including(city: "Hill Valley")
356
356
  expect(actual).to match(expected)
357
357
  TEST
358
358
  program = make_plain_test_program(snippet, color_enabled: color_enabled)
@@ -392,8 +392,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
392
392
  it "produces the correct failure message when used in the positive" do
393
393
  as_both_colored_and_uncolored do |color_enabled|
394
394
  snippet = <<~TEST.strip
395
- expected = a_collection_including("a")
396
395
  actual = ["b"]
396
+ expected = a_collection_including("a")
397
397
  expect(actual).to match(expected)
398
398
  TEST
399
399
  program =
@@ -432,8 +432,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
432
432
  it "produces the correct failure message when used in the negative" do
433
433
  as_both_colored_and_uncolored do |color_enabled|
434
434
  snippet = <<~TEST.strip
435
- expected = a_collection_including("b")
436
435
  actual = ["b"]
436
+ expected = a_collection_including("b")
437
437
  expect(actual).not_to match(expected)
438
438
  TEST
439
439
  program =
@@ -466,8 +466,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
466
466
  it "produces the correct failure message when used in the positive" do
467
467
  as_both_colored_and_uncolored do |color_enabled|
468
468
  snippet = <<~TEST.strip
469
- expected = a_collection_including("milk", "bread")
470
469
  actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
470
+ expected = a_collection_including("milk", "bread")
471
471
  expect(actual).to match(expected)
472
472
  TEST
473
473
  program =
@@ -512,8 +512,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
512
512
  it "produces the correct failure message when used in the negative" do
513
513
  as_both_colored_and_uncolored do |color_enabled|
514
514
  snippet = <<~TEST.strip
515
- expected = a_collection_including("milk", "toast")
516
515
  actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
516
+ expected = a_collection_including("milk", "toast")
517
517
  expect(actual).not_to match(expected)
518
518
  TEST
519
519
  program =
@@ -551,14 +551,14 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
551
551
  it "produces the correct failure message when used in the positive" do
552
552
  as_both_colored_and_uncolored do |color_enabled|
553
553
  snippet = <<~TEST.strip
554
- expected = {
555
- name: "shopping list",
556
- contents: a_collection_including("milk", "bread")
557
- }
558
554
  actual = {
559
555
  name: "shopping list",
560
556
  contents: ["milk", "toast", "eggs"]
561
557
  }
558
+ expected = {
559
+ name: "shopping list",
560
+ contents: a_collection_including("milk", "bread")
561
+ }
562
562
  expect(actual).to match(expected)
563
563
  TEST
564
564
  program =
@@ -604,14 +604,14 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
604
604
  it "produces the correct failure message when used in the negative" do
605
605
  as_both_colored_and_uncolored do |color_enabled|
606
606
  snippet = <<~TEST.strip
607
- expected = {
608
- name: "shopping list",
609
- contents: a_collection_including("milk", "toast")
610
- }
611
607
  actual = {
612
608
  name: "shopping list",
613
609
  contents: ["milk", "toast", "eggs"]
614
610
  }
611
+ expected = {
612
+ name: "shopping list",
613
+ contents: a_collection_including("milk", "toast")
614
+ }
615
615
  expect(actual).not_to match(expected)
616
616
  TEST
617
617
  program =
@@ -647,14 +647,14 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
647
647
  it "produces the correct failure message" do
648
648
  as_both_colored_and_uncolored do |color_enabled|
649
649
  snippet = <<~TEST.strip
650
- expected = {
651
- name: "shopping list",
652
- contents: a_collection_including("milk", "bread")
653
- }
654
650
  actual = {
655
651
  name: "shopping list",
656
652
  contents: nil
657
653
  }
654
+ expected = {
655
+ name: "shopping list",
656
+ contents: a_collection_including("milk", "bread")
657
+ }
658
658
  expect(actual).to match(expected)
659
659
  TEST
660
660
  program =
@@ -701,8 +701,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
701
701
  it "produces the correct failure message" do
702
702
  as_both_colored_and_uncolored do |color_enabled|
703
703
  snippet = <<~TEST.strip
704
- expected = array_including("a")
705
704
  actual = ["b"]
705
+ expected = array_including("a")
706
706
  expect(actual).to match(expected)
707
707
  TEST
708
708
  program = make_plain_test_program(snippet, color_enabled: color_enabled)
@@ -743,8 +743,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
743
743
  it "produces the correct failure message when used in the positive" do
744
744
  as_both_colored_and_uncolored do |color_enabled|
745
745
  snippet = <<~TEST.strip
746
- expected = an_object_having_attributes(name: "b")
747
746
  actual = A.new("a")
747
+ expected = an_object_having_attributes(name: "b")
748
748
  expect(actual).to match(expected)
749
749
  TEST
750
750
  program =
@@ -783,8 +783,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
783
783
  it "produces the correct failure message when used in the negative" do
784
784
  as_both_colored_and_uncolored do |color_enabled|
785
785
  snippet = <<~TEST.strip
786
- expected = an_object_having_attributes(name: "b")
787
786
  actual = A.new("b")
787
+ expected = an_object_having_attributes(name: "b")
788
788
  expect(actual).not_to match(expected)
789
789
  TEST
790
790
  program =
@@ -817,13 +817,6 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
817
817
  it "produces the correct failure message when used in the positive" do
818
818
  as_both_colored_and_uncolored do |color_enabled|
819
819
  snippet = <<~TEST.strip
820
- expected = an_object_having_attributes(
821
- line_1: "123 Main St.",
822
- city: "Oakland",
823
- zip: "91234",
824
- state: "CA",
825
- something_else: "blah"
826
- )
827
820
  actual = SuperDiff::Test::ShippingAddress.new(
828
821
  line_1: "456 Ponderosa Ct.",
829
822
  line_2: nil,
@@ -831,6 +824,13 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
831
824
  state: "CA",
832
825
  zip: "90382"
833
826
  )
827
+ expected = an_object_having_attributes(
828
+ line_1: "123 Main St.",
829
+ city: "Oakland",
830
+ zip: "91234",
831
+ state: "CA",
832
+ something_else: "blah"
833
+ )
834
834
  expect(actual).to match(expected)
835
835
  TEST
836
836
  program =
@@ -880,11 +880,6 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
880
880
  it "produces the correct failure message when used in the negative" do
881
881
  as_both_colored_and_uncolored do |color_enabled|
882
882
  snippet = <<~TEST.strip
883
- expected = an_object_having_attributes(
884
- line_1: "123 Main St.",
885
- city: "Oakland",
886
- zip: "91234"
887
- )
888
883
  actual = SuperDiff::Test::ShippingAddress.new(
889
884
  line_1: "123 Main St.",
890
885
  line_2: nil,
@@ -892,6 +887,11 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
892
887
  zip: "91234",
893
888
  state: "CA"
894
889
  )
890
+ expected = an_object_having_attributes(
891
+ line_1: "123 Main St.",
892
+ city: "Oakland",
893
+ zip: "91234"
894
+ )
895
895
  expect(actual).not_to match(expected)
896
896
  TEST
897
897
  program =
@@ -928,16 +928,6 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
928
928
  it "produces the correct failure message when used in the positive" do
929
929
  as_both_colored_and_uncolored do |color_enabled|
930
930
  snippet = <<~TEST.strip
931
- expected = {
932
- name: "Marty McFly",
933
- shipping_address: an_object_having_attributes(
934
- line_1: "123 Main St.",
935
- city: "Oakland",
936
- state: "CA",
937
- zip: "91234",
938
- something_else: "blah"
939
- )
940
- }
941
931
  actual = {
942
932
  name: "Marty McFly",
943
933
  shipping_address: SuperDiff::Test::ShippingAddress.new(
@@ -948,6 +938,16 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
948
938
  zip: "90382"
949
939
  )
950
940
  }
941
+ expected = {
942
+ name: "Marty McFly",
943
+ shipping_address: an_object_having_attributes(
944
+ line_1: "123 Main St.",
945
+ city: "Oakland",
946
+ state: "CA",
947
+ zip: "91234",
948
+ something_else: "blah"
949
+ )
950
+ }
951
951
  expect(actual).to match(expected)
952
952
  TEST
953
953
  program = make_plain_test_program(snippet, color_enabled: color_enabled)
@@ -998,23 +998,23 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
998
998
  it "produces the correct failure message when used the negative" do
999
999
  as_both_colored_and_uncolored do |color_enabled|
1000
1000
  snippet = <<~TEST.strip
1001
- expected = {
1001
+ actual = {
1002
1002
  name: "Marty McFly",
1003
- shipping_address: an_object_having_attributes(
1003
+ shipping_address: SuperDiff::Test::ShippingAddress.new(
1004
1004
  line_1: "123 Main St.",
1005
+ line_2: nil,
1005
1006
  city: "Oakland",
1006
1007
  state: "CA",
1007
- zip: "91234"
1008
+ zip: "91234",
1008
1009
  )
1009
1010
  }
1010
- actual = {
1011
+ expected = {
1011
1012
  name: "Marty McFly",
1012
- shipping_address: SuperDiff::Test::ShippingAddress.new(
1013
+ shipping_address: an_object_having_attributes(
1013
1014
  line_1: "123 Main St.",
1014
- line_2: nil,
1015
1015
  city: "Oakland",
1016
1016
  state: "CA",
1017
- zip: "91234",
1017
+ zip: "91234"
1018
1018
  )
1019
1019
  }
1020
1020
  expect(actual).not_to match(expected)
@@ -1052,8 +1052,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1052
1052
  it "produces the correct failure message when used in the positive" do
1053
1053
  as_both_colored_and_uncolored do |color_enabled|
1054
1054
  snippet = <<~TEST.strip
1055
- expected = a_collection_containing_exactly("a")
1056
1055
  actual = ["b"]
1056
+ expected = a_collection_containing_exactly("a")
1057
1057
  expect(actual).to match(expected)
1058
1058
  TEST
1059
1059
  program =
@@ -1092,8 +1092,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1092
1092
  it "produces the correct failure message when used in the negative" do
1093
1093
  as_both_colored_and_uncolored do |color_enabled|
1094
1094
  snippet = <<~TEST.strip
1095
- expected = a_collection_containing_exactly("b")
1096
1095
  actual = ["b"]
1096
+ expected = a_collection_containing_exactly("b")
1097
1097
  expect(actual).not_to match(expected)
1098
1098
  TEST
1099
1099
  program =
@@ -1126,8 +1126,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1126
1126
  it "produces the correct failure message when used in the positive" do
1127
1127
  as_both_colored_and_uncolored do |color_enabled|
1128
1128
  snippet = <<~TEST.strip
1129
- expected = a_collection_containing_exactly("milk", "bread")
1130
1129
  actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
1130
+ expected = a_collection_containing_exactly("milk", "bread")
1131
1131
  expect(actual).to match(expected)
1132
1132
  TEST
1133
1133
  program =
@@ -1172,8 +1172,8 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1172
1172
  it "produces the correct failure message when used in the negative" do
1173
1173
  as_both_colored_and_uncolored do |color_enabled|
1174
1174
  snippet = <<~TEST.strip
1175
- expected = a_collection_containing_exactly("milk", "eggs", "toast")
1176
1175
  actual = ["milk", "toast", "eggs"]
1176
+ expected = a_collection_containing_exactly("milk", "eggs", "toast")
1177
1177
  expect(actual).not_to match(expected)
1178
1178
  TEST
1179
1179
  program =
@@ -1211,14 +1211,14 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1211
1211
  it "produces the correct failure message when used in the positive" do
1212
1212
  as_both_colored_and_uncolored do |color_enabled|
1213
1213
  snippet = <<~TEST.strip
1214
- expected = {
1215
- name: "shopping list",
1216
- contents: a_collection_containing_exactly("milk", "bread")
1217
- }
1218
1214
  actual = {
1219
1215
  name: "shopping list",
1220
1216
  contents: ["milk", "toast", "eggs"]
1221
1217
  }
1218
+ expected = {
1219
+ name: "shopping list",
1220
+ contents: a_collection_containing_exactly("milk", "bread")
1221
+ }
1222
1222
  expect(actual).to match(expected)
1223
1223
  TEST
1224
1224
  program =
@@ -1264,14 +1264,14 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1264
1264
  it "produces the correct failure message when used in the negative" do
1265
1265
  as_both_colored_and_uncolored do |color_enabled|
1266
1266
  snippet = <<~TEST.strip
1267
- expected = {
1268
- name: "shopping list",
1269
- contents: a_collection_containing_exactly("milk", "eggs", "toast")
1270
- }
1271
1267
  actual = {
1272
1268
  name: "shopping list",
1273
1269
  contents: ["milk", "toast", "eggs"]
1274
1270
  }
1271
+ expected = {
1272
+ name: "shopping list",
1273
+ contents: a_collection_containing_exactly("milk", "eggs", "toast")
1274
+ }
1275
1275
  expect(actual).not_to match(expected)
1276
1276
  TEST
1277
1277
  program =
@@ -1307,14 +1307,14 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1307
1307
  it "produces the correct failure message" do
1308
1308
  as_both_colored_and_uncolored do |color_enabled|
1309
1309
  snippet = <<~TEST.strip
1310
- expected = {
1311
- name: "shopping list",
1312
- contents: a_collection_containing_exactly("milk", "bread")
1313
- }
1314
1310
  actual = {
1315
1311
  name: "shopping list",
1316
1312
  contents: nil
1317
1313
  }
1314
+ expected = {
1315
+ name: "shopping list",
1316
+ contents: a_collection_containing_exactly("milk", "bread")
1317
+ }
1318
1318
  expect(actual).to match(expected)
1319
1319
  TEST
1320
1320
  program =