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
@@ -1,6 +1,6 @@
1
1
  shared_examples_for "integration with HashWithIndifferentAccess" do
2
2
  describe "and RSpec's #eq matcher" do
3
- context "when the actual value is a HashWithIndifferentAccess" do
3
+ context "when the actual value is a HashWithIndifferentAccess" do
4
4
  context "and both hashes are one-dimensional" do
5
5
  context "and the expected hash contains symbol keys" do
6
6
  it "produces the correct output" do
@@ -12,7 +12,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
12
12
  state: "CA",
13
13
  zip: "90382",
14
14
  }
15
- actual = HashWithIndifferentAccess.new({
15
+ actual = HashWithIndifferentAccess.new({
16
16
  line_1: "456 Ponderosa Ct.",
17
17
  city: "Oakland",
18
18
  state: "CA",
@@ -20,35 +20,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
20
20
  })
21
21
  expect(actual).to eq(expected)
22
22
  TEST
23
- program = make_rspec_rails_test_program(
24
- snippet,
25
- color_enabled: color_enabled,
26
- )
23
+ program = make_program(snippet, color_enabled: color_enabled)
27
24
 
28
25
  expected_output = build_expected_output(
29
26
  color_enabled: color_enabled,
30
27
  snippet: "expect(actual).to eq(expected)",
31
28
  expectation: proc {
32
29
  line do
33
- plain "Expected "
34
- beta %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
30
+ plain %|Expected |
31
+ actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
35
32
  end
36
33
 
37
34
  line do
38
- plain " to eq "
39
- alpha %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
35
+ plain %| to eq |
36
+ expected %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
40
37
  end
41
38
  },
42
39
  diff: proc {
43
- plain_line %| #<HashWithIndifferentAccess {|
44
- alpha_line %|- "line_1" => "123 Main St.",|
45
- beta_line %|+ "line_1" => "456 Ponderosa Ct.",|
46
- alpha_line %|- "city" => "Hill Valley",|
47
- beta_line %|+ "city" => "Oakland",|
48
- plain_line %| "state" => "CA",|
49
- alpha_line %|- "zip" => "90382"|
50
- beta_line %|+ "zip" => "91234"|
51
- plain_line %| }>|
40
+ plain_line %| #<HashWithIndifferentAccess {|
41
+ expected_line %|- "line_1" => "123 Main St.",|
42
+ actual_line %|+ "line_1" => "456 Ponderosa Ct.",|
43
+ expected_line %|- "city" => "Hill Valley",|
44
+ actual_line %|+ "city" => "Oakland",|
45
+ plain_line %| "state" => "CA",|
46
+ expected_line %|- "zip" => "90382"|
47
+ actual_line %|+ "zip" => "91234"|
48
+ plain_line %| }>|
52
49
  },
53
50
  )
54
51
 
@@ -69,7 +66,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
69
66
  "state" => "CA",
70
67
  "zip" => "90382",
71
68
  }
