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
@@ -13,11 +13,11 @@ RSpec.describe "Integration with RSpec's #be_truthy matcher", type: :integration
13
13
  snippet: %|expect(nil).to be_truthy|,
14
14
  expectation: proc {
15
15
  line do
16
- plain "Expected "
17
- beta %|nil|
18
- plain " to be "
19
- alpha %|truthy|
20
- plain "."
16
+ plain %|Expected |
17
+ actual %|nil|
18
+ plain %| to be |
19
+ expected %|truthy|
20
+ plain %|.|
21
21
  end
22
22
  },
23
23
  )
@@ -40,11 +40,11 @@ RSpec.describe "Integration with RSpec's #be_truthy matcher", type: :integration
40
40
  snippet: %|expect(true).not_to be_truthy|,
41
41
  expectation: proc {
42
42
  line do
43
- plain "Expected "
44
- beta %|true|
45
- plain " not to be "
46
- alpha %|truthy|
47
- plain "."
43
+ plain %|Expected |
44
+ actual %|true|
45
+ plain %| not to be |
46
+ expected %|truthy|
47
+ plain %|.|
48
48
  end
49
49
  },
50
50
  )
@@ -6,7 +6,7 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
6
6
  as_both_colored_and_uncolored do |color_enabled|
7
7
  snippet = <<~TEST.strip
8
8
  expected = ["Einie", "Marty"]
9
- actual = ["Marty", "Jennifer", "Doc"]
9
+ actual = ["Marty", "Jennifer", "Doc"]
10
10
  expect(actual).to contain_exactly(*expected)
11
11
  TEST
12
12
  program = make_plain_test_program(
@@ -19,22 +19,23 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
19
19
  snippet: %|expect(actual).to contain_exactly(*expected)|,
20
20
  expectation: proc {
21
21
  line do
22
- plain "Expected "
23
- beta %|["Marty", "Jennifer", "Doc"]|
24
- plain " to contain exactly "
25
- alpha %|"Einie"|
26
- plain " and "
27
- alpha %|"Marty"|
28
- plain "."
22
+ plain %|Expected |
23
+ actual %|["Marty", "Jennifer", "Doc"]|
24
+ plain %| to contain exactly |
25
+ expected %|"Einie"|
26
+ plain %| and |
27
+ expected %|"Marty"|
28
+ plain %|.|
29
29
  end
30
30
  },
31
31
  diff: proc {
32
- plain_line %| [|
33
- plain_line %| "Marty",|
34
- plain_line %| "Jennifer",|
35
- plain_line %| "Doc",|
36
- alpha_line %|- "Einie"|
37
- plain_line %| ]|
32
+ plain_line %| [|
33
+ plain_line %| "Marty",|
34
+ actual_line %|+ "Jennifer",|
35
+ actual_line %|+ "Doc",|
36
+ # expected_line %|- "Einie"| # TODO
37
+ expected_line %|- "Einie",|
38
+ plain_line %| ]|
38
39
  },
39
40
  )
40
41
 
@@ -60,13 +61,13 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
60
61
  snippet: %|expect(values).not_to contain_exactly(*values)|,
61
62
  expectation: proc {
62
63
  line do
63
- plain "Expected "
64
- beta %|["Einie", "Marty"]|
65
- plain " not to contain exactly "
66
- alpha %|"Einie"|
67
- plain " and "
68
- alpha %|"Marty"|
69
- plain "."
64
+ plain %|Expected |
65
+ actual %|["Einie", "Marty"]|
66
+ plain %| not to contain exactly |
67
+ expected %|"Einie"|
68
+ plain %| and |
69
+ expected %|"Marty"|
70
+ plain %|.|
70
71
  end
71
72
  },
72
73
  )
@@ -90,7 +91,7 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
90
91
  "George McFly",
91
92
  "Lorraine McFly"
92
93
  ]
93
- actual = [
94
+ actual = [
94
95
  "Marty McFly",
95
96
  "Doc Brown",
96
97
  "Einie",
@@ -108,32 +109,33 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
108
109
  snippet: %|expect(actual).to contain_exactly(*expected)|,
109
110
  expectation: proc {
110
111
  line do
111
- plain " Expected "
112
- beta %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
112
+ plain %| Expected |
113
+ actual %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
113
114
  end
114
115
 
115
116
  line do
116
- plain "to contain exactly "
117
- alpha %|"Doc Brown"|
118
- plain ", "
119
- alpha %|"Marty McFly"|
120
- plain ", "
121
- alpha %|"Biff Tannen"|
122
- plain ", "
123
- alpha %|"George McFly"|
124
- plain " and "
125
- alpha %|"Lorraine McFly"|
117
+ plain %|to contain exactly |
118
+ expected %|"Doc Brown"|
119
+ plain %|, |
120
+ expected %|"Marty McFly"|
121
+ plain %|, |
122
+ expected %|"Biff Tannen"|
123
+ plain %|, |
124
+ expected %|"George McFly"|
125
+ plain %| and |
126
+ expected %|"Lorraine McFly"|
126
127
  end
127
128
  },
128
129
  diff: proc {
129
- plain_line %| [|
130
- plain_line %| "Marty McFly",|
131
- plain_line %| "Doc Brown",|
132
- plain_line %| "Einie",|
133
- plain_line %| "Lorraine McFly",|
134
- alpha_line %|- "Biff Tannen",|
135
- alpha_line %|- "George McFly"|
136
- plain_line %| ]|
130
+ plain_line %| [|
131
+ plain_line %| "Marty McFly",|
132
+ plain_line %| "Doc Brown",|
133
+ plain_line %| "Lorraine McFly",|
134
+ actual_line %|+ "Einie",|
135
+ expected_line %|- "Biff Tannen",|
136
+ # expected_line %|- "George McFly"| # TODO
137
+ expected_line %|- "George McFly",|
138
+ plain_line %| ]|
137
139
  },
138
140
  )
139
141
 
@@ -165,19 +167,19 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
165
167
  newline_before_expectation: true,
166
168
  expectation: proc {
167
169
  line do
168
- plain " Expected "
169
- beta %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
170
+ plain %| Expected |
171
+ actual %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
170
172
  end
171
173
 
172
174
  line do
173
- plain "not to contain exactly "
174
- alpha %|"Marty McFly"|
175
- plain ", "
176
- alpha %|"Doc Brown"|
177
- plain ", "
178
- alpha %|"Einie"|
179
- plain " and "
180
- alpha %|"Lorraine McFly"|
175
+ plain %|not to contain exactly |
176
+ expected %|"Marty McFly"|
177
+ plain %|, |
178
+ expected %|"Doc Brown"|
179
+ plain %|, |
180
+ expected %|"Einie"|
181
+ plain %| and |
182
+ expected %|"Lorraine McFly"|
181
183
  end
182
184
  },
183
185
  )
