super_diff 0.5.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -7,7 +7,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
7
7
  as_both_colored_and_uncolored do |color_enabled|
8
8
  snippet = <<~TEST.strip
9
9
  expected = a_hash_including(city: "Hill Valley")
10
- actual = { city: "Burbank" }
10
+ actual = { city: "Burbank" }
11
11
  expect(actual).to match(expected)
12
12
  TEST
13
13
  program = make_plain_test_program(
@@ -20,18 +20,18 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
20
20
  snippet: %|expect(actual).to match(expected)|,
21
21
  expectation: proc {
22
22
  line do
23
- plain "Expected "
24
- beta %|{ city: "Burbank" }|
25
- plain " to match "
26
- alpha %|#<a hash including (city: "Hill Valley")>|
27
- plain "."
23
+ plain %|Expected |
24
+ actual %|{ city: "Burbank" }|
25
+ plain %| to match |
26
+ expected %|#<a hash including (city: "Hill Valley")>|
27
+ plain %|.|
28
28
  end
29
29
  },
30
30
  diff: proc {
31
- plain_line %| {|
32
- alpha_line %|- city: "Hill Valley"|
33
- beta_line %|+ city: "Burbank"|
34
- plain_line %| }|
31
+ plain_line %| {|
32
+ expected_line %|- city: "Hill Valley"|
33
+ actual_line %|+ city: "Burbank"|
34
+ plain_line %| }|
35
35
  },
36
36
  )
37
37
 
@@ -45,7 +45,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
45
45
  as_both_colored_and_uncolored do |color_enabled|
46
46
  snippet = <<~TEST.strip
47
47
  expected = a_hash_including(city: "Burbank")
48
- actual = { city: "Burbank" }
48
+ actual = { city: "Burbank" }
49
49
  expect(actual).not_to match(expected)
50
50
  TEST
51
51
  program = make_plain_test_program(
@@ -58,11 +58,11 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
58
58
  snippet: %|expect(actual).not_to match(expected)|,
59
59
  expectation: proc {
60
60
  line do
61
- plain "Expected "
62
- beta %|{ city: "Burbank" }|
63
- plain " not to match "
64
- alpha %|#<a hash including (city: "Burbank")>|
65
- plain "."
61
+ plain %|Expected |
62
+ actual %|{ city: "Burbank" }|
63
+ plain %| not to match |
64
+ expected %|#<a hash including (city: "Burbank")>|
65
+ plain %|.|
66
66
  end
67
67
  },
68
68
  )
@@ -82,7 +82,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
82
82
  city: "Hill Valley",
83
83
  zip: "90382"
84
84
  )
85
- actual = {
85
+ actual = {
86
86
  line_1: "123 Main St.",
87
87
  city: "Burbank",
88
88
  state: "CA",
@@ -100,24 +100,24 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
100
100
  snippet: %|expect(actual).to match(expected)|,
101
101
  expectation: proc {
102
102
  line do
103
- plain "Expected "
104
- beta %|{ line_1: "123 Main St.", city: "Burbank", state: "CA", zip: "90210" }|
103
+ plain %|Expected |
104
+ actual %|{ line_1: "123 Main St.", city: "Burbank", state: "CA", zip: "90210" }|
105
105
  end
106
106
 
107
107
  line do
108
- plain "to match "
109
- alpha %|#<a hash including (city: "Hill Valley", zip: "90382")>|
108
+ plain %|to match |
109
+ expected %|#<a hash including (city: "Hill Valley", zip: "90382")>|
110
110
  end
111
111
  },
112
112
  diff: proc {
113
- plain_line %| {|
114
- plain_line %| line_1: "123 Main St.",|
115
- alpha_line %|- city: "Hill Valley",|
116
- beta_line %|+ city: "Burbank",|
117
- plain_line %| state: "CA",|
118
- alpha_line %|- zip: "90382"|
119
- beta_line %|+ zip: "90210"|
120
- plain_line %| }|
113
+ plain_line %| {|
114
+ plain_line %| line_1: "123 Main St.",|
115
+ expected_line %|- city: "Hill Valley",|
116
+ actual_line %|+ city: "Burbank",|
117
+ plain_line %| state: "CA",|
118
+ expected_line %|- zip: "90382"|
119
+ actual_line %|+ zip: "90210"|
120
+ plain_line %| }|
121
121
  },
122
122
  )
123
123
 
@@ -134,7 +134,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
134
134
  city: "Burbank",
135
135
  zip: "90210"
136
136
  )
137
- actual = {
137
+ actual = {
138
138
  line_1: "123 Main St.",
139
139
  city: "Burbank",
140
140
  state: "CA",
@@ -153,13 +153,13 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
153
153
  newline_before_expectation: true,
154
154
  expectation: proc {
155
155
  line do
156
- plain " Expected "
157
- beta %|{ line_1: "123 Main St.", city: "Burbank", state: "CA", zip: "90210" }|
156
+ plain %| Expected |
157
+ actual %|{ line_1: "123 Main St.", city: "Burbank", state: "CA", zip: "90210" }|
158
158
  end
159
159
 
160
160
  line do
161
- plain "not to match "
162
- alpha %|#<a hash including (city: "Burbank", zip: "90210")>|
161
+ plain %|not to match |
162
+ expected %|#<a hash including (city: "Burbank", zip: "90210")>|
163
163
  end
164
164
  },
165
165
  )
@@ -173,7 +173,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
173
173
  end
174
174
 
175
175
  context "when the expected value includes a hash-including-<something>" do
176
- context "and the corresponding actual value is a hash" do
176
+ context "and the corresponding actual value is a hash" do
177
177
  it "produces the correct failure message when used in the positive" do
178
178
  as_both_colored_and_uncolored do |color_enabled|
179
179
  snippet = <<~TEST.strip
@@ -184,7 +184,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
184
184
  zip: "90382"
185
185
  )
186
186
  }