72
- actual = HashWithIndifferentAccess.new({
69
+ actual = HashWithIndifferentAccess.new({
73
70
  line_1: "456 Ponderosa Ct.",
74
71
  city: "Oakland",
75
72
  state: "CA",
@@ -77,35 +74,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
77
74
  })
78
75
  expect(actual).to eq(expected)
79
76
  TEST
80
- program = make_rspec_rails_test_program(
81
- snippet,
82
- color_enabled: color_enabled,
83
- )
77
+ program = make_program(snippet, color_enabled: color_enabled)
84
78
 
85
79
  expected_output = build_expected_output(
86
80
  color_enabled: color_enabled,
87
81
  snippet: "expect(actual).to eq(expected)",
88
82
  expectation: proc {
89
83
  line do
90
- plain "Expected "
91
- beta %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
84
+ plain %|Expected |
85
+ actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
92
86
  end
93
87
 
94
88
  line do
95
- plain " to eq "
96
- alpha %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
89
+ plain %| to eq |
90
+ expected %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
97
91
  end
98
92
  },
99
93
  diff: proc {
100
- plain_line %| #<HashWithIndifferentAccess {|
101
- alpha_line %|- "line_1" => "123 Main St.",|
102
- beta_line %|+ "line_1" => "456 Ponderosa Ct.",|
103
- alpha_line %|- "city" => "Hill Valley",|
104
- beta_line %|+ "city" => "Oakland",|
105
- plain_line %| "state" => "CA",|
106
- alpha_line %|- "zip" => "90382"|
107
- beta_line %|+ "zip" => "91234"|
108
- plain_line %| }>|
94
+ plain_line %| #<HashWithIndifferentAccess {|
95
+ expected_line %|- "line_1" => "123 Main St.",|
96
+ actual_line %|+ "line_1" => "456 Ponderosa Ct.",|
97
+ expected_line %|- "city" => "Hill Valley",|
98
+ actual_line %|+ "city" => "Oakland",|
99
+ plain_line %| "state" => "CA",|
100
+ expected_line %|- "zip" => "90382"|
101
+ actual_line %|+ "zip" => "91234"|
102
+ plain_line %| }>|
109
103
  },
110
104
  )
111
105
 
@@ -130,7 +124,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
130
124
  state: "CA",
131
125
  zip: "91234",
132
126
  })
133
- actual = {
127
+ actual = {
134
128
  line_1: "123 Main St.",
135
129
  city: "Hill Valley",
136
130
  state: "CA",
@@ -138,35 +132,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
138
132
  }
139
133
  expect(actual).to eq(expected)
140
134
  TEST
141
- program = make_rspec_rails_test_program(
142
- snippet,
143
- color_enabled: color_enabled,
144
- )
135
+ program = make_program(snippet, color_enabled: color_enabled)
145
136
 
146
137
  expected_output = build_expected_output(
147
138
  color_enabled: color_enabled,
148
139
  snippet: "expect(actual).to eq(expected)",
149
140
  expectation: proc {
150
141
  line do
151
- plain "Expected "
152
- beta %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
142
+ plain %|Expected |
143
+ actual %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
153
144
  end
154
145
 
155
146
  line do
156
- plain " to eq "
157
- alpha %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
147
+ plain %| to eq |
148
+ expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
158
149
  end
159
150
  },
160
151
  diff: proc {
161
- plain_line %| #<HashWithIndifferentAccess {|
162
- alpha_line %|- "line_1" => "456 Ponderosa Ct.",|
163
- beta_line %|+ "line_1" => "123 Main St.",|
164
- alpha_line %|- "city" => "Oakland",|
165
- beta_line %|+ "city" => "Hill Valley",|
166
- plain_line %| "state" => "CA",|
167
- alpha_line %|- "zip" => "91234"|
168
- beta_line %|+ "zip" => "90382"|
169
- plain_line %| }>|
152
+ plain_line %| #<HashWithIndifferentAccess {|
153
+ expected_line %|- "line_1" => "456 Ponderosa Ct.",|
154
+ actual_line %|+ "line_1" => "123 Main St.",|
155
+ expected_line %|- "city" => "Oakland",|
156
+ actual_line %|+ "city" => "Hill Valley",|
157
+ plain_line %| "state" => "CA",|
158
+ expected_line %|- "zip" => "91234"|
159
+ actual_line %|+ "zip" => "90382"|
160
+ plain_line %| }>|
170
161
  },
171
162
  )
172
163
 
@@ -177,7 +168,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
177
168
  end
178
169
  end
179
170
 
180
- context "and the actual hash contains string keys" do
171
+ context "and the actual hash contains string keys" do
181
172
  it "produces the correct output" do
182
173
  as_both_colored_and_uncolored do |color_enabled|
183
174
  snippet = <<~TEST.strip
@@ -187,7 +178,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
187
178
  state: "CA",
188
179
  zip: "91234",