@@ -200,7 +202,7 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
200
202
  /Georg McFly/,
201
203
  /Lorrain McFly/
202
204
  ]
203
- actual = [
205
+ actual = [
204
206
  "Marty McFly",
205
207
  "Doc Brown",
206
208
  "Einie",
@@ -218,33 +220,34 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
218
220
  snippet: %|expect(actual).to contain_exactly(*expected)|,
219
221
  expectation: proc {
220
222
  line do
221
- plain " Expected "
222
- beta %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
223
+ plain %| Expected |
224
+ actual %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
223
225
  end
224
226
 
225
227
  line do
226
- plain "to contain exactly "
227
- alpha %|/ Brown$/|
228
- plain ", "
229
- alpha %|"Marty McFly"|
230
- plain ", "
231
- alpha %|"Biff Tannen"|
232
- plain ", "
233
- alpha %|/Georg McFly/|
234
- plain " and "
235
- alpha %|/Lorrain McFly/|
228
+ plain %|to contain exactly |
229
+ expected %|/ Brown$/|
230
+ plain %|, |
231
+ expected %|"Marty McFly"|
232
+ plain %|, |
233
+ expected %|"Biff Tannen"|
234
+ plain %|, |
235
+ expected %|/Georg McFly/|
236
+ plain %| and |
237
+ expected %|/Lorrain McFly/|
236
238
  end
237
239
  },
238
240
  diff: proc {
239
- plain_line %| [|
240
- plain_line %| "Marty McFly",|
241
- plain_line %| "Doc Brown",|
242
- plain_line %| "Einie",|
243
- plain_line %| "Lorraine McFly",|
244
- alpha_line %|- "Biff Tannen",|
245
- alpha_line %|- /Georg McFly/,|
246
- alpha_line %|- /Lorrain McFly/|
247
- plain_line %| ]|
241
+ plain_line %| [|
242
+ plain_line %| "Marty McFly",|
243
+ plain_line %| "Doc Brown",|
244
+ actual_line %|+ "Einie",|
245
+ actual_line %|+ "Lorraine McFly",|
246
+ expected_line %|- "Biff Tannen",|
247
+ expected_line %|- /Georg McFly/,|
248
+ # expected_line %|- /Lorrain McFly/| # TODO
249
+ expected_line %|- /Lorrain McFly/,|
250
+ plain_line %| ]|
248
251
  },
249
252
  )
250
253
 
@@ -277,21 +280,21 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
277
280
  newline_before_expectation: true,
278
281
  expectation: proc {
279
282
  line do
280
- plain " Expected "
281
- beta %|[/ Brown$/, "Marty McFly", "Biff Tannen", /Georg McFly/, /Lorrain McFly/]|
283
+ plain %| Expected |
284
+ actual %|[/ Brown$/, "Marty McFly", "Biff Tannen", /Georg McFly/, /Lorrain McFly/]|
282
285
  end
283
286
 
284
287
  line do
285
- plain "not to contain exactly "
286
- alpha %|/ Brown$/|
287
- plain ", "
288
- alpha %|"Marty McFly"|
289
- plain ", "
290
- alpha %|"Biff Tannen"|
291
- plain ", "
292
- alpha %|/Georg McFly/|
293
- plain " and "
294
- alpha %|/Lorrain McFly/|
288
+ plain %|not to contain exactly |
289
+ expected %|/ Brown$/|
290
+ plain %|, |
291
+ expected %|"Marty McFly"|
292
+ plain %|, |
293
+ expected %|"Biff Tannen"|
294
+ plain %|, |
295
+ expected %|/Georg McFly/|
296
+ plain %| and |
297
+ expected %|/Lorrain McFly/|
295
298
  end
296
299
  },
297
300
  )
@@ -312,7 +315,7 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
312
315
  a_collection_containing_exactly("zing"),
313
316
  an_object_having_attributes(baz: "qux"),
314
317
  ]