187
- actual = {
187
+ actual = {
188
188
  name: "Marty McFly",
189
189
  address: {
190
190
  line_1: "123 Main St.",
@@ -205,27 +205,27 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
205
205
  snippet: %|expect(actual).to match(expected)|,
206
206
  expectation: proc {
207
207
  line do
208
- plain "Expected "
209
- beta %|{ name: "Marty McFly", address: { line_1: "123 Main St.", city: "Burbank", state: "CA", zip: "90210" } }|
208
+ plain %|Expected |
209
+ actual %|{ name: "Marty McFly", address: { line_1: "123 Main St.", city: "Burbank", state: "CA", zip: "90210" } }|
210
210
  end
211
211
 
212
212
  line do
213
- plain "to match "
214
- alpha %|{ name: "Marty McFly", address: #<a hash including (city: "Hill Valley", zip: "90382")> }|
213
+ plain %|to match |
214
+ expected %|{ name: "Marty McFly", address: #<a hash including (city: "Hill Valley", zip: "90382")> }|
215
215
  end
216
216
  },
217
217
  diff: proc {
218
- plain_line %| {|
219
- plain_line %| name: "Marty McFly",|
220
- plain_line %| address: {|
221
- plain_line %| line_1: "123 Main St.",|
222
- alpha_line %|- city: "Hill Valley",|
223
- beta_line %|+ city: "Burbank",|
224
- plain_line %| state: "CA",|
225
- alpha_line %|- zip: "90382"|
226
- beta_line %|+ zip: "90210"|
227
- plain_line %| }|
228
- plain_line %| }|
218
+ plain_line %| {|
219
+ plain_line %| name: "Marty McFly",|
220
+ plain_line %| address: {|
221
+ plain_line %| line_1: "123 Main St.",|
222
+ expected_line %|- city: "Hill Valley",|
223
+ actual_line %|+ city: "Burbank",|
224
+ plain_line %| state: "CA",|
225
+ expected_line %|- zip: "90382"|
226
+ actual_line %|+ zip: "90210"|
227
+ plain_line %| }|
228
+ plain_line %| }|
229
229
  },
230
230
  )
231
231
 
@@ -245,7 +245,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
245
245
  zip: "90210"
246
246
  )
247
247
  }
248
- actual = {
248
+ actual = {
249
249
  name: "Marty McFly",
250
250
  address: {
251
251
  line_1: "123 Main St.",
@@ -267,13 +267,13 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
267
267
  newline_before_expectation: true,
268
268
  expectation: proc {
269
269
  line do
270
- plain " Expected "
271
- beta %|{ name: "Marty McFly", address: { line_1: "123 Main St.", city: "Burbank", state: "CA", zip: "90210" } }|
270
+ plain %| Expected |
271
+ actual %|{ name: "Marty McFly", address: { line_1: "123 Main St.", city: "Burbank", state: "CA", zip: "90210" } }|
272
272
  end
273
273
 
274
274
  line do
275
- plain "not to match "
276
- alpha %|{ name: "Marty McFly", address: #<a hash including (city: "Burbank", zip: "90210")> }|
275
+ plain %|not to match |
276
+ expected %|{ name: "Marty McFly", address: #<a hash including (city: "Burbank", zip: "90210")> }|
277
277
  end
278
278
  },
279
279
  )
@@ -285,7 +285,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
285
285
  end
286
286
  end
287
287
 
288
- context "and the corresponding actual value is not a hash" do
288
+ context "and the corresponding actual value is not a hash" do
289
289
  it "produces the correct failure message" do
290
290
  as_both_colored_and_uncolored do |color_enabled|
291
291
  snippet = <<~TEST.strip
@@ -296,7 +296,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
296
296
  zip: "90382"
297
297
  )
298
298
  }
299
- actual = {
299
+ actual = {
300
300
  name: "Marty McFly",
301
301
  address: nil
302
302
  }
@@ -312,24 +312,24 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
312
312
  snippet: %|expect(actual).to match(expected)|,
313
313
  expectation: proc {
314
314
  line do
315
- plain "Expected "
316
- beta %|{ name: "Marty McFly", address: nil }|
315
+ plain %|Expected |
316
+ actual %|{ name: "Marty McFly", address: nil }|
317
317
  end
318
318
 
319
319
  line do
320
- plain "to match "
321
- alpha %|{ name: "Marty McFly", address: #<a hash including (city: "Hill Valley", zip: "90382")> }|
320
+ plain %|to match |
321
+ expected %|{ name: "Marty McFly", address: #<a hash including (city: "Hill Valley", zip: "90382")> }|
322
322
  end
323
323
  },
324
324
  diff: proc {
325
- plain_line %! {!
326
- plain_line %! name: "Marty McFly",!
327
- alpha_line %!- address: #<a hash including (!
328
- alpha_line %!- city: "Hill Valley",!
329
- alpha_line %!- zip: "90382"!
330
- alpha_line %!- )>!
331
- beta_line %!+ address: nil!
332
- plain_line %! }!
325
+ plain_line %! {!
326
+ plain_line %! name: "Marty McFly",!
327
+ expected_line %!- address: #<a hash including (!
328
+ expected_line %!- city: "Hill Valley",!
329
+ expected_line %!- zip: "90382"!
330
+ expected_line %!- )>!
331
+ actual_line %!+ address: nil!
332
+ plain_line %! }!
333
333
  },
334
334
  )
335
335
 
@@ -341,13 +341,55 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
341
341
  end
342
342
  end
343
343
 
344
+ # HINT: `a_hash_including` is an alias of `include` in the rspec-expectations gem.
345
+ # `hash_including` is an argument matcher in the rspec-mocks gem.
346
+ context "when the expected value is `hash-including-<something>`, not `a-hash-including-<something>`" do
347
+ it "produces the correct failure message" do
348
+ as_both_colored_and_uncolored do |color_enabled|
349
+ snippet = <<~TEST.strip
350
+ expected = hash_including(city: "Hill Valley")
351
+ actual = { city: "Burbank" }
352
+ expect(actual).to match(expected)
353
+ TEST
354
+ program = make_plain_test_program(
355
+ snippet,
356
+ color_enabled: color_enabled,
357
+ )
358
+
359
+ expected_output = build_expected_output(
360
+ color_enabled: color_enabled,
361
+ snippet: %|expect(actual).to match(expected)|,
362
+ expectation: proc {
363
+ line do
364
+ plain %|Expected |
365
+ actual %|{ city: "Burbank" }|
366
+ plain %| to match |
367
+ expected %|#<a hash including (city: "Hill Valley")>|
368
+ plain %|.|
369
+ end
370
+ },
371
+ diff: proc {
372
+ plain_line %| {|
373
+ expected_line %|- city: "Hill Valley"|
374
+ actual_line %|+ city: "Burbank"|
375
+ plain_line %| }|
376
+ },
377
+ )
378
+
379
+ expect(program).
380
+ to produce_output_when_run(expected_output).
381
+ in_color(color_enabled)
382
+ end
383
+ end
384
+ end
385
+
344
386
  context "when the expected value is a collection-including-<something>" do
345
387
  context "that is small" do
346
388
  it "produces the correct failure message when used in the positive" do
347
389
  as_both_colored_and_uncolored do |color_enabled|
348
390
  snippet = <<~TEST.strip
349
391
  expected = a_collection_including("a")
350
- actual = ["b"]
392
+ actual = ["b"]
351
393
  expect(actual).to match(expected)
352
394
  TEST
353
395
  program = make_plain_test_program(
@@ -360,19 +402,19 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
360
402
  snippet: %|expect(actual).to match(expected)|,
361
403
  expectation: proc {
362
404
  line do
363
- plain "Expected "
364
- beta %|["b"]|
365
- plain " to match "
366
- alpha %|#<a collection including ("a")>|
367
- plain "."
405
+ plain %|Expected |
406
+ actual %|["b"]|
407
+ plain %| to match |
408
+ expected %|#<a collection including ("a")>|
409
+ plain %|.|
368
410
  end
369
411
  },
370
412
  diff: proc {
371
- plain_line %| [|
372
- plain_line %| "b"|
373
- # alpha_line %|- "a",| # FIXME
374
- alpha_line %|- "a"|
375
- plain_line %| ]|
413
+ plain_line %| [|
414
+ plain_line %| "b"|
415
+ # expected_line %|- "a",| # FIXME
416
+ expected_line %|- "a"|
417
+ plain_line %| ]|
376
418
  },
377
419
  )
378
420
 
@@ -386,7 +428,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
386
428
  as_both_colored_and_uncolored do |color_enabled|
387
429
  snippet = <<~TEST.strip
388
430
  expected = a_collection_including("b")
389
- actual = ["b"]
431
+ actual = ["b"]
390
432
  expect(actual).not_to match(expected)
391
433
  TEST
392
434
  program = make_plain_test_program(
@@ -399,11 +441,11 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
399
441
  snippet: %|expect(actual).not_to match(expected)|,
400
442
  expectation: proc {
401
443
  line do
402
- plain "Expected "
403
- beta %|["b"]|
404
- plain " not to match "
405
- alpha %|#<a collection including ("b")>|
406
- plain "."
444
+ plain %|Expected |
445
+ actual %|["b"]|
446
+ plain %| not to match |
447
+ expected %|#<a collection including ("b")>|
448
+ plain %|.|
407
449
  end
408
450
  },
409
451
  )
@@ -420,7 +462,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
420
462
  as_both_colored_and_uncolored do |color_enabled|
421
463
  snippet = <<~TEST.strip
422
464
  expected = a_collection_including("milk", "bread")
423
- actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
465
+ actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
424
466
  expect(actual).to match(expected)
425
467
  TEST
426
468
  program = make_plain_test_program(
@@ -433,25 +475,25 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
433
475
  snippet: %|expect(actual).to match(expected)|,
434
476
  expectation: proc {
435
477
  line do
436
- plain "Expected "
437
- beta %|["milk", "toast", "eggs", "cheese", "English muffins"]|
478
+ plain %|Expected |
479
+ actual %|["milk", "toast", "eggs", "cheese", "English muffins"]|
438
480
  end
439
481
 
440
482
  line do
441
- plain "to match "
442
- alpha %|#<a collection including ("milk", "bread")>|
483
+ plain %|to match |
484
+ expected %|#<a collection including ("milk", "bread")>|
443
485
  end
444
486
  },
445
487
  diff: proc {
446
- plain_line %| [|
447
- plain_line %| "milk",|
448
- plain_line %| "toast",|
449
- plain_line %| "eggs",|
450
- plain_line %| "cheese",|
451
- # plain_line %| "English muffins",| # FIXME
452
- plain_line %| "English muffins"|
453
- alpha_line %|- "bread"|
454
- plain_line %| ]|
488
+ plain_line %| [|
489
+ plain_line %| "milk",|
490
+ plain_line %| "toast",|
491
+ plain_line %| "eggs",|
492
+ plain_line %| "cheese",|
493
+ # plain_line %| "English muffins",| # FIXME
494
+ plain_line %| "English muffins"|
495
+ expected_line %|- "bread"|
496
+ plain_line %| ]|
455
497
  },
456
498
  )
457
499
 
@@ -465,7 +507,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
465
507
  as_both_colored_and_uncolored do |color_enabled|
466
508
  snippet = <<~TEST.strip
467
509
  expected = a_collection_including("milk", "toast")
468
- actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
510
+ actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
469
511
  expect(actual).not_to match(expected)
470
512
  TEST
471
513
  program = make_plain_test_program(
@@ -479,13 +521,13 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
479
521
  newline_before_expectation: true,
480
522
  expectation: proc {
481
523
  line do
482
- plain " Expected "
483
- beta %|["milk", "toast", "eggs", "cheese", "English muffins"]|
524
+ plain %| Expected |
525
+ actual %|["milk", "toast", "eggs", "cheese", "English muffins"]|
484
526
  end
485
527
 
486
528
  line do
487
- plain "not to match "
488
- alpha %|#<a collection including ("milk", "toast")>|
529
+ plain %|not to match |
530
+ expected %|#<a collection including ("milk", "toast")>|
489
531
  end
490
532
  },
491
533
  )
@@ -499,7 +541,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
499
541
  end
500
542
 
501
543
  context "when the expected value includes a collection-including-<something>" do
502
- context "and the corresponding actual value is an array" do
544
+ context "and the corresponding actual value is an array" do
503
545
  it "produces the correct failure message when used in the positive" do
504
546
  as_both_colored_and_uncolored do |color_enabled|
505
547
  snippet = <<~TEST.strip
@@ -507,7 +549,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
507
549
  name: "shopping list",
508
550
  contents: a_collection_including("milk", "bread")
509
551
  }
510
- actual = {
552
+ actual = {
511
553
  name: "shopping list",
512
554
  contents: ["milk", "toast", "eggs"]
513
555
  }
@@ -523,26 +565,26 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
523
565
  snippet: %|expect(actual).to match(expected)|,
524
566
  expectation: proc {
525
567
  line do
526
- plain "Expected "
527
- beta %|{ name: "shopping list", contents: ["milk", "toast", "eggs"] }|
568
+ plain %|Expected |
569
+ actual %|{ name: "shopping list", contents: ["milk", "toast", "eggs"] }|
528
570
  end
529
571
 
530
572
  line do
531
- plain "to match "
532
- alpha %|{ name: "shopping list", contents: #<a collection including ("milk", "bread")> }|
573
+ plain %|to match |
574
+ expected %|{ name: "shopping list", contents: #<a collection including ("milk", "bread")> }|
533
575
  end
534
576
  },
535
577
  diff: proc {
536
- plain_line %| {|
537
- plain_line %| name: "shopping list",|
538
- plain_line %| contents: [|
539
- plain_line %| "milk",|
540
- plain_line %| "toast",|
541
- # plain_line %| "eggs",| # FIXME
542
- plain_line %| "eggs"|
543
- alpha_line %|- "bread"|
544
- plain_line %| ]|
545
- plain_line %| }|
578
+ plain_line %| {|
579
+ plain_line %| name: "shopping list",|
580
+ plain_line %| contents: [|
581
+ plain_line %| "milk",|
582
+ plain_line %| "toast",|
583
+ # plain_line %| "eggs",| # FIXME
584
+ plain_line %| "eggs"|
585
+ expected_line %|- "bread"|
586
+ plain_line %| ]|
587
+ plain_line %| }|
546
588
  },
547
589
  )
548
590
 
@@ -559,7 +601,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
559
601
  name: "shopping list",
560
602
  contents: a_collection_including("milk", "toast")
561
603
  }
562
- actual = {
604
+ actual = {
563
605
  name: "shopping list",
564
606
  contents: ["milk", "toast", "eggs"]
565
607
  }
@@ -576,13 +618,13 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
576
618
  newline_before_expectation: true,
577
619
  expectation: proc {
578
620
  line do
579
- plain " Expected "
580
- beta %|{ name: "shopping list", contents: ["milk", "toast", "eggs"] }|
621
+ plain %| Expected |
622
+ actual %|{ name: "shopping list", contents: ["milk", "toast", "eggs"] }|
581
623
  end
582
624
 
583
625
  line do
584
- plain "not to match "
585
- alpha %|{ name: "shopping list", contents: #<a collection including ("milk", "toast")> }|
626
+ plain %|not to match |
627
+ expected %|{ name: "shopping list", contents: #<a collection including ("milk", "toast")> }|
586
628
  end
587
629
  },
588
630
  )
@@ -594,7 +636,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
594
636
  end
595
637
  end
596
638
 
597
- context "when the corresponding actual value is not an array" do
639
+ context "when the corresponding actual value is not an array" do
598
640
  it "produces the correct failure message" do
599
641
  as_both_colored_and_uncolored do |color_enabled|
600
642
  snippet = <<~TEST.strip
@@ -602,7 +644,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
602
644
  name: "shopping list",
603
645
  contents: a_collection_including("milk", "bread")
604
646
  }
605
- actual = {
647
+ actual = {
606
648
  name: "shopping list",
607
649
  contents: nil
608
650
  }
@@ -618,24 +660,24 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
618
660
  snippet: %|expect(actual).to match(expected)|,
619
661
  expectation: proc {
620
662
  line do
621
- plain "Expected "
622
- beta %|{ name: "shopping list", contents: nil }|
663
+ plain %|Expected |
664
+ actual %|{ name: "shopping list", contents: nil }|
623
665
  end
624
666
 
625
667
  line do
626
- plain "to match "
627
- alpha %|{ name: "shopping list", contents: #<a collection including ("milk", "bread")> }|
668
+ plain %|to match |
669
+ expected %|{ name: "shopping list", contents: #<a collection including ("milk", "bread")> }|
628
670
  end
629
671
  },
630
672
  diff: proc {
631
- plain_line %! {!
632
- plain_line %! name: "shopping list",!
633
- alpha_line %!- contents: #<a collection including (!
634
- alpha_line %!- "milk",!
635
- alpha_line %!- "bread"!
636
- alpha_line %!- )>!
637
- beta_line %!+ contents: nil!
638
- plain_line %! }!
673
+ plain_line %! {!
674
+ plain_line %! name: "shopping list",!
675
+ expected_line %!- contents: #<a collection including (!
676
+ expected_line %!- "milk",!
677
+ expected_line %!- "bread"!
678
+ expected_line %!- )>!
679
+ actual_line %!+ contents: nil!
680
+ plain_line %! }!
639
681
  },
640
682
  )
641
683
 
@@ -647,13 +689,54 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
647
689
  end
648
690
  end
649
691
 
692
+ context "when the expected value is an array-including-<something>" do
693
+ it "produces the correct failure message" do
694
+ as_both_colored_and_uncolored do |color_enabled|
695
+ snippet = <<~TEST.strip
696
+ expected = array_including("a")
697
+ actual = ["b"]
698
+ expect(actual).to match(expected)
699
+ TEST
700
+ program = make_plain_test_program(
701
+ snippet,
702
+ color_enabled: color_enabled,
703
+ )
704
+
705
+ expected_output = build_expected_output(
706
+ color_enabled: color_enabled,
707
+ snippet: %|expect(actual).to match(expected)|,
708
+ expectation: proc {
709
+ line do
710
+ plain %|Expected |
711
+ actual %|["b"]|
712
+ plain %| to match |
713
+ expected %|#<a collection including ("a")>|
714
+ plain %|.|
715
+ end
716
+ },
717
+ diff: proc {
718
+ plain_line %| [|
719
+ plain_line %| "b"|
720
+ # expected_line %|- "a",| # FIXME
721
+ expected_line %|- "a"|
722
+ plain_line %| ]|
723
+ },
724
+ )
725
+
726
+ expect(program).
727
+ to produce_output_when_run(expected_output).
728
+ in_color(color_enabled)
729
+ end
730
+ end
731
+ end
732
+
650
733
  context "when the expected value is an object-having-attributes" do
651
734
  context "that is small" do
652
735
  it "produces the correct failure message when used in the positive" do
653
736
  as_both_colored_and_uncolored do |color_enabled|
654
737
  snippet = <<~TEST.strip
655
738
  expected = an_object_having_attributes(name: "b")
656
- actual = A.new("a")
739
+ actual = A.new("a")
657
740
  expect(actual).to match(expected)
658
741
  TEST
659
742
  program = make_plain_test_program(
@@ -666,19 +749,19 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
666
749
  snippet: %|expect(actual).to match(expected)|,
667
750
  expectation: proc {
668
751
  line do
669
- plain "Expected "
670
- beta %|#<A name: "a">|
671
- plain " to match "
672
- alpha %|#<an object having attributes (name: "b")>|
673
- plain "."
752
+ plain %|Expected |
753
+ actual %|#<A name: "a">|
754
+ plain %| to match |
755
+ expected %|#<an object having attributes (name: "b")>|
756
+ plain %|.|
674
757
  end
675
758
  },
676
759
  diff: proc {
677
- plain_line %| #<A {|
678
- # alpha_line %|- name: "b",| # FIXME
679
- alpha_line %|- name: "b"|
680
- beta_line %|+ name: "a"|
681
- plain_line %| }>|
760
+ plain_line %| #<A {|
761
+ # expected_line %|- name: "b",| # FIXME
762
+ expected_line %|- name: "b"|
763
+ actual_line %|+ name: "a"|
764
+ plain_line %| }>|
682
765
  },
683
766
  )
684
767
 
@@ -692,7 +775,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
692
775
  as_both_colored_and_uncolored do |color_enabled|
693
776
  snippet = <<~TEST.strip
694
777
  expected = an_object_having_attributes(name: "b")
695
- actual = A.new("b")
778
+ actual = A.new("b")
696
779
  expect(actual).not_to match(expected)
697
780
  TEST
698
781
  program = make_plain_test_program(
@@ -705,11 +788,11 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
705
788
  snippet: %|expect(actual).not_to match(expected)|,
706
789
  expectation: proc {
707
790
  line do
708
- plain "Expected "
709
- beta %|#<A name: "b">|
710
- plain " not to match "
711
- alpha %|#<an object having attributes (name: "b")>|
712
- plain "."
791
+ plain %|Expected |
792
+ actual %|#<A name: "b">|
793
+ plain %| not to match |
794
+ expected %|#<an object having attributes (name: "b")>|
795
+ plain %|.|
713
796
  end
714
797
  },
715
798
  )
@@ -732,7 +815,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
732
815
  state: "CA",
733
816
  something_else: "blah"
734
817
  )
735
- actual = SuperDiff::Test::ShippingAddress.new(
818
+ actual = SuperDiff::Test::ShippingAddress.new(
736
819
  line_1: "456 Ponderosa Ct.",
737
820
  line_2: nil,
738
821
  city: "Hill Valley",
@@ -751,29 +834,30 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
751
834
  snippet: %|expect(actual).to match(expected)|,
752
835
  expectation: proc {
753
836
  line do
754
- plain "Expected "
755
- beta %|#<SuperDiff::Test::ShippingAddress line_1: "456 Ponderosa Ct.", line_2: nil, city: "Hill Valley", state: "CA", zip: "90382">|
837
+ plain %|Expected |
838
+ actual %|#<SuperDiff::Test::ShippingAddress line_1: "456 Ponderosa Ct.", line_2: nil, city: "Hill Valley", state: "CA", zip: "90382">|
756
839
  end
757
840
 
758
841
  line do
759
- plain "to match "
760
- alpha %|#<an object having attributes (line_1: "123 Main St.", city: "Oakland", zip: "91234", state: "CA", something_else: "blah")>|
842
+ plain %|to match |
843
+ expected %|#<an object having attributes (line_1: "123 Main St.", city: "Oakland", zip: "91234", state: "CA", something_else: "blah")>|
761
844
  end
762
845
  },
763
846
  diff: proc {
764
- plain_line %| #<SuperDiff::Test::ShippingAddress {|
765
- alpha_line %|- line_1: "123 Main St.",|
766
- beta_line %|+ line_1: "456 Ponderosa Ct.",|
767
- plain_line %| line_2: nil,|
768
- alpha_line %|- city: "Oakland",|
769
- beta_line %|+ city: "Hill Valley",|
770
- plain_line %| state: "CA",|
771
- # alpha_line %|- zip: "91234",| # FIXME
772
- # beta_line %|+ zip: "90382",| # FIXME
773
- alpha_line %|- zip: "91234"|
774
- beta_line %|+ zip: "90382"|
775
- alpha_line %|- something_else: "blah"|
776
- plain_line %| }>|
847
+ plain_line %| #<SuperDiff::Test::ShippingAddress {|
848
+ expected_line %|- line_1: "123 Main St.",|
849
+ actual_line %|+ line_1: "456 Ponderosa Ct.",|
850
+ plain_line %| line_2: nil,|
851
+ expected_line %|- city: "Oakland",|
852
+ actual_line %|+ city: "Hill Valley",|
853
+ plain_line %| state: "CA",|
854
+ # expected_line %|- zip: "91234",| # FIXME
855
+ # actual_line %|+ zip: "90382",| # FIXME
856
+ expected_line %|- zip: "91234"|
857
+ actual_line %|+ zip: "90382"|
858
+ # expected_line %|- something_else: "blah"| # TODO
859
+ expected_line %|- something_else: "blah",|
860
+ plain_line %| }>|
777
861
  },
778
862
  )
779
863
 
@@ -791,7 +875,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
791
875
  city: "Oakland",
792
876
  zip: "91234"
793
877
  )