189
180
  })
190
- actual = {
181
+ actual = {
191
182
  "line_1" => "123 Main St.",
192
183
  "city" => "Hill Valley",
193
184
  "state" => "CA",
@@ -195,35 +186,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
195
186
  }
196
187
  expect(actual).to eq(expected)
197
188
  TEST
198
- program = make_rspec_rails_test_program(
199
- snippet,
200
- color_enabled: color_enabled,
201
- )
189
+ program = make_program(snippet, color_enabled: color_enabled)
202
190
 
203
191
  expected_output = build_expected_output(
204
192
  color_enabled: color_enabled,
205
193
  snippet: "expect(actual).to eq(expected)",
206
194
  expectation: proc {
207
195
  line do
208
- plain "Expected "
209
- beta %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
196
+ plain %|Expected |
197
+ actual %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
210
198
  end
211
199
 
212
200
  line do
213
- plain " to eq "
214
- alpha %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
201
+ plain %| to eq |
202
+ expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
215
203
  end
216
204
  },
217
205
  diff: proc {
218
- plain_line %| #<HashWithIndifferentAccess {|
219
- alpha_line %|- "line_1" => "456 Ponderosa Ct.",|
220
- beta_line %|+ "line_1" => "123 Main St.",|
221
- alpha_line %|- "city" => "Oakland",|
222
- beta_line %|+ "city" => "Hill Valley",|
223
- plain_line %| "state" => "CA",|
224
- alpha_line %|- "zip" => "91234"|
225
- beta_line %|+ "zip" => "90382"|
226
- plain_line %| }>|
206
+ plain_line %| #<HashWithIndifferentAccess {|
207
+ expected_line %|- "line_1" => "456 Ponderosa Ct.",|
208
+ actual_line %|+ "line_1" => "123 Main St.",|
209
+ expected_line %|- "city" => "Oakland",|
210
+ actual_line %|+ "city" => "Hill Valley",|
211
+ plain_line %| "state" => "CA",|
212
+ expected_line %|- "zip" => "91234"|
213
+ actual_line %|+ "zip" => "90382"|
214
+ plain_line %| }>|
227
215
  },
228
216
  )
229
217
 
@@ -250,7 +238,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
250
238
  })
251
239
  ]
252
240
  })
253
- actual = {
241
+ actual = {
254
242
  shipments: [
255
243
  {
256
244
  estimated_delivery: {
@@ -262,37 +250,34 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
262
250
  }
263
251
  expect(actual).to eq(expected)
264
252
  TEST
265
- program = make_rspec_rails_test_program(
266
- snippet,
267
- color_enabled: color_enabled,
268
- )
253
+ program = make_program(snippet, color_enabled: color_enabled)
269
254
 
270
255
  expected_output = build_expected_output(
271
256
  color_enabled: color_enabled,
272
257
  snippet: "expect(actual).to eq(expected)",
273
258
  expectation: proc {
274
259
  line do
275
- plain "Expected "
276
- beta %|{ shipments: [{ estimated_delivery: { from: "2019-05-06", to: "2019-05-09" } }] }|
260
+ plain %|Expected |
261
+ actual %|{ shipments: [{ estimated_delivery: { from: "2019-05-06", to: "2019-05-09" } }] }|
277
262
  end
278
263
 
279
264
  line do
280
- plain " to eq "
281
- alpha %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
265
+ plain %| to eq |
266
+ expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
282
267
  end
283
268
  },
284
269
  diff: proc {
285
- plain_line %| #<HashWithIndifferentAccess {|
286
- plain_line %| "shipments" => [|
287
- plain_line %| {|
288
- plain_line %| "estimated_delivery" => {|
289
- plain_line %| "from" => "2019-05-06",|
290
- alpha_line %|- "to" => "2019-05-06"|
291
- beta_line %|+ "to" => "2019-05-09"|
292
- plain_line %| }|
293
- plain_line %| }|
294
- plain_line %| ]|
295
- plain_line %| }>|
270
+ plain_line %| #<HashWithIndifferentAccess {|
271
+ plain_line %| "shipments" => [|
272
+ plain_line %| #<HashWithIndifferentAccess {|
273
+ plain_line %| "estimated_delivery" => #<HashWithIndifferentAccess {|
274
+ plain_line %| "from" => "2019-05-06",|
275
+ expected_line %|- "to" => "2019-05-06"|
276
+ actual_line %|+ "to" => "2019-05-09"|
277
+ plain_line %| }>|
278
+ plain_line %| }>|
279
+ plain_line %| ]|
280
+ plain_line %| }>|
296
281
  },
297
282
  )