315
- actual = [
318
+ actual = [
316
319
  { foo: "bar" },
317
320
  double(baz: "qux"),
318
321
  { blargh: "riddle" }
@@ -329,32 +332,35 @@ RSpec.describe "Integration with RSpec's #contain_exactly matcher", type: :integ
329
332
  snippet: %|expect(actual).to contain_exactly(*expected)|,
330
333
  expectation: proc {
331
334
  line do
332
- plain " Expected "
333
- beta %|[{ foo: "bar" }, #<Double (anonymous)>, { blargh: "riddle" }]|
335
+ plain %| Expected |
336
+ actual %|[{ foo: "bar" }, #<Double (anonymous) baz: "qux">, { blargh: "riddle" }]|
334
337
  end
335
338
 
336
339
  line do
337
- plain "to contain exactly "
338
- alpha %|#<a hash including (foo: "bar")>|
339
- plain ", "
340
- alpha %|#<a collection containing exactly ("zing")>|
341
- plain " and "
342
- alpha %|#<an object having attributes (baz: "qux")>|
340
+ plain %|to contain exactly |
341
+ expected %|#<a hash including (foo: "bar")>|
342
+ plain %|, |
343
+ expected %|#<a collection containing exactly ("zing")>|
344
+ plain %| and |
345
+ expected %|#<an object having attributes (baz: "qux")>|
343
346
  end
344
347
  },
345
348
  diff: proc {
346
- plain_line %| [|
347
- plain_line %| {|
348
- plain_line %| foo: "bar"|
349
- plain_line %| },|
350
- plain_line %| #<Double (anonymous)>,|
351
- plain_line %| {|
352
- plain_line %| blargh: "riddle"|
353
- plain_line %| },|
354
- alpha_line %|- #<a collection containing exactly (|
355
- alpha_line %|- "zing"|
356
- alpha_line %|- )>|
357
- plain_line %| ]|
349
+ plain_line %| [|
350
+ plain_line %| {|
351
+ plain_line %| foo: "bar"|
352
+ plain_line %| },|
353
+ plain_line %| #<Double (anonymous) {|
354
+ plain_line %| baz: "qux"|
355
+ plain_line %| }>,|
356
+ actual_line %|+ {|
357
+ actual_line %|+ blargh: "riddle"|
358
+ actual_line %|+ },|
359
+ expected_line %|- #<a collection containing exactly (|
360
+ expected_line %|- "zing"|
361
+ # expected_line %|- )>| # TODO
362
+ expected_line %|- )>,|
363
+ plain_line %| ]|
358
364
  },
359
365
  )
360
366
 
@@ -12,11 +12,11 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
12
12
  snippet: snippet,
13
13
  expectation: proc {
14
14
  line do
15
- plain "Expected "
16
- beta %|1|
17
- plain " to eq "
18
- alpha %|42|
19
- plain "."
15
+ plain %|Expected |
16
+ actual %|1|
17
+ plain %| to eq |
18
+ expected %|42|
19
+ plain %|.|
20
20
  end
21
21
  },
22
22
  )
@@ -37,11 +37,11 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
37
37
  snippet: snippet,
38
38
  expectation: proc {
39
39
  line do
40
- plain "Expected "
41
- beta %|42|
42
- plain " not to eq "
43
- alpha %|42|
44
- plain "."
40
+ plain %|Expected |
41
+ actual %|42|
42
+ plain %| not to eq |
43
+ expected %|42|
44
+ plain %|.|
45
45
  end
46
46
  },
47
47
  )
@@ -67,11 +67,11 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
67
67
  snippet: snippet,
68
68
  expectation: proc {
69
69
  line do
70
- plain "Expected "
71
- beta %|:bar|
72
- plain " to eq "
73
- alpha %|:foo|
74
- plain "."
70
+ plain %|Expected |
71
+ actual %|:bar|
72
+ plain %| to eq |
73
+ expected %|:foo|
74
+ plain %|.|
75
75
  end
76
76
  },
77
77
  )
@@ -95,11 +95,11 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
95
95
  snippet: snippet,
96
96
  expectation: proc {
97
97
  line do
98
- plain "Expected "
99
- beta %|:foo|
100
- plain " not to eq "
101
- alpha %|:foo|
102
- plain "."
98
+ plain %|Expected |
99
+ actual %|:foo|
100
+ plain %| not to eq |
101
+ expected %|:foo|
102
+ plain %|.|
103
103
  end
104
104
  },
105
105
  )
@@ -125,11 +125,11 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
125
125
  snippet: %|expect("Jennifer").to eq("Marty")|,
126
126
  expectation: proc {
127
127
  line do
128
- plain "Expected "
129
- beta %|"Jennifer"|
130
- plain " to eq "
131
- alpha %|"Marty"|
132
- plain "."
128
+ plain %|Expected |
129
+ actual %|"Jennifer"|
130
+ plain %| to eq |
131
+ expected %|"Marty"|
132
+ plain %|.|
133
133
  end
134
134
  },
135
135
  )
@@ -153,11 +153,11 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
153
153
  snippet: %|expect("Jennifer").not_to eq("Jennifer")|,
154
154
  expectation: proc {
155
155
  line do
156
- plain "Expected "
157
- beta %|"Jennifer"|
158
- plain " not to eq "
159
- alpha %|"Jennifer"|
160
- plain "."
156
+ plain %|Expected |
157
+ actual %|"Jennifer"|
158
+ plain %| not to eq |
159
+ expected %|"Jennifer"|
160
+ plain %|.|
161
161
  end
162
162
  },
163
163
  )
@@ -174,7 +174,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
174
174
  as_both_colored_and_uncolored do |color_enabled|
175
175
  snippet = <<~RUBY
176
176
  expected = Time.utc(2011, 12, 13, 14, 15, 16)
177
- actual = Time.utc(2011, 12, 13, 14, 15, 16, 500_000)
177
+ actual = Time.utc(2011, 12, 13, 14, 15, 16, 500_000)
178
178
  expect(expected).to eq(actual)
179
179
  RUBY
