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.
- checksums.yaml +4 -4
- data/README.md +65 -26
- data/lib/super_diff/active_record/differs/active_record_relation.rb +1 -2
- data/lib/super_diff/active_record/differs.rb +1 -1
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +5 -13
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +1 -3
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders.rb +2 -2
- data/lib/super_diff/active_record/object_inspection.rb +1 -1
- data/lib/super_diff/active_record/operation_tree_builders/active_record_model.rb +1 -2
- data/lib/super_diff/active_record/operation_tree_builders/active_record_relation.rb +1 -2
- data/lib/super_diff/active_record/operation_tree_builders.rb +2 -2
- data/lib/super_diff/active_record/operation_tree_flatteners.rb +1 -1
- data/lib/super_diff/active_record/operation_trees.rb +1 -1
- data/lib/super_diff/active_record.rb +7 -15
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +5 -6
- data/lib/super_diff/active_support/differs.rb +1 -1
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +3 -9
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +1 -1
- data/lib/super_diff/active_support/object_inspection.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_builders/hash_with_indifferent_access.rb +5 -6
- data/lib/super_diff/active_support/operation_tree_builders.rb +1 -1
- data/lib/super_diff/active_support/operation_tree_flatteners.rb +1 -1
- data/lib/super_diff/active_support/operation_trees.rb +1 -1
- data/lib/super_diff/active_support.rb +6 -11
- data/lib/super_diff/colorized_document_extensions.rb +2 -4
- data/lib/super_diff/configuration.rb +14 -8
- data/lib/super_diff/csi/color.rb +4 -4
- data/lib/super_diff/csi/colorized_document.rb +12 -16
- data/lib/super_diff/csi/document.rb +8 -19
- data/lib/super_diff/csi/eight_bit_color.rb +19 -19
- data/lib/super_diff/csi/four_bit_color.rb +82 -31
- data/lib/super_diff/csi/twenty_four_bit_color.rb +12 -11
- data/lib/super_diff/csi/uncolorized_document.rb +2 -6
- data/lib/super_diff/csi.rb +10 -14
- data/lib/super_diff/diff_formatters/collection.rb +35 -41
- data/lib/super_diff/differs/default_object.rb +1 -1
- data/lib/super_diff/differs/defaults.rb +1 -1
- data/lib/super_diff/differs/main.rb +2 -13
- data/lib/super_diff/equality_matchers/array.rb +10 -12
- data/lib/super_diff/equality_matchers/base.rb +1 -1
- data/lib/super_diff/equality_matchers/default.rb +2 -4
- data/lib/super_diff/equality_matchers/defaults.rb +1 -1
- data/lib/super_diff/equality_matchers/hash.rb +10 -12
- data/lib/super_diff/equality_matchers/multiline_string.rb +11 -13
- data/lib/super_diff/equality_matchers/primitive.rb +10 -12
- data/lib/super_diff/equality_matchers/singleline_string.rb +10 -12
- data/lib/super_diff/equality_matchers.rb +1 -1
- data/lib/super_diff/errors.rb +3 -3
- data/lib/super_diff/gem_version.rb +3 -3
- data/lib/super_diff/helpers.rb +10 -10
- data/lib/super_diff/implementation_checks.rb +2 -2
- data/lib/super_diff/line.rb +3 -3
- data/lib/super_diff/object_inspection/inspection_tree.rb +46 -60
- data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +2 -6
- data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +3 -9
- data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +5 -14
- data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +1 -1
- data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +4 -12
- data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +6 -23
- data/lib/super_diff/object_inspection/inspection_tree_builders.rb +9 -9
- data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +8 -20
- data/lib/super_diff/object_inspection/nodes/as_prefix_when_rendering_to_lines.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/as_prelude_when_rendering_to_lines.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/as_single_line.rb +3 -7
- data/lib/super_diff/object_inspection/nodes/base.rb +9 -14
- data/lib/super_diff/object_inspection/nodes/inspection.rb +26 -34
- data/lib/super_diff/object_inspection/nodes/nesting.rb +1 -1
- data/lib/super_diff/object_inspection/nodes/only_when.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/text.rb +1 -5
- data/lib/super_diff/object_inspection/nodes/when_empty.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/when_non_empty.rb +2 -6
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_lines.rb +1 -1
- data/lib/super_diff/object_inspection/nodes/when_rendering_to_string.rb +1 -5
- data/lib/super_diff/object_inspection/nodes.rb +7 -7
- data/lib/super_diff/object_inspection.rb +3 -3
- data/lib/super_diff/operation_tree_builders/array.rb +12 -11
- data/lib/super_diff/operation_tree_builders/base.rb +17 -15
- data/lib/super_diff/operation_tree_builders/custom_object.rb +8 -6
- data/lib/super_diff/operation_tree_builders/default_object.rb +29 -21
- data/lib/super_diff/operation_tree_builders/hash.rb +23 -24
- data/lib/super_diff/operation_tree_builders/main.rb +4 -11
- data/lib/super_diff/operation_tree_builders/multiline_string.rb +3 -3
- data/lib/super_diff/operation_tree_builders/time_like.rb +1 -11
- data/lib/super_diff/operation_tree_builders.rb +1 -1
- data/lib/super_diff/operation_tree_flatteners/base.rb +1 -5
- data/lib/super_diff/operation_tree_flatteners/collection.rb +13 -16
- data/lib/super_diff/operation_tree_flatteners/default_object.rb +1 -2
- data/lib/super_diff/operation_tree_flatteners/hash.rb +2 -10
- data/lib/super_diff/operation_tree_flatteners/multiline_string.rb +2 -1
- data/lib/super_diff/operation_tree_flatteners.rb +3 -3
- data/lib/super_diff/operation_trees/base.rb +3 -5
- data/lib/super_diff/operation_trees/default_object.rb +1 -3
- data/lib/super_diff/operations/binary_operation.rb +2 -2
- data/lib/super_diff/operations/unary_operation.rb +1 -1
- data/lib/super_diff/rails.rb +2 -1
- data/lib/super_diff/recursion_guard.rb +5 -4
- data/lib/super_diff/rspec/augmented_matcher.rb +4 -5
- data/lib/super_diff/rspec/differ.rb +6 -13
- data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +3 -2
- data/lib/super_diff/rspec/differs/collection_including.rb +1 -1
- data/lib/super_diff/rspec/differs/hash_including.rb +1 -1
- data/lib/super_diff/rspec/differs.rb +3 -3
- data/lib/super_diff/rspec/matcher_text_builders/base.rb +13 -15
- data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +5 -7
- data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +3 -5
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +1 -5
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +2 -6
- data/lib/super_diff/rspec/matcher_text_builders.rb +5 -8
- data/lib/super_diff/rspec/matcher_text_template.rb +13 -16
- data/lib/super_diff/rspec/monkey_patches.rb +122 -116
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +11 -16
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +2 -1
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +8 -6
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +9 -9
- data/lib/super_diff/rspec/object_inspection.rb +1 -1
- data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +11 -10
- data/lib/super_diff/rspec/operation_tree_builders/collection_including.rb +7 -6
- data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +11 -10
- data/lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb +22 -17
- data/lib/super_diff/rspec/operation_tree_builders.rb +4 -4
- data/lib/super_diff/rspec.rb +11 -13
- data/lib/super_diff/tiered_lines_elider.rb +87 -115
- data/lib/super_diff/tiered_lines_formatter.rb +5 -9
- data/lib/super_diff/version.rb +1 -1
- data/lib/super_diff.rb +4 -9
- data/spec/examples.txt +493 -485
- data/spec/integration/rails/active_record_spec.rb +3 -1
- data/spec/integration/rails/engines_spec.rb +20 -0
- data/spec/integration/rails/hash_with_indifferent_access_spec.rb +3 -1
- data/spec/integration/rspec/be_falsey_matcher_spec.rb +40 -35
- data/spec/integration/rspec/be_matcher_spec.rb +360 -320
- data/spec/integration/rspec/be_nil_matcher_spec.rb +38 -34
- data/spec/integration/rspec/be_predicate_matcher_spec.rb +376 -359
- data/spec/integration/rspec/be_truthy_matcher_spec.rb +38 -33
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +242 -239
- data/spec/integration/rspec/eq_matcher_spec.rb +595 -557
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +294 -286
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +291 -297
- data/spec/integration/rspec/include_matcher_spec.rb +317 -215
- data/spec/integration/rspec/match_array_matcher_spec.rb +276 -273
- data/spec/integration/rspec/match_matcher_spec.rb +847 -834
- data/spec/integration/rspec/raise_error_matcher_spec.rb +468 -453
- data/spec/integration/rspec/respond_to_matcher_spec.rb +702 -697
- data/spec/integration/rspec/third_party_matcher_spec.rb +142 -138
- data/spec/integration/rspec/unhandled_errors_spec.rb +88 -84
- data/spec/spec_helper.rb +17 -20
- data/spec/support/command_runner.rb +34 -57
- data/spec/support/integration/helpers.rb +35 -28
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +28 -23
- data/spec/support/integration/test_programs/base.rb +12 -17
- data/spec/support/integration/test_programs/plain.rb +6 -0
- data/spec/support/integration/test_programs/rspec_active_record.rb +4 -1
- data/spec/support/integration/test_programs/rspec_active_support.rb +4 -1
- data/spec/support/integration/test_programs/rspec_rails.rb +4 -1
- data/spec/support/integration/test_programs/rspec_rails_engine.rb +30 -0
- data/spec/support/models/active_record/person.rb +6 -4
- data/spec/support/models/active_record/shipping_address.rb +9 -10
- data/spec/support/models/customer.rb +2 -4
- data/spec/support/models/player.rb +3 -6
- data/spec/support/models/shipping_address.rb +4 -13
- data/spec/support/shared_examples/active_record.rb +232 -214
- data/spec/support/shared_examples/active_support.rb +53 -51
- data/spec/support/shared_examples/elided_diffs.rb +405 -381
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +424 -388
- data/spec/support/shared_examples/key.rb +123 -0
- data/spec/support/unit/helpers.rb +1 -3
- data/spec/support/unit/matchers/match_output.rb +12 -13
- data/spec/unit/active_record/object_inspection_spec.rb +222 -206
- data/spec/unit/equality_matchers/main_spec.rb +1049 -984
- data/spec/unit/helpers_spec.rb +14 -21
- data/spec/unit/operation_tree_flatteners/array_spec.rb +557 -524
- data/spec/unit/operation_tree_flatteners/custom_object_spec.rb +619 -601
- data/spec/unit/operation_tree_flatteners/default_object_spec.rb +619 -621
- data/spec/unit/operation_tree_flatteners/hash_spec.rb +595 -556
- data/spec/unit/operation_tree_flatteners/multiline_string_spec.rb +102 -92
- data/spec/unit/rspec/matchers/be_compared_to_spec.rb +3 -3
- data/spec/unit/rspec/matchers/be_predicate_spec.rb +3 -3
- data/spec/unit/rspec/matchers/contain_exactly_spec.rb +1 -1
- data/spec/unit/rspec/matchers/have_attributes_spec.rb +1 -1
- data/spec/unit/rspec/matchers/have_predicate_spec.rb +2 -2
- data/spec/unit/rspec/matchers/include_spec.rb +2 -2
- data/spec/unit/rspec/matchers/match_array_spec.rb +2 -2
- data/spec/unit/rspec/matchers/raise_error_spec.rb +5 -5
- data/spec/unit/rspec/matchers/respond_to_spec.rb +23 -16
- data/spec/unit/rspec/object_inspection_spec.rb +349 -324
- data/spec/unit/super_diff_spec.rb +1542 -1449
- data/spec/unit/tiered_lines_elider_spec.rb +3508 -3536
- data/spec/unit/tiered_lines_formatter_spec.rb +54 -116
- data/super_diff.gemspec +13 -12
- metadata +73 -73
- 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
|
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
|
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 =
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
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 =
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
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 =
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
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
|
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 =
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
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 =
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
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
|
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 =
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
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
|
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
|
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 =
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
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
|
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 =
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
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
|
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 =
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
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
|
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 =
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
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
|
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 =
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
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
|
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 =
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
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
|