298
283
 
@@ -303,7 +288,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
303
288
  end
304
289
  end
305
290
 
306
- context "and the actual hash contains string keys" do
291
+ context "and the actual hash contains string keys" do
307
292
  it "produces the correct output" do
308
293
  as_both_colored_and_uncolored do |color_enabled|
309
294
  snippet = <<~TEST.strip
@@ -317,7 +302,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
317
302
  })
318
303
  ]
319
304
  })
320
- actual = {
305
+ actual = {
321
306
  'shipments' => [
322
307
  {
323
308
  'estimated_delivery' => {
@@ -329,37 +314,34 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
329
314
  }
330
315
  expect(actual).to eq(expected)
331
316
  TEST
332
- program = make_rspec_rails_test_program(
333
- snippet,
334
- color_enabled: color_enabled,
335
- )
317
+ program = make_program(snippet, color_enabled: color_enabled)
336
318
 
337
319
  expected_output = build_expected_output(
338
320
  color_enabled: color_enabled,
339
321
  snippet: "expect(actual).to eq(expected)",
340
322
  expectation: proc {
341
323
  line do
342
- plain "Expected "
343
- beta %|{ "shipments" => [{ "estimated_delivery" => { "from" => "2019-05-06", "to" => "2019-05-09" } }] }|
324
+ plain %|Expected |
325
+ actual %|{ "shipments" => [{ "estimated_delivery" => { "from" => "2019-05-06", "to" => "2019-05-09" } }] }|
344
326
  end
345
327
 
346
328
  line do
347
- plain " to eq "
348
- alpha %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
329
+ plain %| to eq |
330
+ expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
349
331
  end
350
332
  },
351
333
  diff: proc {
352
- plain_line %| #<HashWithIndifferentAccess {|
353
- plain_line %| "shipments" => [|
354
- plain_line %| {|
355
- plain_line %| "estimated_delivery" => {|
356
- plain_line %| "from" => "2019-05-06",|
357
- alpha_line %|- "to" => "2019-05-06"|
358
- beta_line %|+ "to" => "2019-05-09"|
359
- plain_line %| }|
360
- plain_line %| }|
361
- plain_line %| ]|
362
- plain_line %| }>|
334
+ plain_line %| #<HashWithIndifferentAccess {|
335
+ plain_line %| "shipments" => [|
336
+ plain_line %| #<HashWithIndifferentAccess {|
337
+ plain_line %| "estimated_delivery" => #<HashWithIndifferentAccess {|
338
+ plain_line %| "from" => "2019-05-06",|
339
+ expected_line %|- "to" => "2019-05-06"|
340
+ actual_line %|+ "to" => "2019-05-09"|
341
+ plain_line %| }>|
342
+ plain_line %| }>|
343
+ plain_line %| ]|
344
+ plain_line %| }>|
363
345
  },
364
346
  )
365
347
 
@@ -374,7 +356,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
374
356
  end
375
357
 
376
358
  describe "and RSpec's #match matcher" do
377
- context "when the actual value is a HashWithIndifferentAccess" do
359
+ context "when the actual value is a HashWithIndifferentAccess" do
378
360
  context "and both hashes are one-dimensional" do
379
361
  context "and the expected hash contains symbol keys" do