180
180
  program = make_plain_test_program(
@@ -187,26 +187,28 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
187
187
  snippet: %|expect(expected).to eq(actual)|,
188
188
  expectation: proc {
189
189
  line do
190
- plain "Expected "
191
- beta %|2011-12-13 14:15:16.000 UTC +00:00 (Time)|
192
- plain " to eq "
193
- alpha %|2011-12-13 14:15:16.500 UTC +00:00 (Time)|
194
- plain "."
190
+ plain %|Expected |
191
+ actual %|#<Time 2011-12-13 14:15:16 +00:00 (UTC)>|
192
+ end
193
+
194
+ line do
195
+ plain %| to eq |
196
+ expected %|#<Time 2011-12-13 14:15:16+(1/2) +00:00 (UTC)>|
195
197
  end
196
198
  },
197
199
  diff: proc {
198
- plain_line " #<Time {"
199
- plain_line " year: 2011,"
200
- plain_line " month: 12,"
201
- plain_line " day: 13,"
202
- plain_line " hour: 14,"
203
- plain_line " min: 15,"
204
- plain_line " sec: 16,"
205
- alpha_line "- nsec: 500000000,"
206
- beta_line "+ nsec: 0,"
207
- plain_line " zone: \"UTC\","
208
- plain_line " gmt_offset: 0"
209
- plain_line " }>"
200
+ plain_line " #<Time {"
201
+ plain_line " year: 2011,"
202
+ plain_line " month: 12,"
203
+ plain_line " day: 13,"
204
+ plain_line " hour: 14,"
205
+ plain_line " min: 15,"
206
+ plain_line " sec: 16,"
207
+ expected_line "- subsec: (1/2),"
208
+ actual_line "+ subsec: 0,"
209
+ plain_line " zone: \"UTC\","
210
+ plain_line " utc_offset: 0"
211
+ plain_line " }>"
210
212
  },
211
213
  )
212
214
 
@@ -233,69 +235,15 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
233
235
  newline_before_expectation: true,
234
236
  expectation: proc {
235
237
  line do
236
- plain " Expected "
237
- beta %|2011-12-13 14:15:16.000 UTC +00:00 (Time)|
238
- end
239
-
240
- line do
241
- plain "not to eq "
242
- alpha %|2011-12-13 14:15:16.000 UTC +00:00 (Time)|
243
- end
244
- },
245
- )
246
-
247
- expect(program).
248
- to produce_output_when_run(expected_output).
249
- in_color(color_enabled)
250
- end
251
- end
252
- end
253
-
254
- context "when comparing two different Time and ActiveSupport::TimeWithZone instances", active_record: true do
255
- it "produces the correct failure message when used in the positive" do
256
- as_both_colored_and_uncolored do |color_enabled|
257
- snippet = <<~RUBY
258
- expected = Time.utc(2011, 12, 13, 14, 15, 16)
259
- actual = Time.utc(2011, 12, 13, 15, 15, 16).in_time_zone("Europe/Stockholm")
260
- expect(expected).to eq(actual)
261
- RUBY
262
- program = make_rspec_rails_test_program(
263
- snippet,
264
- color_enabled: color_enabled,
265
- )
266
-
267
- expected_output = build_expected_output(
268
- color_enabled: color_enabled,
269
- snippet: %|expect(expected).to eq(actual)|,
270
- expectation: proc {
271
- line do
272
- plain "Expected "
273
- beta %|2011-12-13 14:15:16.000 UTC +00:00 (Time)|
238
+ plain %| Expected |
239
+ actual %|#<Time 2011-12-13 14:15:16 +00:00 (UTC)>|
274
240
  end
275
241
 
276
242
  line do
277
- plain " to eq "
278
- alpha %|2011-12-13 16:15:16.000 CET +01:00 (ActiveSupport::TimeWithZone)|
243
+ plain %|not to eq |
244
+ expected %|#<Time 2011-12-13 14:15:16 +00:00 (UTC)>|
279
245
  end
280
246
  },
281
- diff: proc {
282
- plain_line " #<ActiveSupport::TimeWithZone {"
283
- plain_line " year: 2011,"
284
- plain_line " month: 12,"
285
- plain_line " day: 13,"
286
- alpha_line "- hour: 16,"
287
- beta_line "+ hour: 14,"
288
- plain_line " min: 15,"
289
- plain_line " sec: 16,"
290
- plain_line " nsec: 0,"
291
- alpha_line "- zone: \"CET\","
292
- beta_line "+ zone: \"UTC\","
293
- alpha_line "- gmt_offset: 3600,"
294
- beta_line "+ gmt_offset: 0,"
295
- alpha_line "- utc: 2011-12-13 15:15:16.000 UTC +00:00 (Time)"
296
- beta_line "+ utc: 2011-12-13 14:15:16.000 UTC +00:00 (Time)"
297
- plain_line " }>"
298
- },
299
247
  )
300
248
 
301
249
  expect(program).
@@ -310,7 +258,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
310
258
  as_both_colored_and_uncolored do |color_enabled|
311
259
  snippet = <<~TEST.strip
312
260
  expected = "Something entirely different"
313
- actual = "This is a line\\nAnd that's another line\\n"
261
+ actual = "This is a line\\nAnd that's another line\\n"
314
262
  expect(actual).to eq(expected)
315
263
  TEST
316
264
  program = make_plain_test_program(snippet, color_enabled: color_enabled)
@@ -320,17 +268,17 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
320
268
  snippet: %|expect(actual).to eq(expected)|,
321
269
  expectation: proc {
322
270
  line do
323
- plain "Expected "
324
- beta %|"This is a line\\nAnd that's another line\\n"|
325
- plain " to eq "
326
- alpha %|"Something entirely different"|
327
- plain "."
271
+ plain %|Expected |
272
+ actual %|"This is a line\\nAnd that's another line\\n"|
273
+ plain %| to eq |
274
+ expected %|"Something entirely different"|
275
+ plain %|.|
328
276
  end
329
277
  },
330
278
  diff: proc {
331
- alpha_line %|- Something entirely different|
332
- beta_line %|+ This is a line\\n|
333
- beta_line %|+ And that's another line\\n|
279
+ expected_line %|- Something entirely different|
280
+ actual_line %|+ This is a line\\n|
281
+ actual_line %|+ And that's another line\\n|
334
282
  },
