super_diff 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +65 -26
  3. data/lib/super_diff/active_record/differs/active_record_relation.rb +1 -2
  4. data/lib/super_diff/active_record/differs.rb +1 -1
  5. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +5 -13
  6. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +1 -3
  7. data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +2 -2
  8. data/lib/super_diff/active_record/object_inspection.rb +1 -1
  9. data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +1 -2
  10. data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +1 -2
  11. data/lib/super_diff/active_record/operation_tree_builders.rb +2 -2
  12. data/lib/super_diff/active_record/operation_tree_flatteners.rb +1 -1
  13. data/lib/super_diff/active_record/operation_trees.rb +1 -1
  14. data/lib/super_diff/active_record.rb +7 -15
  15. data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +5 -6
  16. data/lib/super_diff/active_support/differs.rb +1 -1
  17. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +3 -9
  18. data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +1 -1
  19. data/lib/super_diff/active_support/object_inspection.rb +1 -1
  20. data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +5 -6
  21. data/lib/super_diff/active_support/operation_tree_builders.rb +1 -1
  22. data/lib/super_diff/active_support/operation_tree_flatteners.rb +1 -1
  23. data/lib/super_diff/active_support/operation_trees.rb +1 -1
  24. data/lib/super_diff/active_support.rb +6 -11
  25. data/lib/super_diff/colorized_document_extensions.rb +2 -4
  26. data/lib/super_diff/configuration.rb +14 -8
  27. data/lib/super_diff/csi/color.rb +4 -4
  28. data/lib/super_diff/csi/colorized_document.rb +12 -16
  29. data/lib/super_diff/csi/document.rb +8 -19
  30. data/lib/super_diff/csi/eight_bit_color.rb +19 -19
  31. data/lib/super_diff/csi/four_bit_color.rb +82 -31
  32. data/lib/super_diff/csi/twenty_four_bit_color.rb +12 -11
  33. data/lib/super_diff/csi/uncolorized_document.rb +2 -6
  34. data/lib/super_diff/csi.rb +10 -14
  35. data/lib/super_diff/diff_formatters/collection.rb +35 -41
  36. data/lib/super_diff/differs/default_object.rb +1 -1
  37. data/lib/super_diff/differs/defaults.rb +1 -1
  38. data/lib/super_diff/differs/main.rb +2 -13
  39. data/lib/super_diff/equality_matchers/array.rb +10 -12
  40. data/lib/super_diff/equality_matchers/base.rb +1 -1
  41. data/lib/super_diff/equality_matchers/default.rb +2 -4
  42. data/lib/super_diff/equality_matchers/defaults.rb +1 -1
  43. data/lib/super_diff/equality_matchers/hash.rb +10 -12
  44. data/lib/super_diff/equality_matchers/multiline_string.rb +11 -13
  45. data/lib/super_diff/equality_matchers/primitive.rb +10 -12
  46. data/lib/super_diff/equality_matchers/singleline_string.rb +10 -12
  47. data/lib/super_diff/equality_matchers.rb +1 -1
  48. data/lib/super_diff/errors.rb +3 -3
  49. data/lib/super_diff/gem_version.rb +3 -3
  50. data/lib/super_diff/helpers.rb +10 -10
  51. data/lib/super_diff/implementation_checks.rb +2 -2
  52. data/lib/super_diff/line.rb +3 -3
  53. data/lib/super_diff/object_inspection/inspection_tree.rb +46 -60
  54. data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +2 -6
  55. data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +3 -9
  56. data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +5 -14
  57. data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +1 -1
  58. data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +4 -12
  59. data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +6 -23
  60. data/lib/super_diff/object_inspection/inspection_tree_builders.rb +9 -9
  61. data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +8 -20
  62. data/lib/super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines.rb +1 -5
  63. data/lib/super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines.rb +1 -5
  64. data/lib/super_diff/object_inspection/nodes/as_single_line.rb +3 -7
  65. data/lib/super_diff/object_inspection/nodes/base.rb +9 -14
  66. data/lib/super_diff/object_inspection/nodes/inspection.rb +26 -34
  67. data/lib/super_diff/object_inspection/nodes/nesting.rb +1 -1
  68. data/lib/super_diff/object_inspection/nodes/only_when.rb +2 -6
  69. data/lib/super_diff/object_inspection/nodes/text.rb +1 -5
  70. data/lib/super_diff/object_inspection/nodes/when_empty.rb +2 -6
  71. data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +2 -6
  72. data/lib/super_diff/object_inspection/nodes/when_rendering_to_lines.rb +1 -1
  73. data/lib/super_diff/object_inspection/nodes/when_rendering_to_string.rb +1 -5
  74. data/lib/super_diff/object_inspection/nodes.rb +7 -7
  75. data/lib/super_diff/object_inspection.rb +3 -3
  76. data/lib/super_diff/operation_tree_builders/array.rb +12 -11
  77. data/lib/super_diff/operation_tree_builders/base.rb +17 -15
  78. data/lib/super_diff/operation_tree_builders/custom_object.rb +8 -6
  79. data/lib/super_diff/operation_tree_builders/default_object.rb +29 -21
  80. data/lib/super_diff/operation_tree_builders/hash.rb +23 -24
  81. data/lib/super_diff/operation_tree_builders/main.rb +4 -11
  82. data/lib/super_diff/operation_tree_builders/multiline_string.rb +3 -3
  83. data/lib/super_diff/operation_tree_builders/time_like.rb +1 -11
  84. data/lib/super_diff/operation_tree_builders.rb +1 -1
  85. data/lib/super_diff/operation_tree_flatteners/base.rb +1 -5
  86. data/lib/super_diff/operation_tree_flatteners/collection.rb +13 -16
  87. data/lib/super_diff/operation_tree_flatteners/default_object.rb +1 -2
  88. data/lib/super_diff/operation_tree_flatteners/hash.rb +2 -10
  89. data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +2 -1
  90. data/lib/super_diff/operation_tree_flatteners.rb +3 -3
  91. data/lib/super_diff/operation_trees/base.rb +3 -5
  92. data/lib/super_diff/operation_trees/default_object.rb +1 -3
  93. data/lib/super_diff/operations/binary_operation.rb +2 -2
  94. data/lib/super_diff/operations/unary_operation.rb +1 -1
  95. data/lib/super_diff/rails.rb +2 -1
  96. data/lib/super_diff/recursion_guard.rb +5 -4
  97. data/lib/super_diff/rspec/augmented_matcher.rb +4 -5
  98. data/lib/super_diff/rspec/differ.rb +6 -13
  99. data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +3 -2
  100. data/lib/super_diff/rspec/differs/collection_including.rb +1 -1
  101. data/lib/super_diff/rspec/differs/hash_including.rb +1 -1
  102. data/lib/super_diff/rspec/differs.rb +3 -3
  103. data/lib/super_diff/rspec/matcher_text_builders/base.rb +13 -15
  104. data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +5 -7
  105. data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +3 -5
  106. data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +1 -5
  107. data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +2 -6
  108. data/lib/super_diff/rspec/matcher_text_builders.rb +5 -8
  109. data/lib/super_diff/rspec/matcher_text_template.rb +13 -16
  110. data/lib/super_diff/rspec/monkey_patches.rb +122 -116
  111. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +8 -6
  112. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +11 -16
  113. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +2 -1
  114. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +8 -6
  115. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +8 -6
  116. data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +9 -9
  117. data/lib/super_diff/rspec/object_inspection.rb +1 -1
  118. data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +11 -10
  119. data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +7 -6
  120. data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +11 -10
  121. data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +22 -17
  122. data/lib/super_diff/rspec/operation_tree_builders.rb +4 -4
  123. data/lib/super_diff/rspec.rb +11 -13
  124. data/lib/super_diff/tiered_lines_elider.rb +87 -115
  125. data/lib/super_diff/tiered_lines_formatter.rb +5 -9
  126. data/lib/super_diff/version.rb +1 -1
  127. data/lib/super_diff.rb +4 -9
  128. data/spec/examples.txt +493 -485
  129. data/spec/integration/rails/active_record_spec.rb +3 -1
  130. data/spec/integration/rails/engines_spec.rb +20 -0
  131. data/spec/integration/rails/hash_with_indifferent_access_spec.rb +3 -1
  132. data/spec/integration/rspec/be_falsey_matcher_spec.rb +40 -35
  133. data/spec/integration/rspec/be_matcher_spec.rb +360 -320
  134. data/spec/integration/rspec/be_nil_matcher_spec.rb +38 -34
  135. data/spec/integration/rspec/be_predicate_matcher_spec.rb +376 -359
  136. data/spec/integration/rspec/be_truthy_matcher_spec.rb +38 -33
  137. data/spec/integration/rspec/contain_exactly_matcher_spec.rb +242 -239
  138. data/spec/integration/rspec/eq_matcher_spec.rb +595 -557
  139. data/spec/integration/rspec/have_attributes_matcher_spec.rb +294 -286
  140. data/spec/integration/rspec/have_predicate_matcher_spec.rb +291 -297
  141. data/spec/integration/rspec/include_matcher_spec.rb +317 -215
  142. data/spec/integration/rspec/match_array_matcher_spec.rb +276 -273
  143. data/spec/integration/rspec/match_matcher_spec.rb +847 -834
  144. data/spec/integration/rspec/raise_error_matcher_spec.rb +468 -453
  145. data/spec/integration/rspec/respond_to_matcher_spec.rb +702 -697
  146. data/spec/integration/rspec/third_party_matcher_spec.rb +142 -138
  147. data/spec/integration/rspec/unhandled_errors_spec.rb +88 -84
  148. data/spec/spec_helper.rb +17 -20
  149. data/spec/support/command_runner.rb +34 -57
  150. data/spec/support/integration/helpers.rb +35 -28
  151. data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +28 -23
  152. data/spec/support/integration/test_programs/base.rb +12 -17
  153. data/spec/support/integration/test_programs/plain.rb +6 -0
  154. data/spec/support/integration/test_programs/rspec_active_record.rb +4 -1
  155. data/spec/support/integration/test_programs/rspec_active_support.rb +4 -1
  156. data/spec/support/integration/test_programs/rspec_rails.rb +4 -1
  157. data/spec/support/integration/test_programs/rspec_rails_engine.rb +30 -0
  158. data/spec/support/models/active_record/person.rb +6 -4
  159. data/spec/support/models/active_record/shipping_address.rb +9 -10
  160. data/spec/support/models/customer.rb +2 -4
  161. data/spec/support/models/player.rb +3 -6
  162. data/spec/support/models/shipping_address.rb +4 -13
  163. data/spec/support/shared_examples/active_record.rb +232 -214
  164. data/spec/support/shared_examples/active_support.rb +53 -51
  165. data/spec/support/shared_examples/elided_diffs.rb +405 -381
  166. data/spec/support/shared_examples/hash_with_indifferent_access.rb +424 -388
  167. data/spec/support/shared_examples/key.rb +123 -0
  168. data/spec/support/unit/helpers.rb +1 -3
  169. data/spec/support/unit/matchers/match_output.rb +12 -13
  170. data/spec/unit/active_record/object_inspection_spec.rb +222 -206
  171. data/spec/unit/equality_matchers/main_spec.rb +1049 -984
  172. data/spec/unit/helpers_spec.rb +14 -21
  173. data/spec/unit/operation_tree_flatteners/array_spec.rb +557 -524
  174. data/spec/unit/operation_tree_flatteners/custom_object_spec.rb +619 -601
  175. data/spec/unit/operation_tree_flatteners/default_object_spec.rb +619 -621
  176. data/spec/unit/operation_tree_flatteners/hash_spec.rb +595 -556
  177. data/spec/unit/operation_tree_flatteners/multiline_string_spec.rb +102 -92
  178. data/spec/unit/rspec/matchers/be_compared_to_spec.rb +3 -3
  179. data/spec/unit/rspec/matchers/be_predicate_spec.rb +3 -3
  180. data/spec/unit/rspec/matchers/contain_exactly_spec.rb +1 -1
  181. data/spec/unit/rspec/matchers/have_attributes_spec.rb +1 -1
  182. data/spec/unit/rspec/matchers/have_predicate_spec.rb +2 -2
  183. data/spec/unit/rspec/matchers/include_spec.rb +2 -2
  184. data/spec/unit/rspec/matchers/match_array_spec.rb +2 -2
  185. data/spec/unit/rspec/matchers/raise_error_spec.rb +5 -5
  186. data/spec/unit/rspec/matchers/respond_to_spec.rb +23 -16
  187. data/spec/unit/rspec/object_inspection_spec.rb +349 -324
  188. data/spec/unit/super_diff_spec.rb +1542 -1449
  189. data/spec/unit/tiered_lines_elider_spec.rb +3508 -3536
  190. data/spec/unit/tiered_lines_formatter_spec.rb +54 -116
  191. data/super_diff.gemspec +13 -12
  192. metadata +73 -73
  193. data/spec/tmp/warnings_logger/all_warnings.txt +0 -2