380
362
  it "produces the correct output" do
@@ -386,7 +368,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
386
368
  state: "CA",
387
369
  zip: "90382",
388
370
  }
389
- actual = HashWithIndifferentAccess.new({
371
+ actual = HashWithIndifferentAccess.new({
390
372
  line_1: "456 Ponderosa Ct.",
391
373
  city: "Oakland",
392
374
  state: "CA",
@@ -394,35 +376,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
394
376
  })
395
377
  expect(actual).to match(expected)
396
378
  TEST
397
- program = make_rspec_rails_test_program(
398
- snippet,
399
- color_enabled: color_enabled,
400
- )
379
+ program = make_program(snippet, color_enabled: color_enabled)
401
380
 
402
381
  expected_output = build_expected_output(
403
382
  color_enabled: color_enabled,
404
383
  snippet: "expect(actual).to match(expected)",
405
384
  expectation: proc {
406
385
  line do
407
- plain "Expected "
408
- beta %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
386
+ plain %|Expected |
387
+ actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
409
388
  end
410
389
 
411
390
  line do
412
- plain "to match "
413
- alpha %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
391
+ plain %|to match |
392
+ expected %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
414
393
  end
415
394
  },
416
395
  diff: proc {
417
- plain_line %| #<HashWithIndifferentAccess {|
418
- alpha_line %|- "line_1" => "123 Main St.",|
419
- beta_line %|+ "line_1" => "456 Ponderosa Ct.",|
420
- alpha_line %|- "city" => "Hill Valley",|
421
- beta_line %|+ "city" => "Oakland",|
422
- plain_line %| "state" => "CA",|
423
- alpha_line %|- "zip" => "90382"|
424
- beta_line %|+ "zip" => "91234"|
425
- plain_line %| }>|
396
+ plain_line %| #<HashWithIndifferentAccess {|
397
+ expected_line %|- "line_1" => "123 Main St.",|
398
+ actual_line %|+ "line_1" => "456 Ponderosa Ct.",|
399
+ expected_line %|- "city" => "Hill Valley",|
400
+ actual_line %|+ "city" => "Oakland",|
401
+ plain_line %| "state" => "CA",|
402
+ expected_line %|- "zip" => "90382"|
403
+ actual_line %|+ "zip" => "91234"|
404
+ plain_line %| }>|
426
405
  },
427
406
  )
428
407
 
@@ -443,7 +422,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
443
422
  "state" => "CA",
444
423
  "zip" => "90382",
445
424
  }
446
- actual = HashWithIndifferentAccess.new({
425
+ actual = HashWithIndifferentAccess.new({
447
426
  line_1: "456 Ponderosa Ct.",
448
427
  city: "Oakland",
449
428
  state: "CA",
@@ -451,35 +430,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
451
430
  })
452
431
  expect(actual).to match(expected)
453
432
  TEST
454
- program = make_rspec_rails_test_program(
455
- snippet,
456
- color_enabled: color_enabled,
457
- )
433
+ program = make_program(snippet, color_enabled: color_enabled)
458
434
 
459
435
  expected_output = build_expected_output(
460
436
  color_enabled: color_enabled,
461
437
  snippet: "expect(actual).to match(expected)",
462
438
  expectation: proc {
463
439
  line do
464
- plain "Expected "
465
- beta %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
440
+ plain %|Expected |
441
+ actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
466
442
  end
467
443
 
468
444
  line do
469
- plain "to match "
470
- alpha %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
445
+ plain %|to match |
446
+ expected %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
471
447
  end
472
448
  },
473
449
  diff: proc {
474
- plain_line %| #<HashWithIndifferentAccess {|
475
- alpha_line %|- "line_1" => "123 Main St.",|
476
- beta_line %|+ "line_1" => "456 Ponderosa Ct.",|
477
- alpha_line %|- "city" => "Hill Valley",|
478
- beta_line %|+ "city" => "Oakland",|
479
- plain_line %| "state" => "CA",|
480
- alpha_line %|- "zip" => "90382"|
481
- beta_line %|+ "zip" => "91234"|
482
- plain_line %| }>|
450
+ plain_line %| #<HashWithIndifferentAccess {|
451
+ expected_line %|- "line_1" => "123 Main St.",|
452
+ actual_line %|+ "line_1" => "456 Ponderosa Ct.",|
453
+ expected_line %|- "city" => "Hill Valley",|
454
+ actual_line %|+ "city" => "Oakland",|
455
+ plain_line %| "state" => "CA",|
456
+ expected_line %|- "zip" => "90382"|
457
+ actual_line %|+ "zip" => "91234"|
458
+ plain_line %| }>|
483
459
  },
484
460
  )