335
283
  )
336
284
 
@@ -346,7 +294,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
346
294
  as_both_colored_and_uncolored do |color_enabled|
347
295
  snippet = <<~TEST.strip
348
296
  expected = "This is a line\\nAnd that's another line\\n"
349
- actual = "Something entirely different"
297
+ actual = "Something entirely different"
350
298
  expect(actual).to eq(expected)
351
299
  TEST
352
300
  program = make_plain_test_program(snippet, color_enabled: color_enabled)
@@ -356,17 +304,17 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
356
304
  snippet: %|expect(actual).to eq(expected)|,
357
305
  expectation: proc {
358
306
  line do
359
- plain "Expected "
360
- beta %|"Something entirely different"|
361
- plain " to eq "
362
- alpha %|"This is a line\\nAnd that's another line\\n"|
363
- plain "."
307
+ plain %|Expected |
308
+ actual %|"Something entirely different"|
309
+ plain %| to eq |
310
+ expected %|"This is a line\\nAnd that's another line\\n"|
311
+ plain %|.|
364
312
  end
365
313
  },
366
314
  diff: proc {
367
- alpha_line %|- This is a line\\n|
368
- alpha_line %|- And that's another line\\n|
369
- beta_line %|+ Something entirely different|
315
+ expected_line %|- This is a line\\n|
316
+ expected_line %|- And that's another line\\n|
317
+ actual_line %|+ Something entirely different|
370
318
  },
371
319
  )
372
320
 
@@ -382,7 +330,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
382
330
  as_both_colored_and_uncolored do |color_enabled|
383
331
  snippet = <<~TEST.strip
384
332
  expected = "This is a line\\nAnd that's a line\\nAnd there's a line too\\n"
385
- actual = "This is a line\\nSomething completely different\\nAnd there's a line too\\n"
333
+ actual = "This is a line\\nSomething completely different\\nAnd there's a line too\\n"
386
334
  expect(actual).to eq(expected)
387
335
  TEST
388
336
  program = make_plain_test_program(snippet, color_enabled: color_enabled)
@@ -392,20 +340,20 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
392
340
  snippet: %|expect(actual).to eq(expected)|,
393
341
  expectation: proc {
394
342
  line do
395
- plain "Expected "
396
- beta %|"This is a line\\nSomething completely different\\nAnd there's a line too\\n"|
343
+ plain %|Expected |
344
+ actual %|"This is a line\\nSomething completely different\\nAnd there's a line too\\n"|
397
345
  end
398
346
 
399
347
  line do
400
- plain " to eq "
401
- alpha %|"This is a line\\nAnd that's a line\\nAnd there's a line too\\n"|
348
+ plain %| to eq |
349
+ expected %|"This is a line\\nAnd that's a line\\nAnd there's a line too\\n"|
402
350
  end
403
351
  },
404
352
  diff: proc {
405
- plain_line %| This is a line\\n|
406
- alpha_line %|- And that's a line\\n|
407
- beta_line %|+ Something completely different\\n|
408
- plain_line %| And there's a line too\\n|
353
+ plain_line %| This is a line\\n|
354
+ expected_line %|- And that's a line\\n|
355
+ actual_line %|+ Something completely different\\n|
356
+ plain_line %| And there's a line too\\n|
409
357
  },
410
358
  )
411
359
 
@@ -429,13 +377,13 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
429
377
  newline_before_expectation: true,
430
378
  expectation: proc {
431
379
  line do
432
- plain " Expected "
433
- beta %|"This is a line\\nAnd that's a line\\nAnd there's a line too\\n"|
380
+ plain %| Expected |
381
+ actual %|"This is a line\\nAnd that's a line\\nAnd there's a line too\\n"|
434
382
  end
435
383
 
436
384
  line do
437
- plain "not to eq "
438
- alpha %|"This is a line\\nAnd that's a line\\nAnd there's a line too\\n"|
385
+ plain %|not to eq |
386
+ expected %|"This is a line\\nAnd that's a line\\nAnd there's a line too\\n"|
439
387
  end
440
388
  },
441
389
  )
@@ -464,7 +412,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
464
412
  }
465
413
  ]
466
414
  ]