@@ -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",
@@ -22,36 +22,39 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
22
22
  TEST
23
23
  program = make_program(snippet, color_enabled: color_enabled)
24
24
 
25
- expected_output = build_expected_output(
26
- color_enabled: color_enabled,
27
- snippet: "expect(actual).to eq(expected)",
28
- expectation: proc {
29
- line do
30
- plain %|Expected |
31
- actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
32
- end
33
-
34
- line do
35
- plain %| to eq |
36
- expected %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
37
- end
38
- },
39
- diff: proc {
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 %| }>|
49
- },
50
- )
51
-
52
- expect(program).
53
- to produce_output_when_run(expected_output).
54
- in_color(color_enabled)
25
+ expected_output =
26
+ build_expected_output(
27
+ color_enabled: color_enabled,
28
+ snippet: "expect(actual).to eq(expected)",
29
+ expectation:
30
+ proc do
31
+ line do
32
+ plain "Expected "
33
+ actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
34
+ end
35
+
36
+ line do
37
+ plain " to eq "
38
+ expected %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
39
+ end
40
+ end,
41
+ diff:
42
+ proc do
43
+ plain_line " #<HashWithIndifferentAccess {"
44
+ expected_line %|- "line_1" => "123 Main St.",|
45
+ actual_line %|+ "line_1" => "456 Ponderosa Ct.",|
46
+ expected_line %|- "city" => "Hill Valley",|
47
+ actual_line %|+ "city" => "Oakland",|
48
+ plain_line %| "state" => "CA",|
49
+ expected_line %|- "zip" => "90382"|
50
+ actual_line %|+ "zip" => "91234"|
51
+ plain_line " }>"
52
+ end
53
+ )
54
+
55
+ expect(program).to produce_output_when_run(
56
+ expected_output
57
+ ).in_color(color_enabled)
55
58
  end