485
461
 
@@ -494,7 +470,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
494
470
 
495
471
  context "when the expected value is a HashWithIndifferentAccess" do
496
472
  context "and both hashes are one-dimensional" do
497
- context "and the actual hash contains symbol keys" do
473
+ context "and the actual hash contains symbol keys" do
498
474
  it "produces the correct output" do
499
475
  as_both_colored_and_uncolored do |color_enabled|
500
476
  snippet = <<~TEST.strip
@@ -504,7 +480,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
504
480
  state: "CA",
505
481
  zip: "91234",
506
482
  })
507
- actual = {
483
+ actual = {
508
484
  line_1: "123 Main St.",
509
485
  city: "Hill Valley",
510
486
  state: "CA",
@@ -512,35 +488,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
512
488
  }
513
489
  expect(actual).to match(expected)
514
490
  TEST
515
- program = make_rspec_rails_test_program(
516
- snippet,
517
- color_enabled: color_enabled,
518
- )
491
+ program = make_program(snippet, color_enabled: color_enabled)
519
492
 
520
493
  expected_output = build_expected_output(
521
494
  color_enabled: color_enabled,
522
495
  snippet: "expect(actual).to match(expected)",
523
496
  expectation: proc {
524
497
  line do
525
- plain "Expected "
526
- beta %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
498
+ plain %|Expected |
499
+ actual %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
527
500
  end
528
501
 
529
502
  line do
530
- plain "to match "
531
- alpha %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
503
+ plain %|to match |
504
+ expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
532
505
  end
533
506
  },
534
507
  diff: proc {
535
- plain_line %| #<HashWithIndifferentAccess {|
536
- alpha_line %|- "line_1" => "456 Ponderosa Ct.",|
537
- beta_line %|+ "line_1" => "123 Main St.",|
538
- alpha_line %|- "city" => "Oakland",|
539
- beta_line %|+ "city" => "Hill Valley",|
540
- plain_line %| "state" => "CA",|
541
- alpha_line %|- "zip" => "91234"|
542
- beta_line %|+ "zip" => "90382"|
543
- plain_line %| }>|
508
+ plain_line %| #<HashWithIndifferentAccess {|
509
+ expected_line %|- "line_1" => "456 Ponderosa Ct.",|
510
+ actual_line %|+ "line_1" => "123 Main St.",|
511
+ expected_line %|- "city" => "Oakland",|
512
+ actual_line %|+ "city" => "Hill Valley",|
513
+ plain_line %| "state" => "CA",|
514
+ expected_line %|- "zip" => "91234"|
515
+ actual_line %|+ "zip" => "90382"|
516
+ plain_line %| }>|
544
517
  },
545
518
  )
546
519
 
@@ -551,7 +524,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
551
524
  end
552
525
  end
553
526
 
554
- context "and the actual hash contains string keys" do
527
+ context "and the actual hash contains string keys" do
555
528
  it "produces the correct output" do
556
529
  as_both_colored_and_uncolored do |color_enabled|
557
530
  snippet = <<~TEST.strip
@@ -561,7 +534,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
561
534
  state: "CA",
562
535
  zip: "91234",