794
- actual = SuperDiff::Test::ShippingAddress.new(
878
+ actual = SuperDiff::Test::ShippingAddress.new(
795
879
  line_1: "123 Main St.",
796
880
  line_2: nil,
797
881
  city: "Oakland",
@@ -811,13 +895,13 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
811
895
  newline_before_expectation: true,
812
896
  expectation: proc {
813
897
  line do
814
- plain " Expected "
815
- beta %|#<SuperDiff::Test::ShippingAddress line_1: "123 Main St.", line_2: nil, city: "Oakland", state: "CA", zip: "91234">|
898
+ plain %| Expected |
899
+ actual %|#<SuperDiff::Test::ShippingAddress line_1: "123 Main St.", line_2: nil, city: "Oakland", state: "CA", zip: "91234">|
816
900
  end
817
901
 
818
902
  line do
819
- plain "not to match "
820
- alpha %|#<an object having attributes (line_1: "123 Main St.", city: "Oakland", zip: "91234")>|
903
+ plain %|not to match |
904
+ expected %|#<an object having attributes (line_1: "123 Main St.", city: "Oakland", zip: "91234")>|
821
905
  end
822
906
  },
823
907
  )
@@ -844,7 +928,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
844
928
  something_else: "blah"
845
929
  )
846
930
  }