56
59
  end
57
60
  end
@@ -66,7 +69,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
66
69
  "state" => "CA",
67
70
  "zip" => "90382",
68
71
  }
69
- actual = HashWithIndifferentAccess.new({
72
+ actual = HashWithIndifferentAccess.new({
70
73
  line_1: "456 Ponderosa Ct.",
71
74
  city: "Oakland",
72
75
  state: "CA",
@@ -76,36 +79,39 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
76
79
  TEST
77
80
  program = make_program(snippet, color_enabled: color_enabled)
78
81
 
79
- expected_output = build_expected_output(
80
- color_enabled: color_enabled,
81
- snippet: "expect(actual).to eq(expected)",
82
- expectation: proc {
83
- line do
84
- plain %|Expected |
85
- actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
86
- end
87
-
88
- line do
89
- plain %| to eq |
90
- expected %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
91
- end
92
- },
93
- diff: proc {
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 %| }>|
103
- },
104
- )
105
-
106
- expect(program).
107
- to produce_output_when_run(expected_output).
108
- in_color(color_enabled)
82
+ expected_output =
83
+ build_expected_output(
84
+ color_enabled: color_enabled,
85
+ snippet: "expect(actual).to eq(expected)",
86
+ expectation:
87
+ proc do
88
+ line do
89
+ plain "Expected "
90
+ actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
91
+ end
92
+
93
+ line do
94
+ plain " to eq "
95
+ expected %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
96
+ end
97
+ end,
98
+ diff:
99
+ proc do
100
+ plain_line " #<HashWithIndifferentAccess {"
101
+ expected_line %|- "line_1" => "123 Main St.",|
102
+ actual_line %|+ "line_1" => "456 Ponderosa Ct.",|
103
+ expected_line %|- "city" => "Hill Valley",|
104
+ actual_line %|+ "city" => "Oakland",|
105
+ plain_line %| "state" => "CA",|
106
+ expected_line %|- "zip" => "90382"|
107
+ actual_line %|+ "zip" => "91234"|
108
+ plain_line " }>"
109
+ end
110
+ )
111
+
112
+ expect(program).to produce_output_when_run(
113
+ expected_output
114
+ ).in_color(color_enabled)
109
115
  end
110
116
  end
111
117
  end
@@ -124,7 +130,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
124
130
  state: "CA",
125
131
  zip: "91234",
126
132
  })
127
- actual = {
133
+ actual = {
128
134
  line_1: "123 Main St.",
129
135
  city: "Hill Valley",
130
136
  state: "CA",
@@ -134,41 +140,44 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
134
140
  TEST
135
141
  program = make_program(snippet, color_enabled: color_enabled)
136
142
 
137
- expected_output = build_expected_output(
138
- color_enabled: color_enabled,
139
- snippet: "expect(actual).to eq(expected)",
140
- expectation: proc {
141
- line do
142
- plain %|Expected |
143
- actual %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
144
- end
145
-
146
- line do
147
- plain %| to eq |
148
- expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
149
- end
150
- },
151
- diff: proc {
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 %| }>|
161
- },
162
- )
163
-
164
- expect(program).
165
- to produce_output_when_run(expected_output).
166
- in_color(color_enabled)
143
+ expected_output =
144
+ build_expected_output(
145
+ color_enabled: color_enabled,
146
+ snippet: "expect(actual).to eq(expected)",
147
+ expectation:
148
+ proc do
149
+ line do
150
+ plain "Expected "
151
+ actual %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
152
+ end
153
+
154
+ line do
155
+ plain " to eq "
156
+ expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
157
+ end
158
+ end,
159
+ diff:
160
+ proc do
161
+ plain_line " #<HashWithIndifferentAccess {"
162
+ expected_line %|- "line_1" => "456 Ponderosa Ct.",|
163
+ actual_line %|+ "line_1" => "123 Main St.",|
164
+ expected_line %|- "city" => "Oakland",|
165
+ actual_line %|+ "city" => "Hill Valley",|
166
+ plain_line %| "state" => "CA",|
167
+ expected_line %|- "zip" => "91234"|
168
+ actual_line %|+ "zip" => "90382"|
169
+ plain_line " }>"
170
+ end
171
+ )
172
+
173
+ expect(program).to produce_output_when_run(
174
+ expected_output
175
+ ).in_color(color_enabled)
167
176
  end
168
177
  end
169
178
  end
170
179
 
171
- context "and the actual hash contains string keys" do
180
+ context "and the actual hash contains string keys" do
172
181
  it "produces the correct output" do
173
182
  as_both_colored_and_uncolored do |color_enabled|
174
183
  snippet = <<~TEST.strip
@@ -178,7 +187,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
178
187
  state: "CA",
179
188
  zip: "91234",
180
189
  })