563
536
  })
564
- actual = {
537
+ actual = {
565
538
  "line_1" => "123 Main St.",
566
539
  "city" => "Hill Valley",
567
540
  "state" => "CA",
@@ -569,35 +542,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
569
542
  }
570
543
  expect(actual).to match(expected)
571
544
  TEST
572
- program = make_rspec_rails_test_program(
573
- snippet,
574
- color_enabled: color_enabled,
575
- )
545
+ program = make_program(snippet, color_enabled: color_enabled)
576
546
 
577
547
  expected_output = build_expected_output(
578
548
  color_enabled: color_enabled,
579
549
  snippet: "expect(actual).to match(expected)",
580
550
  expectation: proc {
581
551
  line do
582
- plain "Expected "
583
- beta %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
552
+ plain %|Expected |
553
+ actual %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
584
554
  end
585
555
 
586
556
  line do
587
- plain "to match "
588
- alpha %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
557
+ plain %|to match |
558
+ expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
589
559
  end
590
560
  },
591
561
  diff: proc {
592
- plain_line %| #<HashWithIndifferentAccess {|
593
- alpha_line %|- "line_1" => "456 Ponderosa Ct.",|
594
- beta_line %|+ "line_1" => "123 Main St.",|
595
- alpha_line %|- "city" => "Oakland",|
596
- beta_line %|+ "city" => "Hill Valley",|
597
- plain_line %| "state" => "CA",|
598
- alpha_line %|- "zip" => "91234"|
599
- beta_line %|+ "zip" => "90382"|
600
- plain_line %| }>|
562
+ plain_line %| #<HashWithIndifferentAccess {|
563
+ expected_line %|- "line_1" => "456 Ponderosa Ct.",|
564
+ actual_line %|+ "line_1" => "123 Main St.",|
565
+ expected_line %|- "city" => "Oakland",|
566
+ actual_line %|+ "city" => "Hill Valley",|
567
+ plain_line %| "state" => "CA",|
568
+ expected_line %|- "zip" => "91234"|
569
+ actual_line %|+ "zip" => "90382"|
570
+ plain_line %| }>|
601
571
  },
602
572
  )
603
573
 
@@ -610,7 +580,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
610
580
  end
611
581
 
612
582
  context "and both hashes are multi-dimensional" do
613
- context "and the actual hash contains symbol keys" do
583
+ context "and the actual hash contains symbol keys" do
614
584
  it "produces the correct output" do
615
585
  as_both_colored_and_uncolored do |color_enabled|
616
586
  snippet = <<~TEST.strip
@@ -624,7 +594,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
624
594
  })
625
595
  ]
626
596
  })
627
- actual = {
597
+ actual = {
628
598
  shipments: [
629
599
  {
630
600
  estimated_delivery: {
@@ -636,37 +606,34 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
636
606
  }
637
607
  expect(actual).to match(expected)
638
608
  TEST
639
- program = make_rspec_rails_test_program(
640
- snippet,
641
- color_enabled: color_enabled,
642
- )
609
+ program = make_program(snippet, color_enabled: color_enabled)
643
610
 
644
611
  expected_output = build_expected_output(
645
612
  color_enabled: color_enabled,
646
613
  snippet: "expect(actual).to match(expected)",
647
614
  expectation: proc {
648
615
  line do
649
- plain "Expected "
650
- beta %|{ shipments: [{ estimated_delivery: { from: "2019-05-06", to: "2019-05-09" } }] }|
616
+ plain %|Expected |
617
+ actual %|{ shipments: [{ estimated_delivery: { from: "2019-05-06", to: "2019-05-09" } }] }|
651
618
  end
652
619
 
653
620
  line do
654
- plain "to match "
655
- alpha %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
621
+ plain %|to match |
622
+ expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
656
623
  end
657
624
  },
658
625
  diff: proc {
659
- plain_line %| #<HashWithIndifferentAccess {|
660
- plain_line %| "shipments" => [|
661
- plain_line %| {|
662
- plain_line %| "estimated_delivery" => {|
663
- plain_line %| "from" => "2019-05-06",|
664
- alpha_line %|- "to" => "2019-05-06"|
665
- beta_line %|+ "to" => "2019-05-09"|
666
- plain_line %| }|
667
- plain_line %| }|
668
- plain_line %| ]|
669
- plain_line %| }>|
626
+ plain_line %| #<HashWithIndifferentAccess {|
627
+ plain_line %| "shipments" => [|
628
+ plain_line %| #<HashWithIndifferentAccess {|
629
+ plain_line %| "estimated_delivery" => #<HashWithIndifferentAccess {|
630
+ plain_line %| "from" => "2019-05-06",|
631
+ expected_line %|- "to" => "2019-05-06"|
632
+ actual_line %|+ "to" => "2019-05-09"|
633
+ plain_line %| }>|
634
+ plain_line %| }>|
635
+ plain_line %| ]|
636
+ plain_line %| }>|
670
637
  },
671
638
  )