847
- actual = {
931
+ actual = {
848
932
  name: "Marty McFly",
849
933
  shipping_address: SuperDiff::Test::ShippingAddress.new(
850
934
  line_1: "456 Ponderosa Ct.",
@@ -866,31 +950,32 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
866
950
  snippet: %|expect(actual).to match(expected)|,
867
951
  expectation: proc {
868
952
  line do
869
- plain "Expected "
870
- beta %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::ShippingAddress line_1: "456 Ponderosa Ct.", line_2: nil, city: "Hill Valley", state: "CA", zip: "90382"> }|
953
+ plain %|Expected |
954
+ actual %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::ShippingAddress line_1: "456 Ponderosa Ct.", line_2: nil, city: "Hill Valley", state: "CA", zip: "90382"> }|
871
955
  end
872
956
 
873
957
  line do
874
- plain "to match "
875
- alpha %|{ name: "Marty McFly", shipping_address: #<an object having attributes (line_1: "123 Main St.", city: "Oakland", state: "CA", zip: "91234", something_else: "blah")> }|
958
+ plain %|to match |
959
+ expected %|{ name: "Marty McFly", shipping_address: #<an object having attributes (line_1: "123 Main St.", city: "Oakland", state: "CA", zip: "91234", something_else: "blah")> }|
876
960
  end
877
961
  },
878
962
  diff: proc {
879
- plain_line %| {|
880
- plain_line %| name: "Marty McFly",|
881
- plain_line %| shipping_address: #<SuperDiff::Test::ShippingAddress {|
882
- alpha_line %|- line_1: "123 Main St.",|
883
- beta_line %|+ line_1: "456 Ponderosa Ct.",|
884
- plain_line %| line_2: nil,|
885
- alpha_line %|- city: "Oakland",|
886
- beta_line %|+ city: "Hill Valley",|
887
- plain_line %| state: "CA",|
888
- # alpha_line %|- zip: "91234",| # FIXME
889
- alpha_line %|- zip: "91234"|
890
- beta_line %|+ zip: "90382"|
891
- alpha_line %|- something_else: "blah"|
892
- plain_line %| }>|
893
- plain_line %| }|
963
+ plain_line %| {|
964
+ plain_line %| name: "Marty McFly",|
965
+ plain_line %| shipping_address: #<SuperDiff::Test::ShippingAddress {|
966
+ expected_line %|- line_1: "123 Main St.",|
967
+ actual_line %|+ line_1: "456 Ponderosa Ct.",|
968
+ plain_line %| line_2: nil,|
969
+ expected_line %|- city: "Oakland",|
970
+ actual_line %|+ city: "Hill Valley",|
971
+ plain_line %| state: "CA",|
972
+ # expected_line %|- zip: "91234",| # FIXME
973
+ expected_line %|- zip: "91234"|
974
+ actual_line %|+ zip: "90382"|
975
+ # expected_line %|- something_else: "blah"| # TODO
976
+ expected_line %|- something_else: "blah",|
977
+ plain_line %| }>|
978
+ plain_line %| }|
894
979
  },
895
980
  )