467
- actual = [
415
+ actual = [
468
416
  [
469
417
  :h2,
470
418
  [:span, [:text, "Goodbye world"]],
@@ -489,45 +437,45 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
489
437
  snippet: %|expect(actual).to eq(expected)|,
490
438
  expectation: proc {
491
439
  line do
492
- plain "Expected "
493
- beta %|[[:h2, [:span, [:text, "Goodbye world"]], { id: "hero", class: "header", data: { "sticky" => false, :role => "deprecated", :person => #<SuperDiff::Test::Person name: "Doc", age: 60> } }], :br]|
440
+ plain %|Expected |
441
+ actual %|[[:h2, [:span, [:text, "Goodbye world"]], { id: "hero", class: "header", data: { "sticky" => false, :role => "deprecated", :person => #<SuperDiff::Test::Person name: "Doc", age: 60> } }], :br]|
494
442
  end
495
443
 
496
444
  line do
497
- plain " to eq "
498
- alpha %|[[:h1, [:span, [:text, "Hello world"]], { class: "header", data: { "sticky" => true, :person => #<SuperDiff::Test::Person name: "Marty", age: 60> } }]]|
445
+ plain %| to eq |
446
+ expected %|[[:h1, [:span, [:text, "Hello world"]], { class: "header", data: { "sticky" => true, :person => #<SuperDiff::Test::Person name: "Marty", age: 60> } }]]|
499
447
  end
500
448
  },
501
449
  diff: proc {
502
- plain_line %| [|
503
- plain_line %| [|
504
- alpha_line %|- :h1,|
505
- beta_line %|+ :h2,|
506
- plain_line %| [|
507
- plain_line %| :span,|
508
- plain_line %| [|
509
- plain_line %| :text,|
510
- alpha_line %|- "Hello world"|
511
- beta_line %|+ "Goodbye world"|
512
- plain_line %| ]|
513
- plain_line %| ],|
514
- plain_line %| {|
515
- beta_line %|+ id: "hero",|
516
- plain_line %| class: "header",|
517
- plain_line %| data: {|
518
- alpha_line %|- "sticky" => true,|
519
- beta_line %|+ "sticky" => false,|
520
- beta_line %|+ role: "deprecated",|
521
- plain_line %| person: #<SuperDiff::Test::Person {|
522
- alpha_line %|- name: "Marty",|
523
- beta_line %|+ name: "Doc",|
524
- plain_line %| age: 60|
525
- plain_line %| }>|
526
- plain_line %| }|
527
- plain_line %| }|
528
- plain_line %| ],|
529
- beta_line %|+ :br|
530
- plain_line %| ]|
450
+ plain_line %| [|
451
+ plain_line %| [|
452
+ expected_line %|- :h1,|
453
+ actual_line %|+ :h2,|
454
+ plain_line %| [|
455
+ plain_line %| :span,|
456
+ plain_line %| [|
457
+ plain_line %| :text,|
458
+ expected_line %|- "Hello world"|
459
+ actual_line %|+ "Goodbye world"|
460
+ plain_line %| ]|
461
+ plain_line %| ],|
462
+ plain_line %| {|
463
+ actual_line %|+ id: "hero",|
464
+ plain_line %| class: "header",|
465
+ plain_line %| data: {|
466
+ expected_line %|- "sticky" => true,|
467
+ actual_line %|+ "sticky" => false,|
468
+ actual_line %|+ :role => "deprecated",|
469
+ plain_line %| :person => #<SuperDiff::Test::Person {|
470
+ expected_line %|- name: "Marty",|
471
+ actual_line %|+ name: "Doc",|
472
+ plain_line %| age: 60|
473
+ plain_line %| }>|
474
+ plain_line %| }|
475
+ plain_line %| }|
476
+ plain_line %| ],|
477
+ actual_line %|+ :br|
478
+ plain_line %| ]|
531
479
  },
532
480
  )
533
481
 
@@ -563,13 +511,13 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
563
511
  newline_before_expectation: true,
564
512
  expectation: proc {
565
513
  line do
566
- plain " Expected "
567
- beta %|[[:h1, [:span, [:text, "Hello world"]], { class: "header", data: { "sticky" => true, :person => #<SuperDiff::Test::Person name: "Marty", age: 60> } }]]|
514
+ plain %| Expected |
515
+ actual %|[[:h1, [:span, [:text, "Hello world"]], { class: "header", data: { "sticky" => true, :person => #<SuperDiff::Test::Person name: "Marty", age: 60> } }]]|
568
516
  end
569
517
 
570
518
  line do
571
- plain "not to eq "
572
- alpha %|[[:h1, [:span, [:text, "Hello world"]], { class: "header", data: { "sticky" => true, :person => #<SuperDiff::Test::Person name: "Marty", age: 60> } }]]|
519
+ plain %|not to eq |
520
+ expected %|[[:h1, [:span, [:text, "Hello world"]], { class: "header", data: { "sticky" => true, :person => #<SuperDiff::Test::Person name: "Marty", age: 60> } }]]|
573
521
  end
574
522
  },
575
523
  )
@@ -604,7 +552,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
604
552
  { name: "Chevy 4x4" }
605
553
  ]
606
554
  }
607
- actual = {
555
+ actual = {
608
556
  customer: {
609
557
  person: SuperDiff::Test::Person.new(name: "Marty McFly, Jr.", age: 17),
610
558
  shipping_address: {
@@ -632,47 +580,47 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
632
580
  snippet: %|expect(actual).to eq(expected)|,
633
581
  expectation: proc {
634
582
  line do
635
- plain "Expected "
636
- beta %|{ customer: { person: #<SuperDiff::Test::Person name: "Marty McFly, Jr.", age: 17>, shipping_address: { line_1: "456 Ponderosa Ct.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Mattel Hoverboard" }] }|
583
+ plain %|Expected |
584
+ actual %|{ customer: { person: #<SuperDiff::Test::Person name: "Marty McFly, Jr.", age: 17>, shipping_address: { line_1: "456 Ponderosa Ct.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Mattel Hoverboard" }] }|
637
585
  end
638
586
 
639
587
  line do
640
- plain " to eq "
641
- alpha %|{ customer: { person: #<SuperDiff::Test::Person name: "Marty McFly", age: 17>, shipping_address: { line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Chevy 4x4" }] }|
588
+ plain %| to eq |
589
+ expected %|{ customer: { person: #<SuperDiff::Test::Person name: "Marty McFly", age: 17>, shipping_address: { line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Chevy 4x4" }] }|
642
590
  end
643
591
  },
644
592
  diff: proc {
645
- plain_line %| {|
646
- plain_line %| customer: {|
647
- plain_line %| person: #<SuperDiff::Test::Person {|
648
- alpha_line %|- name: "Marty McFly",|
649
- beta_line %|+ name: "Marty McFly, Jr.",|
650
- plain_line %| age: 17|
651
- plain_line %| }>,|
652
- plain_line %| shipping_address: {|
653
- alpha_line %|- line_1: "123 Main St.",|
654
- beta_line %|+ line_1: "456 Ponderosa Ct.",|
655
- plain_line %| city: "Hill Valley",|
656
- plain_line %| state: "CA",|
657
- plain_line %| zip: "90382"|
658
- plain_line %| }|
659
- plain_line %| },|
660
- plain_line %| items: [|
661
- plain_line %| {|
662
- plain_line %| name: "Fender Stratocaster",|
663
- plain_line %| cost: 100000,|
664
- plain_line %| options: [|
665
- plain_line %| "red",|
666
- plain_line %| "blue",|
667
- plain_line %| "green"|
668
- plain_line %| ]|
669
- plain_line %| },|
670
- plain_line %| {|
671
- alpha_line %|- name: "Chevy 4x4"|
672
- beta_line %|+ name: "Mattel Hoverboard"|
673
- plain_line %| }|
674
- plain_line %| ]|
675
- plain_line %| }|
593
+ plain_line %| {|
594
+ plain_line %| customer: {|
595
+ plain_line %| person: #<SuperDiff::Test::Person {|
596
+ expected_line %|- name: "Marty McFly",|
597
+ actual_line %|+ name: "Marty McFly, Jr.",|
598
+ plain_line %| age: 17|
599
+ plain_line %| }>,|
600
+ plain_line %| shipping_address: {|
601
+ expected_line %|- line_1: "123 Main St.",|
602
+ actual_line %|+ line_1: "456 Ponderosa Ct.",|
603
+ plain_line %| city: "Hill Valley",|
604
+ plain_line %| state: "CA",|
605
+ plain_line %| zip: "90382"|
606
+ plain_line %| }|
607
+ plain_line %| },|
608
+ plain_line %| items: [|
609
+ plain_line %| {|
610
+ plain_line %| name: "Fender Stratocaster",|
611
+ plain_line %| cost: 100000,|
612
+ plain_line %| options: [|
613
+ plain_line %| "red",|
614
+ plain_line %| "blue",|
615
+ plain_line %| "green"|
616
+ plain_line %| ]|
617
+ plain_line %| },|
618
+ plain_line %| {|
619
+ expected_line %|- name: "Chevy 4x4"|
620
+ actual_line %|+ name: "Mattel Hoverboard"|
621
+ plain_line %| }|
622
+ plain_line %| ]|
623
+ plain_line %| }|
676
624
  },
677
625
  )
678
626
 
@@ -714,13 +662,13 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
714
662
  newline_before_expectation: true,
715
663
  expectation: proc {
716
664
  line do
717
- plain " Expected "
718
- beta %|{ customer: { person: #<SuperDiff::Test::Person name: "Marty McFly", age: 17>, shipping_address: { line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Chevy 4x4" }] }|
665
+ plain %| Expected |
666
+ actual %|{ customer: { person: #<SuperDiff::Test::Person name: "Marty McFly", age: 17>, shipping_address: { line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Chevy 4x4" }] }|
719
667
  end
720
668
 
721
669
  line do
722
- plain "not to eq "
723
- alpha %|{ customer: { person: #<SuperDiff::Test::Person name: "Marty McFly", age: 17>, shipping_address: { line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Chevy 4x4" }] }|
670
+ plain %|not to eq |
671
+ expected %|{ customer: { person: #<SuperDiff::Test::Person name: "Marty McFly", age: 17>, shipping_address: { line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" } }, items: [{ name: "Fender Stratocaster", cost: 100000, options: ["red", "blue", "green"] }, { name: "Chevy 4x4" }] }|
724
672
  end
725
673
  },
726
674
  )
@@ -740,7 +688,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
740
688
  name: "Marty",
741
689
  age: 31,
742
690
  )
743
- actual = SuperDiff::Test::Customer.new(
691
+ actual = SuperDiff::Test::Customer.new(
744
692
  name: "Doc",
745
693
  shipping_address: :some_shipping_address,
746
694
  phone: "1234567890",
@@ -755,13 +703,13 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
755
703
  newline_before_expectation: true,
756
704
  expectation: proc {
757
705
  line do
758
- plain "Expected "
759
- beta %|#<SuperDiff::Test::Customer name: "Doc", shipping_address: :some_shipping_address, phone: "1234567890">|
706
+ plain %|Expected |
707
+ actual %|#<SuperDiff::Test::Customer name: "Doc", shipping_address: :some_shipping_address, phone: "1234567890">|
760
708
  end
761
709
 
762
710
  line do
763
- plain " to eq "
764
- alpha %|#<SuperDiff::Test::Person name: "Marty", age: 31>|
711
+ plain %| to eq |
712
+ expected %|#<SuperDiff::Test::Person name: "Marty", age: 31>|
765
713
  end
766
714
  },
767
715
  )
@@ -789,13 +737,13 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
789
737
  newline_before_expectation: true,
790
738
  expectation: proc {
791
739
  line do
792
- plain " Expected "
793
- beta %|#<SuperDiff::Test::Person name: "Marty", age: 31>|
740
+ plain %| Expected |
741
+ actual %|#<SuperDiff::Test::Person name: "Marty", age: 31>|
794
742
  end
795
743
 
796
744
  line do
797
- plain "not to eq "
798
- alpha %|#<SuperDiff::Test::Person name: "Marty", age: 31>|
745
+ plain %|not to eq |
746
+ expected %|#<SuperDiff::Test::Person name: "Marty", age: 31>|
799
747
  end
800
748
  },
801
749
  )
@@ -815,7 +763,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
815
763
  name: "camera",
816
764
  quantity: 3,
817
765
  )
818
- actual = SuperDiff::Test::Player.new(
766
+ actual = SuperDiff::Test::Player.new(
819
767
  handle: "mcmire",
820
768
  character: "Jon",
821
769
  inventory: ["sword"],
@@ -832,17 +780,14 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
832
780
  snippet: %|expect(actual).to eq(expected)|,
833
781
  newline_before_expectation: true,
834
782
  expectation: proc {
835
- if SuperDiff::Test.jruby?
836
- else
837
- line do
838
- plain "Expected "
839
- beta %|#<SuperDiff::Test::Player @handle="mcmire", @character="Jon", @inventory=["sword"], @shields=11.4, @health=4, @ultimate=true>|
840
- end
841
-
842
- line do
843
- plain " to eq "
844
- alpha %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
845
- end
783
+ line do
784
+ plain %|Expected |
785
+ actual %|#<SuperDiff::Test::Player @character="Jon", @handle="mcmire", @health=4, @inventory=["sword"], @shields=11.4, @ultimate=true>|
786
+ end
787
+
788
+ line do
789
+ plain %| to eq |
790
+ expected %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
846
791
  end
847
792
  },
848
793
  )
@@ -870,17 +815,14 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
870
815
  snippet: %|expect(value).not_to eq(value)|,
871
816
  newline_before_expectation: true,
872
817
  expectation: proc {
873
- if SuperDiff::Test.jruby?
874
- else
875
- line do
876
- plain " Expected "
877
- beta %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
878
- end
879
-
880
- line do
881
- plain "not to eq "
882
- alpha %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
883
- end
818
+ line do
819
+ plain %| Expected |
820
+ actual %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
821
+ end
822
+
823
+ line do
824
+ plain %|not to eq |
825
+ expected %|#<SuperDiff::Test::Item @name="camera", @quantity=3>|
884
826
  end
885
827
  },
886
828
  )
@@ -898,7 +840,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
898
840
  as_both_colored_and_uncolored do |color_enabled|
899
841
  snippet = <<~TEST.strip
900
842
  expected = { foo: nil }
901
- actual = { foo: [] }
843
+ actual = { foo: [] }
902
844
  expect(actual).to eq(expected)
903
845
  TEST
904
846
  program = make_plain_test_program(snippet, color_enabled: color_enabled)
@@ -909,18 +851,18 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
909
851
  newline_before_expectation: true,
910
852
  expectation: proc {
911
853
  line do
912
- plain "Expected "
913
- beta %|{ foo: [] }|
914
- plain " to eq "
915
- alpha %|{ foo: nil }|
916
- plain "."
854
+ plain %|Expected |
855
+ actual %|{ foo: [] }|
856
+ plain %| to eq |
857
+ expected %|{ foo: nil }|
858
+ plain %|.|
917
859
  end
918
860
  },
919
861
  diff: proc {
920
- plain_line %| {|
921
- alpha_line %|- foo: nil|
922
- beta_line %|+ foo: []|
923
- plain_line %| }|
862
+ plain_line %| {|
863
+ expected_line %|- foo: nil|
864
+ actual_line %|+ foo: []|
865
+ plain_line %| }|
924
866
  }
925
867
  )
926
868
 
@@ -936,7 +878,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
936
878
  as_both_colored_and_uncolored do |color_enabled|
937
879
  snippet = <<~TEST.strip
938
880
  expected = { foo: nil }
939
- actual = { foo: {} }
881
+ actual = { foo: {} }
940
882
  expect(actual).to eq(expected)
941
883
  TEST
942
884
  program = make_plain_test_program(snippet, color_enabled: color_enabled)
@@ -947,18 +889,18 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
947
889
  newline_before_expectation: true,
948
890
  expectation: proc {
949
891
  line do
950
- plain "Expected "
951
- beta %|{ foo: {} }|
952
- plain " to eq "
953
- alpha %|{ foo: nil }|
954
- plain "."
892
+ plain %|Expected |
893
+ actual %|{ foo: {} }|
894
+ plain %| to eq |
895
+ expected %|{ foo: nil }|
896
+ plain %|.|
955
897
  end
956
898
  },
957
899
  diff: proc {
958
- plain_line %| {|
959
- alpha_line %|- foo: nil|
960
- beta_line %|+ foo: {}|
961
- plain_line %| }|
900
+ plain_line %| {|
901
+ expected_line %|- foo: nil|
902
+ actual_line %|+ foo: {}|
903
+ plain_line %| }|
962
904
  }
963
905
  )
964
906
 
@@ -974,7 +916,7 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
974
916
  as_both_colored_and_uncolored do |color_enabled|
975
917
  snippet = <<~TEST.strip
976
918
  expected = { foo: nil }
977
- actual = { foo: SuperDiff::Test::EmptyClass.new }
919
+ actual = { foo: SuperDiff::Test::EmptyClass.new }
978
920
  expect(actual).to eq(expected)
979
921
  TEST
980
922
  program = make_plain_test_program(snippet, color_enabled: color_enabled)
@@ -985,18 +927,18 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
985
927
  newline_before_expectation: true,
986
928
  expectation: proc {
987
929
  line do
988
- plain "Expected "
989
- beta %|{ foo: #<SuperDiff::Test::EmptyClass> }|
990
- plain " to eq "
991
- alpha %|{ foo: nil }|
992
- plain "."
930
+ plain %|Expected |
931
+ actual %|{ foo: #<SuperDiff::Test::EmptyClass> }|
932
+ plain %| to eq |
933
+ expected %|{ foo: nil }|
934
+ plain %|.|
993
935
  end
994
936
  },
995
937
  diff: proc {
996
- plain_line %| {|
997
- alpha_line %|- foo: nil|
998
- beta_line %|+ foo: #<SuperDiff::Test::EmptyClass>|
999
- plain_line %| }|
938
+ plain_line %| {|
939
+ expected_line %|- foo: nil|
940
+ actual_line %|+ foo: #<SuperDiff::Test::EmptyClass>|
941
+ plain_line %| }|
1000
942
  }
1001
943
  )
1002
944
 
@@ -1007,4 +949,8 @@ RSpec.describe "Integration with RSpec's #eq matcher", type: :integration do
1007
949
  end
1008
950
  end
1009
951
  end
952
+
953
+ it_behaves_like "a matcher that supports elided diffs" do
954
+ let(:matcher) { :eq }
955
+ end
1010
956
  end