672
639
 
@@ -677,7 +644,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
677
644
  end
678
645
  end
679
646
 
680
- context "and the actual hash contains string keys" do
647
+ context "and the actual hash contains string keys" do
681
648
  it "produces the correct output" do
682
649
  as_both_colored_and_uncolored do |color_enabled|
683
650
  snippet = <<~TEST.strip
@@ -691,7 +658,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
691
658
  })
692
659
  ]
693
660
  })
694
- actual = {
661
+ actual = {
695
662
  'shipments' => [
696
663
  {
697
664
  'estimated_delivery' => {
@@ -703,37 +670,34 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
703
670
  }
704
671
  expect(actual).to match(expected)
705
672
  TEST
706
- program = make_rspec_rails_test_program(
707
- snippet,
708
- color_enabled: color_enabled,
709
- )
673
+ program = make_program(snippet, color_enabled: color_enabled)
710
674
 
711
675
  expected_output = build_expected_output(
712
676
  color_enabled: color_enabled,
713
677
  snippet: "expect(actual).to match(expected)",
714
678
  expectation: proc {
715
679
  line do
716
- plain "Expected "
717
- beta %|{ "shipments" => [{ "estimated_delivery" => { "from" => "2019-05-06", "to" => "2019-05-09" } }] }|
680
+ plain %|Expected |
681
+ actual %|{ "shipments" => [{ "estimated_delivery" => { "from" => "2019-05-06", "to" => "2019-05-09" } }] }|
718
682
  end
719
683
 
720
684
  line do
721
- plain "to match "
722
- alpha %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
685
+ plain %|to match |
686
+ expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
723
687
  end
724
688
  },
725
689
  diff: proc {
726
- plain_line %| #<HashWithIndifferentAccess {|
727
- plain_line %| "shipments" => [|
728
- plain_line %| {|
729
- plain_line %| "estimated_delivery" => {|
730
- plain_line %| "from" => "2019-05-06",|
731
- alpha_line %|- "to" => "2019-05-06"|
732
- beta_line %|+ "to" => "2019-05-09"|
733
- plain_line %| }|
734
- plain_line %| }|
735
- plain_line %| ]|
736
- plain_line %| }>|
690
+ plain_line %| #<HashWithIndifferentAccess {|
691
+ plain_line %| "shipments" => [|
692
+ plain_line %| #<HashWithIndifferentAccess {|
693
+ plain_line %| "estimated_delivery" => #<HashWithIndifferentAccess {|
694
+ plain_line %| "from" => "2019-05-06",|
695
+ expected_line %|- "to" => "2019-05-06"|
696
+ actual_line %|+ "to" => "2019-05-09"|
697
+ plain_line %| }>|
698
+ plain_line %| }>|
699
+ plain_line %| ]|
700
+ plain_line %| }>|
737
701
  },
738
702
  )
739
703