896
981
 
@@ -912,7 +997,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
912
997
  zip: "91234"
913
998
  )
914
999
  }
915
- actual = {
1000
+ actual = {
916
1001
  name: "Marty McFly",
917
1002
  shipping_address: SuperDiff::Test::ShippingAddress.new(
918
1003
  line_1: "123 Main St.",
@@ -935,13 +1020,13 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
935
1020
  newline_before_expectation: true,
936
1021
  expectation: proc {
937
1022
  line do
938
- plain " Expected "
939
- beta %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::ShippingAddress line_1: "123 Main St.", line_2: nil, city: "Oakland", state: "CA", zip: "91234"> }|
1023
+ plain %| Expected |
1024
+ actual %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::ShippingAddress line_1: "123 Main St.", line_2: nil, city: "Oakland", state: "CA", zip: "91234"> }|
940
1025
  end
941
1026
 
942
1027
  line do
943
- plain "not to match "
944
- alpha %|{ name: "Marty McFly", shipping_address: #<an object having attributes (line_1: "123 Main St.", city: "Oakland", state: "CA", zip: "91234")> }|
1028
+ plain %|not to match |
1029
+ expected %|{ name: "Marty McFly", shipping_address: #<an object having attributes (line_1: "123 Main St.", city: "Oakland", state: "CA", zip: "91234")> }|
945
1030
  end
946
1031
  },
947
1032
  )
@@ -959,7 +1044,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
959
1044
  as_both_colored_and_uncolored do |color_enabled|
960
1045
  snippet = <<~TEST.strip
961
1046
  expected = a_collection_containing_exactly("a")
962
- actual = ["b"]
1047
+ actual = ["b"]
963
1048
  expect(actual).to match(expected)
964
1049
  TEST
965
1050
  program = make_plain_test_program(
@@ -972,18 +1057,19 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
972
1057
  snippet: %|expect(actual).to match(expected)|,
973
1058
  expectation: proc {
974
1059
  line do
975
- plain "Expected "
976
- beta %|["b"]|
977
- plain " to match "
978
- alpha %|#<a collection containing exactly ("a")>|
979
- plain "."
1060
+ plain %|Expected |
1061
+ actual %|["b"]|
1062
+ plain %| to match |
1063
+ expected %|#<a collection containing exactly ("a")>|
1064
+ plain %|.|
980
1065
  end
981
1066
  },
982
1067
  diff: proc {
983
- plain_line %| [|
984
- plain_line %| "b",|
985
- alpha_line %|- "a"|
986
- plain_line %| ]|
1068
+ plain_line %| [|
1069
+ actual_line %|+ "b",|
1070
+ # expected_line %|- "a"| # TODO
1071
+ expected_line %|- "a",|
1072
+ plain_line %| ]|
987
1073
  },
988
1074
  )
989
1075
 
@@ -997,7 +1083,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
997
1083
  as_both_colored_and_uncolored do |color_enabled|
998
1084
  snippet = <<~TEST.strip
999
1085
  expected = a_collection_containing_exactly("b")
1000
- actual = ["b"]
1086
+ actual = ["b"]
1001
1087
  expect(actual).not_to match(expected)
1002
1088
  TEST
1003
1089
  program = make_plain_test_program(
@@ -1010,11 +1096,11 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1010
1096
  snippet: %|expect(actual).not_to match(expected)|,
1011
1097
  expectation: proc {
1012
1098
  line do
1013
- plain "Expected "
1014
- beta %|["b"]|
1015
- plain " not to match "
1016
- alpha %|#<a collection containing exactly ("b")>|
1017
- plain "."
1099
+ plain %|Expected |
1100
+ actual %|["b"]|
1101
+ plain %| not to match |
1102
+ expected %|#<a collection containing exactly ("b")>|
1103
+ plain %|.|
1018
1104
  end
1019
1105
  },
1020
1106
  )
@@ -1031,7 +1117,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1031
1117
  as_both_colored_and_uncolored do |color_enabled|
1032
1118
  snippet = <<~TEST.strip
1033
1119
  expected = a_collection_containing_exactly("milk", "bread")
1034
- actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
1120
+ actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
1035
1121
  expect(actual).to match(expected)
1036
1122
  TEST
1037
1123
  program = make_plain_test_program(
@@ -1044,24 +1130,25 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1044
1130
  snippet: %|expect(actual).to match(expected)|,
1045
1131
  expectation: proc {
1046
1132
  line do
1047
- plain "Expected "
1048
- beta %|["milk", "toast", "eggs", "cheese", "English muffins"]|
1133
+ plain %|Expected |
1134
+ actual %|["milk", "toast", "eggs", "cheese", "English muffins"]|
1049
1135
  end
1050
1136
 
1051
1137
  line do
1052
- plain "to match "
1053
- alpha %|#<a collection containing exactly ("milk", "bread")>|
1138
+ plain %|to match |
1139
+ expected %|#<a collection containing exactly ("milk", "bread")>|
1054
1140
  end
1055
1141
  },
1056
1142
  diff: proc {
1057
- plain_line %| [|
1058
- plain_line %| "milk",|
1059
- plain_line %| "toast",|
1060
- plain_line %| "eggs",|
1061
- plain_line %| "cheese",|
1062
- plain_line %| "English muffins",|
1063
- alpha_line %|- "bread"|
1064
- plain_line %| ]|
1143
+ plain_line %| [|
1144
+ plain_line %| "milk",|
1145
+ actual_line %|+ "toast",|
1146
+ actual_line %|+ "eggs",|
1147
+ actual_line %|+ "cheese",|
1148
+ actual_line %|+ "English muffins",|
1149
+ # expected_line %|- "bread"| # TODO
1150
+ expected_line %|- "bread",|
1151
+ plain_line %| ]|
1065
1152
  },
1066
1153
  )
1067
1154
 
@@ -1075,7 +1162,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1075
1162
  as_both_colored_and_uncolored do |color_enabled|
1076
1163
  snippet = <<~TEST.strip
1077
1164
  expected = a_collection_containing_exactly("milk", "eggs", "toast")
1078
- actual = ["milk", "toast", "eggs"]
1165
+ actual = ["milk", "toast", "eggs"]
1079
1166
  expect(actual).not_to match(expected)
1080
1167
  TEST
1081
1168
  program = make_plain_test_program(
@@ -1089,13 +1176,13 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1089
1176
  newline_before_expectation: true,
1090
1177
  expectation: proc {
1091
1178
  line do
1092
- plain " Expected "
1093
- beta %|["milk", "toast", "eggs"]|
1179
+ plain %| Expected |
1180
+ actual %|["milk", "toast", "eggs"]|
1094
1181
  end
1095
1182
 
1096
1183
  line do
1097
- plain "not to match "
1098
- alpha %|#<a collection containing exactly ("milk", "eggs", "toast")>|
1184
+ plain %|not to match |
1185
+ expected %|#<a collection containing exactly ("milk", "eggs", "toast")>|
1099
1186
  end
1100
1187
  },
1101
1188
  )
@@ -1109,7 +1196,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1109
1196
  end
1110
1197
 
1111
1198
  context "when the expected value includes a collection-containing-exactly-<something>" do
1112
- context "and the corresponding actual value is an array" do
1199
+ context "and the corresponding actual value is an array" do
1113
1200
  it "produces the correct failure message when used in the positive" do
1114
1201
  as_both_colored_and_uncolored do |color_enabled|
1115
1202
  snippet = <<~TEST.strip
@@ -1117,7 +1204,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1117
1204
  name: "shopping list",
1118
1205
  contents: a_collection_containing_exactly("milk", "bread")
1119
1206
  }
1120
- actual = {
1207
+ actual = {
1121
1208
  name: "shopping list",
1122
1209
  contents: ["milk", "toast", "eggs"]
1123
1210
  }
@@ -1133,25 +1220,26 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1133
1220
  snippet: %|expect(actual).to match(expected)|,
1134
1221
  expectation: proc {
1135
1222
  line do
1136
- plain "Expected "
1137
- beta %|{ name: "shopping list", contents: ["milk", "toast", "eggs"] }|
1223
+ plain %|Expected |
1224
+ actual %|{ name: "shopping list", contents: ["milk", "toast", "eggs"] }|
1138
1225
  end
1139
1226
 
1140
1227
  line do
1141
- plain "to match "
1142
- alpha %|{ name: "shopping list", contents: #<a collection containing exactly ("milk", "bread")> }|
1228
+ plain %|to match |
1229
+ expected %|{ name: "shopping list", contents: #<a collection containing exactly ("milk", "bread")> }|
1143
1230
  end
1144
1231
  },
1145
1232
  diff: proc {
1146
- plain_line %| {|
1147
- plain_line %| name: "shopping list",|
1148
- plain_line %| contents: [|
1149
- plain_line %| "milk",|
1150
- plain_line %| "toast",|
1151
- plain_line %| "eggs",|
1152
- alpha_line %|- "bread"|
1153
- plain_line %| ]|
1154
- plain_line %| }|
1233
+ plain_line %| {|
1234
+ plain_line %| name: "shopping list",|
1235
+ plain_line %| contents: [|
1236
+ plain_line %| "milk",|
1237
+ actual_line %|+ "toast",|
1238
+ actual_line %|+ "eggs",|
1239
+ # expected_line %|- "bread"| # TODO
1240
+ expected_line %|- "bread",|
1241
+ plain_line %| ]|
1242
+ plain_line %| }|
1155
1243
  },
1156
1244
  )
1157
1245
 
@@ -1168,7 +1256,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1168
1256
  name: "shopping list",
1169
1257
  contents: a_collection_containing_exactly("milk", "eggs", "toast")
1170
1258
  }
1171
- actual = {
1259
+ actual = {
1172
1260
  name: "shopping list",
1173
1261
  contents: ["milk", "toast", "eggs"]
1174
1262
  }
@@ -1185,13 +1273,13 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1185
1273
  newline_before_expectation: true,
1186
1274
  expectation: proc {
1187
1275
  line do
1188
- plain " Expected "
1189
- beta %|{ name: "shopping list", contents: ["milk", "toast", "eggs"] }|
1276
+ plain %| Expected |
1277
+ actual %|{ name: "shopping list", contents: ["milk", "toast", "eggs"] }|
1190
1278
  end
1191
1279
 
1192
1280
  line do
1193
- plain "not to match "
1194
- alpha %|{ name: "shopping list", contents: #<a collection containing exactly ("milk", "eggs", "toast")> }|
1281
+ plain %|not to match |
1282
+ expected %|{ name: "shopping list", contents: #<a collection containing exactly ("milk", "eggs", "toast")> }|
1195
1283
  end
1196
1284
  },
1197
1285
  )
@@ -1203,7 +1291,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1203
1291
  end
1204
1292
  end
1205
1293
 
1206
- context "when the corresponding actual value is not an array" do
1294
+ context "when the corresponding actual value is not an array" do
1207
1295
  it "produces the correct failure message" do
1208
1296
  as_both_colored_and_uncolored do |color_enabled|
1209
1297
  snippet = <<~TEST.strip
@@ -1211,7 +1299,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1211
1299
  name: "shopping list",
1212
1300
  contents: a_collection_containing_exactly("milk", "bread")
1213
1301
  }
1214
- actual = {
1302
+ actual = {
1215
1303
  name: "shopping list",
1216
1304
  contents: nil
1217
1305
  }
@@ -1227,24 +1315,24 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
1227
1315
  snippet: %|expect(actual).to match(expected)|,
1228
1316
  expectation: proc {
1229
1317
  line do
1230
- plain "Expected "
1231
- beta %|{ name: "shopping list", contents: nil }|
1318
+ plain %|Expected |
1319
+ actual %|{ name: "shopping list", contents: nil }|
1232
1320
  end
1233
1321
 
1234
1322
  line do
1235
- plain "to match "
1236
- alpha %|{ name: "shopping list", contents: #<a collection containing exactly ("milk", "bread")> }|
1323
+ plain %|to match |
1324
+ expected %|{ name: "shopping list", contents: #<a collection containing exactly ("milk", "bread")> }|
1237
1325
  end
1238
1326
  },
1239
1327
  diff: proc {
1240
- plain_line %! {!
1241
- plain_line %! name: "shopping list",!
1242
- alpha_line %!- contents: #<a collection containing exactly (!
1243
- alpha_line %!- "milk",!
1244
- alpha_line %!- "bread"!
1245
- alpha_line %!- )>!
1246
- beta_line %!+ contents: nil!
1247
- plain_line %! }!
1328
+ plain_line %! {!
1329
+ plain_line %! name: "shopping list",!
1330
+ expected_line %!- contents: #<a collection containing exactly (!
1331
+ expected_line %!- "milk",!
1332
+ expected_line %!- "bread"!
1333
+ expected_line %!- )>!
1334
+ actual_line %!+ contents: nil!
1335
+ plain_line %! }!
1248
1336
  },
1249
1337
  )
1250
1338