181
- actual = {
190
+ actual = {
182
191
  "line_1" => "123 Main St.",
183
192
  "city" => "Hill Valley",
184
193
  "state" => "CA",
@@ -188,36 +197,39 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
188
197
  TEST
189
198
  program = make_program(snippet, color_enabled: color_enabled)
190
199
 
191
- expected_output = build_expected_output(
192
- color_enabled: color_enabled,
193
- snippet: "expect(actual).to eq(expected)",
194
- expectation: proc {
195
- line do
196
- plain %|Expected |
197
- actual %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
198
- end
199
-
200
- line do
201
- plain %| to eq |
202
- expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
203
- end
204
- },
205
- diff: proc {
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 %| }>|
215
- },
216
- )
217
-
218
- expect(program).
219
- to produce_output_when_run(expected_output).
220
- in_color(color_enabled)
200
+ expected_output =
201
+ build_expected_output(
202
+ color_enabled: color_enabled,
203
+ snippet: "expect(actual).to eq(expected)",
204
+ expectation:
205
+ proc do
206
+ line do
207
+ plain "Expected "
208
+ actual %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
209
+ end
210
+
211
+ line do
212
+ plain " to eq "
213
+ expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
214
+ end
215
+ end,
216
+ diff:
217
+ proc do
218
+ plain_line " #<HashWithIndifferentAccess {"
219
+ expected_line %|- "line_1" => "456 Ponderosa Ct.",|
220
+ actual_line %|+ "line_1" => "123 Main St.",|
221
+ expected_line %|- "city" => "Oakland",|
222
+ actual_line %|+ "city" => "Hill Valley",|
223
+ plain_line %| "state" => "CA",|
224
+ expected_line %|- "zip" => "91234"|
225
+ actual_line %|+ "zip" => "90382"|
226
+ plain_line " }>"
227
+ end
228
+ )
229
+
230
+ expect(program).to produce_output_when_run(
231
+ expected_output
232
+ ).in_color(color_enabled)
221
233
  end
222
234
  end
223
235
  end
@@ -238,7 +250,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
238
250
  })
