super_diff 0.9.0 → 0.11.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 +22 -18
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +14 -7
- 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 +20 -11
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/ordered_options.rb +46 -0
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders.rb +5 -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 -10
- 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/date_like.rb +15 -0
- data/lib/super_diff/differs/default_object.rb +1 -1
- data/lib/super_diff/differs/defaults.rb +2 -1
- data/lib/super_diff/differs/main.rb +2 -13
- data/lib/super_diff/differs.rb +1 -0
- 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 +2 -6
- 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 +64 -73
- data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +29 -14
- data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +17 -13
- data/lib/super_diff/object_inspection/inspection_tree_builders/date_like.rb +51 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/default_object.rb +43 -27
- data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +2 -1
- data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +35 -18
- data/lib/super_diff/object_inspection/inspection_tree_builders/primitive.rb +3 -5
- data/lib/super_diff/object_inspection/inspection_tree_builders/time_like.rb +30 -36
- data/lib/super_diff/object_inspection/inspection_tree_builders.rb +13 -9
- data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +11 -22
- 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/date_like.rb +15 -0
- data/lib/super_diff/operation_tree_builders/default_object.rb +29 -21
- data/lib/super_diff/operation_tree_builders/defaults.rb +1 -1
- 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 +2 -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 +2 -10
- 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 +180 -123
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_containing_exactly.rb +14 -7
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb +21 -13
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +35 -36
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/generic_describable_matcher.rb +19 -0
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb +21 -15
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +11 -10
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +11 -10
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/object_having_attributes.rb +14 -7
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/value_within.rb +10 -11
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb +13 -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 +17 -18
- 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 +13 -9
- data/spec/examples.txt +541 -483
- data/spec/integration/rails/active_record_spec.rb +3 -1
- data/spec/integration/rails/engines_spec.rb +25 -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 +257 -254
- data/spec/integration/rspec/eq_matcher_spec.rb +695 -585
- data/spec/integration/rspec/generic_describable_matchers_spec.rb +177 -0
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +312 -304
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +291 -297
- data/spec/integration/rspec/include_matcher_spec.rb +327 -225
- data/spec/integration/rspec/magic_metadata_spec.rb +51 -0
- data/spec/integration/rspec/match_array_matcher_spec.rb +294 -291
- data/spec/integration/rspec/match_matcher_spec.rb +916 -903
- data/spec/integration/rspec/raise_error_matcher_spec.rb +1208 -449
- 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/internal/log/test.log +0 -0
- data/spec/spec_helper.rb +20 -20
- data/spec/support/command_runner.rb +34 -57
- data/spec/support/integration/helpers.rb +44 -32
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +28 -23
- data/spec/support/integration/matchers.rb +34 -0
- data/spec/support/integration/test_programs/base.rb +17 -22
- 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 +20 -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 +258 -240
- data/spec/support/shared_examples/active_support.rb +174 -51
- data/spec/support/shared_examples/elided_diffs.rb +447 -423
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +500 -464
- 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/active_support/object_inspection_spec.rb +170 -0
- 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 +43 -11
- data/spec/unit/rspec/matchers/respond_to_spec.rb +23 -16
- data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +91 -0
- data/spec/unit/rspec/object_inspection_spec.rb +351 -326
- data/spec/unit/super_diff_spec.rb +1594 -1437
- 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 +88 -75
- data/lib/super_diff/errors/no_diff_formatter_available_error.rb +0 -21
- data/lib/super_diff/errors/no_operational_sequencer_available_error.rb +0 -22
- data/spec/tmp/warnings_logger/all_warnings.txt +0 -2
@@ -1,57 +1,60 @@
|
|
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
|
7
7
|
as_both_colored_and_uncolored do |color_enabled|
|
8
8
|
snippet = <<~TEST.strip
|
9
|
+
actual = HashWithIndifferentAccess.new({
|
10
|
+
line_1: "456 Ponderosa Ct.",
|
11
|
+
city: "Oakland",
|
12
|
+
state: "CA",
|
13
|
+
zip: "91234",
|
14
|
+
})
|
9
15
|
expected = {
|
10
16
|
line_1: "123 Main St.",
|
11
17
|
city: "Hill Valley",
|
12
18
|
state: "CA",
|
13
19
|
zip: "90382",
|
14
20
|
}
|
15
|
-
actual = HashWithIndifferentAccess.new({
|
16
|
-
line_1: "456 Ponderosa Ct.",
|
17
|
-
city: "Oakland",
|
18
|
-
state: "CA",
|
19
|
-
zip: "91234",
|
20
|
-
})
|
21
21
|
expect(actual).to eq(expected)
|
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
|
@@ -60,52 +63,55 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
|
|
60
63
|
it "produces the correct output" do
|
61
64
|
as_both_colored_and_uncolored do |color_enabled|
|
62
65
|
snippet = <<~TEST.strip
|
66
|
+
actual = HashWithIndifferentAccess.new({
|
67
|
+
line_1: "456 Ponderosa Ct.",
|
68
|
+
city: "Oakland",
|
69
|
+
state: "CA",
|
70
|
+
zip: "91234",
|
71
|
+
})
|
63
72
|
expected = {
|
64
73
|
"line_1" => "123 Main St.",
|
65
74
|
"city" => "Hill Valley",
|
66
75
|
"state" => "CA",
|
67
76
|
"zip" => "90382",
|
68
77
|
}
|
69
|
-
actual = HashWithIndifferentAccess.new({
|
70
|
-
line_1: "456 Ponderosa Ct.",
|
71
|
-
city: "Oakland",
|
72
|
-
state: "CA",
|
73
|
-
zip: "91234",
|
74
|
-
})
|
75
78
|
expect(actual).to eq(expected)
|
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
|
@@ -118,106 +124,112 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
|
|
118
124
|
it "produces the correct output" do
|
119
125
|
as_both_colored_and_uncolored do |color_enabled|
|
120
126
|
snippet = <<~TEST.strip
|
127
|
+
actual = {
|
128
|
+
line_1: "123 Main St.",
|
129
|
+
city: "Hill Valley",
|
130
|
+
state: "CA",
|
131
|
+
zip: "90382",
|
132
|
+
}
|
121
133
|
expected = HashWithIndifferentAccess.new({
|
122
134
|
line_1: "456 Ponderosa Ct.",
|
123
135
|
city: "Oakland",
|
124
136
|
state: "CA",
|
125
137
|
zip: "91234",
|
126
138
|
})
|
127
|
-
actual = {
|
128
|
-
line_1: "123 Main St.",
|
129
|
-
city: "Hill Valley",
|
130
|
-
state: "CA",
|
131
|
-
zip: "90382",
|
132
|
-
}
|
133
139
|
expect(actual).to eq(expected)
|
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
|
184
|
+
actual = {
|
185
|
+
"line_1" => "123 Main St.",
|
186
|
+
"city" => "Hill Valley",
|
187
|
+
"state" => "CA",
|
188
|
+
"zip" => "90382",
|
189
|
+
}
|
175
190
|
expected = HashWithIndifferentAccess.new({
|
176
191
|
line_1: "456 Ponderosa Ct.",
|
177
192
|
city: "Oakland",
|
178
193
|
state: "CA",
|
179
194
|
zip: "91234",
|
180
195
|
})
|
181
|
-
actual = {
|
182
|
-
"line_1" => "123 Main St.",
|
183
|
-
"city" => "Hill Valley",
|
184
|
-
"state" => "CA",
|
185
|
-
"zip" => "90382",
|
186
|
-
}
|
187
196
|
expect(actual).to eq(expected)
|
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
|
@@ -228,6 +240,16 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
|
|
228
240
|
it "produces the correct output" do
|
229
241
|
as_both_colored_and_uncolored do |color_enabled|
|
230
242
|
snippet = <<~TEST.strip
|
243
|
+
actual = {
|
244
|
+
shipments: [
|
245
|
+
{
|
246
|
+
estimated_delivery: {
|
247
|
+
from: '2019-05-06',
|
248
|
+
to: '2019-05-09'
|
249
|
+
}
|
250
|
+
}
|
251
|
+
]
|
252
|
+
}
|
231
253
|
expected = HashWithIndifferentAccess.new({
|
232
254
|
shipments: [
|
233
255
|
HashWithIndifferentAccess.new({
|
@@ -238,60 +260,63 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
|
|
238
260
|
})
|
239
261
|
]
|
240
262
|
})
|
241
|
-
actual = {
|
242
|
-
shipments: [
|
243
|
-
{
|
244
|
-
estimated_delivery: {
|
245
|
-
from: '2019-05-06',
|
246
|
-
to: '2019-05-09'
|
247
|
-
}
|
248
|
-
}
|
249
|
-
]
|
250
|
-
}
|
251
263
|
expect(actual).to eq(expected)
|
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
|
310
|
+
actual = {
|
311
|
+
'shipments' => [
|
312
|
+
{
|
313
|
+
'estimated_delivery' => {
|
314
|
+
'from' => '2019-05-06',
|
315
|
+
'to' => '2019-05-09'
|
316
|
+
}
|
317
|
+
}
|
318
|
+
]
|
319
|
+
}
|
295
320
|
expected = HashWithIndifferentAccess.new({
|
296
321
|
shipments: [
|
297
322
|
HashWithIndifferentAccess.new({
|
@@ -302,52 +327,45 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
|
|
302
327
|
})
|
303
328
|
]
|
304
329
|
})
|
305
|
-
actual = {
|
306
|
-
'shipments' => [
|
307
|
-
{
|
308
|
-
'estimated_delivery' => {
|
309
|
-
'from' => '2019-05-06',
|
310
|
-
'to' => '2019-05-09'
|
311
|
-
}
|
312
|
-
}
|
313
|
-
]
|
314
|
-
}
|
315
330
|
expect(actual).to eq(expected)
|
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,58 +374,61 @@ 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
|
363
381
|
as_both_colored_and_uncolored do |color_enabled|
|
364
382
|
snippet = <<~TEST.strip
|
383
|
+
actual = HashWithIndifferentAccess.new({
|
384
|
+
line_1: "456 Ponderosa Ct.",
|
385
|
+
city: "Oakland",
|
386
|
+
state: "CA",
|
387
|
+
zip: "91234",
|
388
|
+
})
|
365
389
|
expected = {
|
366
390
|
line_1: "123 Main St.",
|
367
391
|
city: "Hill Valley",
|
368
392
|
state: "CA",
|
369
393
|
zip: "90382",
|
370
394
|
}
|
371
|
-
actual = HashWithIndifferentAccess.new({
|
372
|
-
line_1: "456 Ponderosa Ct.",
|
373
|
-
city: "Oakland",
|
374
|
-
state: "CA",
|
375
|
-
zip: "91234",
|
376
|
-
})
|
377
395
|
expect(actual).to match(expected)
|
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
|
@@ -416,52 +437,55 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
|
|
416
437
|
it "produces the correct output" do
|
417
438
|
as_both_colored_and_uncolored do |color_enabled|
|
418
439
|
snippet = <<~TEST.strip
|
440
|
+
actual = HashWithIndifferentAccess.new({
|
441
|
+
line_1: "456 Ponderosa Ct.",
|
442
|
+
city: "Oakland",
|
443
|
+
state: "CA",
|
444
|
+
zip: "91234",
|
445
|
+
})
|
419
446
|
expected = {
|
420
447
|
"line_1" => "123 Main St.",
|
421
448
|
"city" => "Hill Valley",
|
422
449
|
"state" => "CA",
|
423
450
|
"zip" => "90382",
|
424
451
|
}
|
425
|
-
actual = HashWithIndifferentAccess.new({
|
426
|
-
line_1: "456 Ponderosa Ct.",
|
427
|
-
city: "Oakland",
|
428
|
-
state: "CA",
|
429
|
-
zip: "91234",
|
430
|
-
})
|
431
452
|
expect(actual).to match(expected)
|
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,120 +494,136 @@ 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
|
501
|
+
actual = {
|
502
|
+
line_1: "123 Main St.",
|
503
|
+
city: "Hill Valley",
|
504
|
+
state: "CA",
|
505
|
+
zip: "90382",
|
506
|
+
}
|
477
507
|
expected = HashWithIndifferentAccess.new({
|
478
508
|
line_1: "456 Ponderosa Ct.",
|
479
509
|
city: "Oakland",
|
480
510
|
state: "CA",
|
481
511
|
zip: "91234",
|
482
512
|
})
|
483
|
-
actual = {
|
484
|
-
line_1: "123 Main St.",
|
485
|
-
city: "Hill Valley",
|
486
|
-
state: "CA",
|
487
|
-
zip: "90382",
|
488
|
-
}
|
489
513
|
expect(actual).to match(expected)
|
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
|
558
|
+
actual = {
|
559
|
+
"line_1" => "123 Main St.",
|
560
|
+
"city" => "Hill Valley",
|
561
|
+
"state" => "CA",
|
562
|
+
"zip" => "90382",
|
563
|
+
}
|
531
564
|
expected = HashWithIndifferentAccess.new({
|
532
565
|
line_1: "456 Ponderosa Ct.",
|
533
566
|
city: "Oakland",
|
534
567
|
state: "CA",
|
535
568
|
zip: "91234",
|
536
569
|
})
|
537
|
-
actual = {
|
538
|
-
"line_1" => "123 Main St.",
|
539
|
-
"city" => "Hill Valley",
|
540
|
-
"state" => "CA",
|
541
|
-
"zip" => "90382",
|
542
|
-
}
|
543
570
|
expect(actual).to match(expected)
|
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
|
617
|
+
actual = {
|
618
|
+
shipments: [
|
619
|
+
{
|
620
|
+
estimated_delivery: {
|
621
|
+
from: '2019-05-06',
|
622
|
+
to: '2019-05-09'
|
623
|
+
}
|
624
|
+
}
|
625
|
+
]
|
626
|
+
}
|
587
627
|
expected = HashWithIndifferentAccess.new({
|
588
628
|
shipments: [
|
589
629
|
HashWithIndifferentAccess.new({
|
@@ -594,60 +634,63 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
|
|
594
634
|
})
|
595
635
|
]
|
596
636
|
})
|
597
|
-
actual = {
|
598
|
-
shipments: [
|
599
|
-
{
|
600
|
-
estimated_delivery: {
|
601
|
-
from: '2019-05-06',
|
602
|
-
to: '2019-05-09'
|
603
|
-
}
|
604
|
-
}
|
605
|
-
]
|
606
|
-
}
|
607
637
|
expect(actual).to match(expected)
|
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
|
684
|
+
actual = {
|
685
|
+
'shipments' => [
|
686
|
+
{
|
687
|
+
'estimated_delivery' => {
|
688
|
+
'from' => '2019-05-06',
|
689
|
+
'to' => '2019-05-09'
|
690
|
+
}
|
691
|
+
}
|
692
|
+
]
|
693
|
+
}
|
651
694
|
expected = HashWithIndifferentAccess.new({
|
652
695
|
shipments: [
|
653
696
|
HashWithIndifferentAccess.new({
|
@@ -658,52 +701,45 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
|
|
658
701
|
})
|
659
702
|
]
|
660
703
|
})
|
661
|
-
actual = {
|
662
|
-
'shipments' => [
|
663
|
-
{
|
664
|
-
'estimated_delivery' => {
|
665
|
-
'from' => '2019-05-06',
|
666
|
-
'to' => '2019-05-09'
|
667
|
-
}
|
668
|
-
}
|
669
|
-
]
|
670
|
-
}
|
671
704
|
expect(actual).to match(expected)
|
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
|