239
251
  ]
240
252
  })
241
- actual = {
253
+ actual = {
242
254
  shipments: [
243
255
  {
244
256
  estimated_delivery: {
@@ -252,43 +264,46 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
252
264
  TEST
253
265
  program = make_program(snippet, color_enabled: color_enabled)
254
266
 
255
- expected_output = build_expected_output(
256
- color_enabled: color_enabled,
257
- snippet: "expect(actual).to eq(expected)",
258
- expectation: proc {
259
- line do
260
- plain %|Expected |
261
- actual %|{ shipments: [{ estimated_delivery: { from: "2019-05-06", to: "2019-05-09" } }] }|
262
- end
263
-
264
- line do
265
- plain %| to eq |
266
- expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
267
- end
268
- },
269
- diff: proc {
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 %| }>|
281
- },
282
- )
283
-
284
- expect(program).
285
- to produce_output_when_run(expected_output).
286
- in_color(color_enabled)
267
+ expected_output =
268
+ build_expected_output(
269
+ color_enabled: color_enabled,
270
+ snippet: "expect(actual).to eq(expected)",
271
+ expectation:
272
+ proc do
273
+ line do
274
+ plain "Expected "
275
+ actual %|{ shipments: [{ estimated_delivery: { from: "2019-05-06", to: "2019-05-09" } }] }|
276
+ end
277
+
278
+ line do
279
+ plain " to eq "
280
+ expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
281
+ end
282
+ end,
283
+ diff:
284
+ proc do
285
+ plain_line " #<HashWithIndifferentAccess {"
286
+ plain_line %| "shipments" => [|
287
+ plain_line " #<HashWithIndifferentAccess {"
288
+ plain_line %| "estimated_delivery" => #<HashWithIndifferentAccess {|
289
+ plain_line %| "from" => "2019-05-06",|
290
+ expected_line %|- "to" => "2019-05-06"|
291
+ actual_line %|+ "to" => "2019-05-09"|
292
+ plain_line " }>"
293
+ plain_line " }>"
294
+ plain_line " ]"
295
+ plain_line " }>"
296
+ end
297
+ )
298
+
299
+ expect(program).to produce_output_when_run(
300
+ expected_output
301
+ ).in_color(color_enabled)
287
302
  end
288
303
  end
289
304
  end
290
305
 
291
- context "and the actual hash contains string keys" do
306
+ context "and the actual hash contains string keys" do
292
307
  it "produces the correct output" do
293
308
  as_both_colored_and_uncolored do |color_enabled|
294
309
  snippet = <<~TEST.strip
@@ -302,7 +317,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
302
317
  })
303
318
  ]
304
319
  })
305
- actual = {
320
+ actual = {
306
321
  'shipments' => [
307
322
  {
308
323
  'estimated_delivery' => {
@@ -316,38 +331,41 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
316
331
  TEST
317
332
  program = make_program(snippet, color_enabled: color_enabled)
318
333
 
319
- expected_output = build_expected_output(
320
- color_enabled: color_enabled,
321
- snippet: "expect(actual).to eq(expected)",
322
- expectation: proc {
323
- line do
324
- plain %|Expected |
325
- actual %|{ "shipments" => [{ "estimated_delivery" => { "from" => "2019-05-06", "to" => "2019-05-09" } }] }|
326
- end
327
-
328
- line do
329
- plain %| to eq |
330
- expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
331
- end
332
- },
333
- diff: proc {
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 %| }>|
345
- },
346
- )
347
-
348
- expect(program).
349
- to produce_output_when_run(expected_output).
350
- in_color(color_enabled)
334
+ expected_output =
335
+ build_expected_output(
336
+ color_enabled: color_enabled,
337
+ snippet: "expect(actual).to eq(expected)",
338
+ expectation:
339
+ proc do
340
+ line do
341
+ plain "Expected "
342
+ actual %|{ "shipments" => [{ "estimated_delivery" => { "from" => "2019-05-06", "to" => "2019-05-09" } }] }|
343
+ end
344
+
345
+ line do
346
+ plain " to eq "
347
+ expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
348
+ end
349
+ end,
350
+ diff:
351
+ proc do
352
+ plain_line " #<HashWithIndifferentAccess {"
353
+ plain_line %| "shipments" => [|
354
+ plain_line " #<HashWithIndifferentAccess {"
355
+ plain_line %| "estimated_delivery" => #<HashWithIndifferentAccess {|
356
+ plain_line %| "from" => "2019-05-06",|
357
+ expected_line %|- "to" => "2019-05-06"|
358
+ actual_line %|+ "to" => "2019-05-09"|
359
+ plain_line " }>"
360
+ plain_line " }>"
361
+ plain_line " ]"
362
+ plain_line " }>"
363
+ end
364
+ )
365
+
366
+ expect(program).to produce_output_when_run(
367
+ expected_output
368
+ ).in_color(color_enabled)
351
369
  end
352
370
  end
353
371
  end
@@ -356,7 +374,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
356
374
  end
357
375
 
358
376
  describe "and RSpec's #match matcher" do
359
- context "when the actual value is a HashWithIndifferentAccess" do
377
+ context "when the actual value is a HashWithIndifferentAccess" do
360
378
  context "and both hashes are one-dimensional" do
361
379
  context "and the expected hash contains symbol keys" do
362
380
  it "produces the correct output" do
@@ -368,7 +386,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
368
386
  state: "CA",
369
387
  zip: "90382",
370
388
  }
371
- actual = HashWithIndifferentAccess.new({
389
+ actual = HashWithIndifferentAccess.new({
372
390
  line_1: "456 Ponderosa Ct.",
373
391
  city: "Oakland",
374
392
  state: "CA",
@@ -378,36 +396,39 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
378
396
  TEST
379
397
  program = make_program(snippet, color_enabled: color_enabled)
380
398
 
381
- expected_output = build_expected_output(
382
- color_enabled: color_enabled,
383
- snippet: "expect(actual).to match(expected)",
384
- expectation: proc {
385
- line do
386
- plain %|Expected |
387
- actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
388
- end
389
-
390
- line do
391
- plain %|to match |
392
- expected %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
393
- end
394
- },
395
- diff: proc {
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 %| }>|
405
- },
406
- )
407
-
408
- expect(program).
409
- to produce_output_when_run(expected_output).
410
- in_color(color_enabled)
399
+ expected_output =
400
+ build_expected_output(
401
+ color_enabled: color_enabled,
402
+ snippet: "expect(actual).to match(expected)",
403
+ expectation:
404
+ proc do
405
+ line do
406
+ plain "Expected "
407
+ actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
408
+ end
409
+
410
+ line do
411
+ plain "to match "
412
+ expected %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
413
+ end
414
+ end,
415
+ diff:
416
+ proc do
417
+ plain_line " #<HashWithIndifferentAccess {"
418
+ expected_line %|- "line_1" => "123 Main St.",|
419
+ actual_line %|+ "line_1" => "456 Ponderosa Ct.",|
420
+ expected_line %|- "city" => "Hill Valley",|
421
+ actual_line %|+ "city" => "Oakland",|
422
+ plain_line %| "state" => "CA",|
423
+ expected_line %|- "zip" => "90382"|
424
+ actual_line %|+ "zip" => "91234"|
425
+ plain_line " }>"
426
+ end
427
+ )
428
+
429
+ expect(program).to produce_output_when_run(
430
+ expected_output
431
+ ).in_color(color_enabled)
411
432
  end
412
433
  end
413
434
  end
@@ -422,7 +443,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
422
443
  "state" => "CA",
423
444
  "zip" => "90382",
424
445
  }
425
- actual = HashWithIndifferentAccess.new({
446
+ actual = HashWithIndifferentAccess.new({
426
447
  line_1: "456 Ponderosa Ct.",
427
448
  city: "Oakland",
428
449
  state: "CA",
@@ -432,36 +453,39 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
432
453
  TEST
433
454
  program = make_program(snippet, color_enabled: color_enabled)
434
455
 
435
- expected_output = build_expected_output(
436
- color_enabled: color_enabled,
437
- snippet: "expect(actual).to match(expected)",
438
- expectation: proc {
439
- line do
440
- plain %|Expected |
441
- actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
442
- end
443
-
444
- line do
445
- plain %|to match |
446
- expected %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
447
- end
448
- },
449
- diff: proc {
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 %| }>|
459
- },
460
- )
461
-
462
- expect(program).
463
- to produce_output_when_run(expected_output).
464
- in_color(color_enabled)
456
+ expected_output =
457
+ build_expected_output(
458
+ color_enabled: color_enabled,
459
+ snippet: "expect(actual).to match(expected)",
460
+ expectation:
461
+ proc do
462
+ line do
463
+ plain "Expected "
464
+ actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
465
+ end
466
+
467
+ line do
468
+ plain "to match "
469
+ expected %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
470
+ end
471
+ end,
472
+ diff:
473
+ proc do
474
+ plain_line " #<HashWithIndifferentAccess {"
475
+ expected_line %|- "line_1" => "123 Main St.",|
476
+ actual_line %|+ "line_1" => "456 Ponderosa Ct.",|
477
+ expected_line %|- "city" => "Hill Valley",|
478
+ actual_line %|+ "city" => "Oakland",|
479
+ plain_line %| "state" => "CA",|
480
+ expected_line %|- "zip" => "90382"|
481
+ actual_line %|+ "zip" => "91234"|
482
+ plain_line " }>"
483
+ end
484
+ )
485
+
486
+ expect(program).to produce_output_when_run(
487
+ expected_output
488
+ ).in_color(color_enabled)
465
489
  end
466
490
  end
467
491
  end
@@ -470,7 +494,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
470
494
 
471
495
  context "when the expected value is a HashWithIndifferentAccess" do
472
496
  context "and both hashes are one-dimensional" do
473
- context "and the actual hash contains symbol keys" do
497
+ context "and the actual hash contains symbol keys" do
474
498
  it "produces the correct output" do
475
499
  as_both_colored_and_uncolored do |color_enabled|
476
500
  snippet = <<~TEST.strip
@@ -480,7 +504,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
480
504
  state: "CA",
481
505
  zip: "91234",
482
506
  })
483
- actual = {
507
+ actual = {
484
508
  line_1: "123 Main St.",
485
509
  city: "Hill Valley",
486
510
  state: "CA",
@@ -490,41 +514,44 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
490
514
  TEST
491
515
  program = make_program(snippet, color_enabled: color_enabled)
492
516
 
493
- expected_output = build_expected_output(
494
- color_enabled: color_enabled,
495
- snippet: "expect(actual).to match(expected)",
496
- expectation: proc {
497
- line do
498
- plain %|Expected |
499
- actual %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
500
- end
501
-
502
- line do
503
- plain %|to match |
504
- expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
505
- end
506
- },
507
- diff: proc {
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 %| }>|
517
- },
518
- )
519
-
520
- expect(program).
521
- to produce_output_when_run(expected_output).
522
- in_color(color_enabled)
517
+ expected_output =
518
+ build_expected_output(
519
+ color_enabled: color_enabled,
520
+ snippet: "expect(actual).to match(expected)",
521
+ expectation:
522
+ proc do
523
+ line do
524
+ plain "Expected "
525
+ actual %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
526
+ end
527
+
528
+ line do
529
+ plain "to match "
530
+ expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
531
+ end
532
+ end,
533
+ diff:
534
+ proc do
535
+ plain_line " #<HashWithIndifferentAccess {"
536
+ expected_line %|- "line_1" => "456 Ponderosa Ct.",|
537
+ actual_line %|+ "line_1" => "123 Main St.",|
538
+ expected_line %|- "city" => "Oakland",|
539
+ actual_line %|+ "city" => "Hill Valley",|
540
+ plain_line %| "state" => "CA",|
541
+ expected_line %|- "zip" => "91234"|
542
+ actual_line %|+ "zip" => "90382"|
543
+ plain_line " }>"
544
+ end
545
+ )
546
+
547
+ expect(program).to produce_output_when_run(
548
+ expected_output
549
+ ).in_color(color_enabled)
523
550
  end
524
551
  end
525
552
  end
526
553
 
527
- context "and the actual hash contains string keys" do
554
+ context "and the actual hash contains string keys" do
528
555
  it "produces the correct output" do
529
556
  as_both_colored_and_uncolored do |color_enabled|
530
557
  snippet = <<~TEST.strip
@@ -534,7 +561,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
534
561
  state: "CA",
535
562
  zip: "91234",
536
563
  })
537
- actual = {
564
+ actual = {
538
565
  "line_1" => "123 Main St.",
539
566
  "city" => "Hill Valley",
540
567
  "state" => "CA",
@@ -544,43 +571,46 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
544
571
  TEST
545
572
  program = make_program(snippet, color_enabled: color_enabled)
546
573
 
547
- expected_output = build_expected_output(
548
- color_enabled: color_enabled,
549
- snippet: "expect(actual).to match(expected)",
550
- expectation: proc {
551
- line do
552
- plain %|Expected |
553
- actual %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
554
- end
555
-
556
- line do
557
- plain %|to match |
558
- expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
559
- end
560
- },
561
- diff: proc {
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 %| }>|
571
- },
572
- )
573
-
574
- expect(program).
575
- to produce_output_when_run(expected_output).
576
- in_color(color_enabled)
574
+ expected_output =
575
+ build_expected_output(
576
+ color_enabled: color_enabled,
577
+ snippet: "expect(actual).to match(expected)",
578
+ expectation:
579
+ proc do
580
+ line do
581
+ plain "Expected "
582
+ actual %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
583
+ end
584
+
585
+ line do
586
+ plain "to match "
587
+ expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
588
+ end
589
+ end,
590
+ diff:
591
+ proc do
592
+ plain_line " #<HashWithIndifferentAccess {"
593
+ expected_line %|- "line_1" => "456 Ponderosa Ct.",|
594
+ actual_line %|+ "line_1" => "123 Main St.",|
595
+ expected_line %|- "city" => "Oakland",|
596
+ actual_line %|+ "city" => "Hill Valley",|
597
+ plain_line %| "state" => "CA",|
598
+ expected_line %|- "zip" => "91234"|
599
+ actual_line %|+ "zip" => "90382"|
600
+ plain_line " }>"
601
+ end
602
+ )
603
+
604
+ expect(program).to produce_output_when_run(
605
+ expected_output
606
+ ).in_color(color_enabled)
577
607
  end
578
608
  end
579
609
  end
580
610
  end
581
611
 
582
612
  context "and both hashes are multi-dimensional" do
583
- context "and the actual hash contains symbol keys" do
613
+ context "and the actual hash contains symbol keys" do
584
614
  it "produces the correct output" do
585
615
  as_both_colored_and_uncolored do |color_enabled|
586
616
  snippet = <<~TEST.strip
@@ -594,7 +624,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
594
624
  })
595
625
  ]
596
626
  })
597
- actual = {
627
+ actual = {
598
628
  shipments: [
599
629
  {
600
630
  estimated_delivery: {
@@ -608,43 +638,46 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
608
638
  TEST
609
639
  program = make_program(snippet, color_enabled: color_enabled)
610
640
 
611
- expected_output = build_expected_output(
612
- color_enabled: color_enabled,
613
- snippet: "expect(actual).to match(expected)",
614
- expectation: proc {
615
- line do
616
- plain %|Expected |
617
- actual %|{ shipments: [{ estimated_delivery: { from: "2019-05-06", to: "2019-05-09" } }] }|
618
- end
619
-
620
- line do
621
- plain %|to match |
622
- expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
623
- end
624
- },
625
- diff: proc {
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 %| }>|
637
- },
638
- )
639
-
640
- expect(program).
641
- to produce_output_when_run(expected_output).
642
- in_color(color_enabled)
641
+ expected_output =
642
+ build_expected_output(
643
+ color_enabled: color_enabled,
644
+ snippet: "expect(actual).to match(expected)",
645
+ expectation:
646
+ proc do
647
+ line do
648
+ plain "Expected "
649
+ actual %|{ shipments: [{ estimated_delivery: { from: "2019-05-06", to: "2019-05-09" } }] }|
650
+ end
651
+
652
+ line do
653
+ plain "to match "
654
+ expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
655
+ end
656
+ end,
657
+ diff:
658
+ proc do
659
+ plain_line " #<HashWithIndifferentAccess {"
660
+ plain_line %| "shipments" => [|
661
+ plain_line " #<HashWithIndifferentAccess {"
662
+ plain_line %| "estimated_delivery" => #<HashWithIndifferentAccess {|
663
+ plain_line %| "from" => "2019-05-06",|
664
+ expected_line %|- "to" => "2019-05-06"|
665
+ actual_line %|+ "to" => "2019-05-09"|
666
+ plain_line " }>"
667
+ plain_line " }>"
668
+ plain_line " ]"
669
+ plain_line " }>"
670
+ end
671
+ )
672
+
673
+ expect(program).to produce_output_when_run(
674
+ expected_output
675
+ ).in_color(color_enabled)
643
676
  end
644
677
  end
645
678
  end
646
679
 
647
- context "and the actual hash contains string keys" do
680
+ context "and the actual hash contains string keys" do
648
681
  it "produces the correct output" do
649
682
  as_both_colored_and_uncolored do |color_enabled|
650
683
  snippet = <<~TEST.strip
@@ -658,7 +691,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
658
691
  })
659
692
  ]
660
693
  })
661
- actual = {
694
+ actual = {
662
695
  'shipments' => [
663
696
  {
664
697
  'estimated_delivery' => {
@@ -672,38 +705,41 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
672
705
  TEST
673
706
  program = make_program(snippet, color_enabled: color_enabled)
674
707
 
675
- expected_output = build_expected_output(
676
- color_enabled: color_enabled,
677
- snippet: "expect(actual).to match(expected)",
678
- expectation: proc {
679
- line do
680
- plain %|Expected |
681
- actual %|{ "shipments" => [{ "estimated_delivery" => { "from" => "2019-05-06", "to" => "2019-05-09" } }] }|
682
- end
683
-
684
- line do
685
- plain %|to match |
686
- expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
687
- end
688
- },
689
- diff: proc {
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 %| }>|
701
- },
702
- )
703
-
704
- expect(program).
705
- to produce_output_when_run(expected_output).
706
- in_color(color_enabled)
708
+ expected_output =
709
+ build_expected_output(
710
+ color_enabled: color_enabled,
711
+ snippet: "expect(actual).to match(expected)",
712
+ expectation:
713
+ proc do
714
+ line do
715
+ plain "Expected "
716
+ actual %|{ "shipments" => [{ "estimated_delivery" => { "from" => "2019-05-06", "to" => "2019-05-09" } }] }|
717
+ end
718
+
719
+ line do
720
+ plain "to match "
721
+ expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
722
+ end
723
+ end,
724
+ diff:
725
+ proc do
726
+ plain_line " #<HashWithIndifferentAccess {"
727
+ plain_line %| "shipments" => [|
728
+ plain_line " #<HashWithIndifferentAccess {"
729
+ plain_line %| "estimated_delivery" => #<HashWithIndifferentAccess {|
730
+ plain_line %| "from" => "2019-05-06",|
731
+ expected_line %|- "to" => "2019-05-06"|
732
+ actual_line %|+ "to" => "2019-05-09"|
733
+ plain_line " }>"
734
+ plain_line " }>"
735
+ plain_line " ]"
736
+ plain_line " }>"
737
+ end
738
+ )
739
+
740
+ expect(program).to produce_output_when_run(
741
+ expected_output
742
+ ).in_color(color_enabled)
707
743
  end
708
744
  end
709
745
  end