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
@@ -6,70 +6,71 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
6
6
|
it "produces the correct failure message when used in the positive" do
|
7
7
|
as_both_colored_and_uncolored do |color_enabled|
|
8
8
|
snippet = <<~TEST.strip
|
9
|
+
actual = { city: "Burbank" }
|
9
10
|
expected = a_hash_including(city: "Hill Valley")
|
10
|
-
actual = { city: "Burbank" }
|
11
11
|
expect(actual).to match(expected)
|
12
12
|
TEST
|
13
|
-
program =
|
14
|
-
snippet,
|
15
|
-
|
16
|
-
|
13
|
+
program =
|
14
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
15
|
+
|
16
|
+
expected_output =
|
17
|
+
build_expected_output(
|
18
|
+
color_enabled: color_enabled,
|
19
|
+
snippet: "expect(actual).to match(expected)",
|
20
|
+
expectation:
|
21
|
+
proc do
|
22
|
+
line do
|
23
|
+
plain "Expected "
|
24
|
+
actual %|{ city: "Burbank" }|
|
25
|
+
plain " to match "
|
26
|
+
expected %|#<a hash including (city: "Hill Valley")>|
|
27
|
+
plain "."
|
28
|
+
end
|
29
|
+
end,
|
30
|
+
diff:
|
31
|
+
proc do
|
32
|
+
plain_line " {"
|
33
|
+
expected_line %|- city: "Hill Valley"|
|
34
|
+
actual_line %|+ city: "Burbank"|
|
35
|
+
plain_line " }"
|
36
|
+
end
|
37
|
+
)
|
17
38
|
|
18
|
-
|
19
|
-
color_enabled
|
20
|
-
snippet: %|expect(actual).to match(expected)|,
|
21
|
-
expectation: proc {
|
22
|
-
line do
|
23
|
-
plain %|Expected |
|
24
|
-
actual %|{ city: "Burbank" }|
|
25
|
-
plain %| to match |
|
26
|
-
expected %|#<a hash including (city: "Hill Valley")>|
|
27
|
-
plain %|.|
|
28
|
-
end
|
29
|
-
},
|
30
|
-
diff: proc {
|
31
|
-
plain_line %| {|
|
32
|
-
expected_line %|- city: "Hill Valley"|
|
33
|
-
actual_line %|+ city: "Burbank"|
|
34
|
-
plain_line %| }|
|
35
|
-
},
|
39
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
40
|
+
color_enabled
|
36
41
|
)
|
37
|
-
|
38
|
-
expect(program).
|
39
|
-
to produce_output_when_run(expected_output).
|
40
|
-
in_color(color_enabled)
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
44
45
|
it "produces the correct failure message when used in the negative" do
|
45
46
|
as_both_colored_and_uncolored do |color_enabled|
|
46
47
|
snippet = <<~TEST.strip
|
48
|
+
actual = { city: "Burbank" }
|
47
49
|
expected = a_hash_including(city: "Burbank")
|
48
|
-
actual = { city: "Burbank" }
|
49
50
|
expect(actual).not_to match(expected)
|
50
51
|
TEST
|
51
|
-
program =
|
52
|
-
snippet,
|
53
|
-
|
54
|
-
|
52
|
+
program =
|
53
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
54
|
+
|
55
|
+
expected_output =
|
56
|
+
build_expected_output(
|
57
|
+
color_enabled: color_enabled,
|
58
|
+
snippet: "expect(actual).not_to match(expected)",
|
59
|
+
expectation:
|
60
|
+
proc do
|
61
|
+
line do
|
62
|
+
plain "Expected "
|
63
|
+
actual %|{ city: "Burbank" }|
|
64
|
+
plain " not to match "
|
65
|
+
expected %|#<a hash including (city: "Burbank")>|
|
66
|
+
plain "."
|
67
|
+
end
|
68
|
+
end
|
69
|
+
)
|
55
70
|
|
56
|
-
|
57
|
-
color_enabled
|
58
|
-
snippet: %|expect(actual).not_to match(expected)|,
|
59
|
-
expectation: proc {
|
60
|
-
line do
|
61
|
-
plain %|Expected |
|
62
|
-
actual %|{ city: "Burbank" }|
|
63
|
-
plain %| not to match |
|
64
|
-
expected %|#<a hash including (city: "Burbank")>|
|
65
|
-
plain %|.|
|
66
|
-
end
|
67
|
-
},
|
71
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
72
|
+
color_enabled
|
68
73
|
)
|
69
|
-
|
70
|
-
expect(program).
|
71
|
-
to produce_output_when_run(expected_output).
|
72
|
-
in_color(color_enabled)
|
73
74
|
end
|
74
75
|
end
|
75
76
|
end
|
@@ -78,113 +79,107 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
78
79
|
it "produces the correct failure message when used in the positive" do
|
79
80
|
as_both_colored_and_uncolored do |color_enabled|
|
80
81
|
snippet = <<~TEST.strip
|
81
|
-
|
82
|
-
city: "Hill Valley",
|
83
|
-
zip: "90382"
|
84
|
-
)
|
85
|
-
actual = {
|
82
|
+
actual = {
|
86
83
|
line_1: "123 Main St.",
|
87
84
|
city: "Burbank",
|
88
85
|
state: "CA",
|
89
86
|
zip: "90210"
|
90
87
|
}
|
88
|
+
expected = a_hash_including(
|
89
|
+
city: "Hill Valley",
|
90
|
+
zip: "90382"
|
91
|
+
)
|
91
92
|
expect(actual).to match(expected)
|
92
93
|
TEST
|
93
|
-
program =
|
94
|
-
snippet,
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
94
|
+
program =
|
95
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
96
|
+
|
97
|
+
expected_output =
|
98
|
+
build_expected_output(
|
99
|
+
color_enabled: color_enabled,
|
100
|
+
snippet: "expect(actual).to match(expected)",
|
101
|
+
expectation:
|
102
|
+
proc do
|
103
|
+
line do
|
104
|
+
plain "Expected "
|
105
|
+
actual %|{ line_1: "123 Main St.", city: "Burbank", state: "CA", zip: "90210" }|
|
106
|
+
end
|
107
|
+
|
108
|
+
line do
|
109
|
+
plain "to match "
|
110
|
+
expected %|#<a hash including (city: "Hill Valley", zip: "90382")>|
|
111
|
+
end
|
112
|
+
end,
|
113
|
+
diff:
|
114
|
+
proc do
|
115
|
+
plain_line " {"
|
116
|
+
plain_line %| line_1: "123 Main St.",|
|
117
|
+
expected_line %|- city: "Hill Valley",|
|
118
|
+
actual_line %|+ city: "Burbank",|
|
119
|
+
plain_line %| state: "CA",|
|
120
|
+
expected_line %|- zip: "90382"|
|
121
|
+
actual_line %|+ zip: "90210"|
|
122
|
+
plain_line " }"
|
123
|
+
end
|
124
|
+
)
|
106
125
|
|
107
|
-
|
108
|
-
|
109
|
-
expected %|#<a hash including (city: "Hill Valley", zip: "90382")>|
|
110
|
-
end
|
111
|
-
},
|
112
|
-
diff: proc {
|
113
|
-
plain_line %| {|
|
114
|
-
plain_line %| line_1: "123 Main St.",|
|
115
|
-
expected_line %|- city: "Hill Valley",|
|
116
|
-
actual_line %|+ city: "Burbank",|
|
117
|
-
plain_line %| state: "CA",|
|
118
|
-
expected_line %|- zip: "90382"|
|
119
|
-
actual_line %|+ zip: "90210"|
|
120
|
-
plain_line %| }|
|
121
|
-
},
|
126
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
127
|
+
color_enabled
|
122
128
|
)
|
123
|
-
|
124
|
-
expect(program).
|
125
|
-
to produce_output_when_run(expected_output).
|
126
|
-
in_color(color_enabled)
|
127
129
|
end
|
128
130
|
end
|
129
131
|
|
130
132
|
it "produces the correct failure message when used in the negative" do
|
131
133
|
as_both_colored_and_uncolored do |color_enabled|
|
132
134
|
snippet = <<~TEST.strip
|
133
|
-
|
134
|
-
city: "Burbank",
|
135
|
-
zip: "90210"
|
136
|
-
)
|
137
|
-
actual = {
|
135
|
+
actual = {
|
138
136
|
line_1: "123 Main St.",
|
139
137
|
city: "Burbank",
|
140
138
|
state: "CA",
|
141
139
|
zip: "90210"
|
142
140
|
}
|
141
|
+
expected = a_hash_including(
|
142
|
+
city: "Burbank",
|
143
|
+
zip: "90210"
|
144
|
+
)
|
143
145
|
expect(actual).not_to match(expected)
|
144
146
|
TEST
|
145
|
-
program =
|
146
|
-
snippet,
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
147
|
+
program =
|
148
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
149
|
+
|
150
|
+
expected_output =
|
151
|
+
build_expected_output(
|
152
|
+
color_enabled: color_enabled,
|
153
|
+
snippet: "expect(actual).not_to match(expected)",
|
154
|
+
newline_before_expectation: true,
|
155
|
+
expectation:
|
156
|
+
proc do
|
157
|
+
line do
|
158
|
+
plain " Expected "
|
159
|
+
actual %|{ line_1: "123 Main St.", city: "Burbank", state: "CA", zip: "90210" }|
|
160
|
+
end
|
161
|
+
|
162
|
+
line do
|
163
|
+
plain "not to match "
|
164
|
+
expected %|#<a hash including (city: "Burbank", zip: "90210")>|
|
165
|
+
end
|
166
|
+
end
|
167
|
+
)
|
159
168
|
|
160
|
-
|
161
|
-
|
162
|
-
expected %|#<a hash including (city: "Burbank", zip: "90210")>|
|
163
|
-
end
|
164
|
-
},
|
169
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
170
|
+
color_enabled
|
165
171
|
)
|
166
|
-
|
167
|
-
expect(program).
|
168
|
-
to produce_output_when_run(expected_output).
|
169
|
-
in_color(color_enabled)
|
170
172
|
end
|
171
173
|
end
|
172
174
|
end
|
173
175
|
end
|
174
176
|
|
175
177
|
context "when the expected value includes a hash-including-<something>" do
|
176
|
-
context "and the corresponding actual
|
178
|
+
context "and the corresponding actual value is a hash" do
|
177
179
|
it "produces the correct failure message when used in the positive" do
|
178
180
|
as_both_colored_and_uncolored do |color_enabled|
|
179
181
|
snippet = <<~TEST.strip
|
180
|
-
|
181
|
-
name: "Marty McFly",
|
182
|
-
address: a_hash_including(
|
183
|
-
city: "Hill Valley",
|
184
|
-
zip: "90382"
|
185
|
-
)
|
186
|
-
}
|
187
|
-
actual = {
|
182
|
+
actual = {
|
188
183
|
name: "Marty McFly",
|
189
184
|
address: {
|
190
185
|
line_1: "123 Main St.",
|
@@ -193,59 +188,60 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
193
188
|
zip: "90210"
|
194
189
|
}
|
195
190
|
}
|
191
|
+
expected = {
|
192
|
+
name: "Marty McFly",
|
193
|
+
address: a_hash_including(
|
194
|
+
city: "Hill Valley",
|
195
|
+
zip: "90382"
|
196
|
+
)
|
197
|
+
}
|
196
198
|
expect(actual).to match(expected)
|
197
199
|
TEST
|
198
|
-
program =
|
199
|
-
snippet,
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
200
|
+
program =
|
201
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
202
|
+
|
203
|
+
expected_output =
|
204
|
+
build_expected_output(
|
205
|
+
color_enabled: color_enabled,
|
206
|
+
snippet: "expect(actual).to match(expected)",
|
207
|
+
expectation:
|
208
|
+
proc do
|
209
|
+
line do
|
210
|
+
plain "Expected "
|
211
|
+
actual %|{ name: "Marty McFly", address: { line_1: "123 Main St.", city: "Burbank", state: "CA", zip: "90210" } }|
|
212
|
+
end
|
213
|
+
|
214
|
+
line do
|
215
|
+
plain "to match "
|
216
|
+
expected %|{ name: "Marty McFly", address: #<a hash including (city: "Hill Valley", zip: "90382")> }|
|
217
|
+
end
|
218
|
+
end,
|
219
|
+
diff:
|
220
|
+
proc do
|
221
|
+
plain_line " {"
|
222
|
+
plain_line %| name: "Marty McFly",|
|
223
|
+
plain_line " address: {"
|
224
|
+
plain_line %| line_1: "123 Main St.",|
|
225
|
+
expected_line %|- city: "Hill Valley",|
|
226
|
+
actual_line %|+ city: "Burbank",|
|
227
|
+
plain_line %| state: "CA",|
|
228
|
+
expected_line %|- zip: "90382"|
|
229
|
+
actual_line %|+ zip: "90210"|
|
230
|
+
plain_line " }"
|
231
|
+
plain_line " }"
|
232
|
+
end
|
233
|
+
)
|
211
234
|
|
212
|
-
|
213
|
-
|
214
|
-
expected %|{ name: "Marty McFly", address: #<a hash including (city: "Hill Valley", zip: "90382")> }|
|
215
|
-
end
|
216
|
-
},
|
217
|
-
diff: proc {
|
218
|
-
plain_line %| {|
|
219
|
-
plain_line %| name: "Marty McFly",|
|
220
|
-
plain_line %| address: {|
|
221
|
-
plain_line %| line_1: "123 Main St.",|
|
222
|
-
expected_line %|- city: "Hill Valley",|
|
223
|
-
actual_line %|+ city: "Burbank",|
|
224
|
-
plain_line %| state: "CA",|
|
225
|
-
expected_line %|- zip: "90382"|
|
226
|
-
actual_line %|+ zip: "90210"|
|
227
|
-
plain_line %| }|
|
228
|
-
plain_line %| }|
|
229
|
-
},
|
235
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
236
|
+
color_enabled
|
230
237
|
)
|
231
|
-
|
232
|
-
expect(program).
|
233
|
-
to produce_output_when_run(expected_output).
|
234
|
-
in_color(color_enabled)
|
235
238
|
end
|
236
239
|
end
|
237
240
|
|
238
241
|
it "produces the correct failure message when used in the negative" do
|
239
242
|
as_both_colored_and_uncolored do |color_enabled|
|
240
243
|
snippet = <<~TEST.strip
|
241
|
-
|
242
|
-
name: "Marty McFly",
|
243
|
-
address: a_hash_including(
|
244
|
-
city: "Burbank",
|
245
|
-
zip: "90210"
|
246
|
-
)
|
247
|
-
}
|
248
|
-
actual = {
|
244
|
+
actual = {
|
249
245
|
name: "Marty McFly",
|
250
246
|
address: {
|
251
247
|
line_1: "123 Main St.",
|
@@ -254,41 +250,52 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
254
250
|
zip: "90210"
|
255
251
|
}
|
256
252
|
}
|
253
|
+
expected = {
|
254
|
+
name: "Marty McFly",
|
255
|
+
address: a_hash_including(
|
256
|
+
city: "Burbank",
|
257
|
+
zip: "90210"
|
258
|
+
)
|
259
|
+
}
|
257
260
|
expect(actual).not_to match(expected)
|
258
261
|
TEST
|
259
|
-
program =
|
260
|
-
snippet,
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
262
|
+
program =
|
263
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
264
|
+
|
265
|
+
expected_output =
|
266
|
+
build_expected_output(
|
267
|
+
color_enabled: color_enabled,
|
268
|
+
snippet: "expect(actual).not_to match(expected)",
|
269
|
+
newline_before_expectation: true,
|
270
|
+
expectation:
|
271
|
+
proc do
|
272
|
+
line do
|
273
|
+
plain " Expected "
|
274
|
+
actual %|{ name: "Marty McFly", address: { line_1: "123 Main St.", city: "Burbank", state: "CA", zip: "90210" } }|
|
275
|
+
end
|
276
|
+
|
277
|
+
line do
|
278
|
+
plain "not to match "
|
279
|
+
expected %|{ name: "Marty McFly", address: #<a hash including (city: "Burbank", zip: "90210")> }|
|
280
|
+
end
|
281
|
+
end
|
282
|
+
)
|
273
283
|
|
274
|
-
|
275
|
-
|
276
|
-
expected %|{ name: "Marty McFly", address: #<a hash including (city: "Burbank", zip: "90210")> }|
|
277
|
-
end
|
278
|
-
},
|
284
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
285
|
+
color_enabled
|
279
286
|
)
|
280
|
-
|
281
|
-
expect(program).
|
282
|
-
to produce_output_when_run(expected_output).
|
283
|
-
in_color(color_enabled)
|
284
287
|
end
|
285
288
|
end
|
286
289
|
end
|
287
290
|
|
288
|
-
context "and the corresponding actual
|
291
|
+
context "and the corresponding actual value is not a hash" do
|
289
292
|
it "produces the correct failure message" do
|
290
293
|
as_both_colored_and_uncolored do |color_enabled|
|
291
294
|
snippet = <<~TEST.strip
|
295
|
+
actual = {
|
296
|
+
name: "Marty McFly",
|
297
|
+
address: nil
|
298
|
+
}
|
292
299
|
expected = {
|
293
300
|
name: "Marty McFly",
|
294
301
|
address: a_hash_including(
|
@@ -296,46 +303,43 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
296
303
|
zip: "90382"
|
297
304
|
)
|
298
305
|
}
|
299
|
-
actual = {
|
300
|
-
name: "Marty McFly",
|
301
|
-
address: nil
|
302
|
-
}
|
303
306
|
expect(actual).to match(expected)
|
304
307
|
TEST
|
305
|
-
program =
|
306
|
-
snippet,
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
308
|
+
program =
|
309
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
310
|
+
|
311
|
+
expected_output =
|
312
|
+
build_expected_output(
|
313
|
+
color_enabled: color_enabled,
|
314
|
+
snippet: "expect(actual).to match(expected)",
|
315
|
+
expectation:
|
316
|
+
proc do
|
317
|
+
line do
|
318
|
+
plain "Expected "
|
319
|
+
actual %|{ name: "Marty McFly", address: nil }|
|
320
|
+
end
|
321
|
+
|
322
|
+
line do
|
323
|
+
plain "to match "
|
324
|
+
expected %|{ name: "Marty McFly", address: #<a hash including (city: "Hill Valley", zip: "90382")> }|
|
325
|
+
end
|
326
|
+
end,
|
327
|
+
diff:
|
328
|
+
proc do
|
329
|
+
plain_line " {"
|
330
|
+
plain_line %! name: "Marty McFly",!
|
331
|
+
expected_line "- address: #<a hash including ("
|
332
|
+
expected_line %!- city: "Hill Valley",!
|
333
|
+
expected_line %!- zip: "90382"!
|
334
|
+
expected_line "- )>"
|
335
|
+
actual_line "+ address: nil"
|
336
|
+
plain_line " }"
|
337
|
+
end
|
338
|
+
)
|
318
339
|
|
319
|
-
|
320
|
-
|
321
|
-
expected %|{ name: "Marty McFly", address: #<a hash including (city: "Hill Valley", zip: "90382")> }|
|
322
|
-
end
|
323
|
-
},
|
324
|
-
diff: proc {
|
325
|
-
plain_line %! {!
|
326
|
-
plain_line %! name: "Marty McFly",!
|
327
|
-
expected_line %!- address: #<a hash including (!
|
328
|
-
expected_line %!- city: "Hill Valley",!
|
329
|
-
expected_line %!- zip: "90382"!
|
330
|
-
expected_line %!- )>!
|
331
|
-
actual_line %!+ address: nil!
|
332
|
-
plain_line %! }!
|
333
|
-
},
|
340
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
341
|
+
color_enabled
|
334
342
|
)
|
335
|
-
|
336
|
-
expect(program).
|
337
|
-
to produce_output_when_run(expected_output).
|
338
|
-
in_color(color_enabled)
|
339
343
|
end
|
340
344
|
end
|
341
345
|
end
|
@@ -347,38 +351,38 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
347
351
|
it "produces the correct failure message" do
|
348
352
|
as_both_colored_and_uncolored do |color_enabled|
|
349
353
|
snippet = <<~TEST.strip
|
354
|
+
actual = { city: "Burbank" }
|
350
355
|
expected = hash_including(city: "Hill Valley")
|
351
|
-
actual = { city: "Burbank" }
|
352
356
|
expect(actual).to match(expected)
|
353
357
|
TEST
|
354
|
-
program = make_plain_test_program(
|
355
|
-
snippet,
|
356
|
-
color_enabled: color_enabled,
|
357
|
-
)
|
358
|
+
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
358
359
|
|
359
|
-
expected_output =
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
360
|
+
expected_output =
|
361
|
+
build_expected_output(
|
362
|
+
color_enabled: color_enabled,
|
363
|
+
snippet: "expect(actual).to match(expected)",
|
364
|
+
expectation:
|
365
|
+
proc do
|
366
|
+
line do
|
367
|
+
plain "Expected "
|
368
|
+
actual %|{ city: "Burbank" }|
|
369
|
+
plain " to match "
|
370
|
+
expected %|#<a hash including (city: "Hill Valley")>|
|
371
|
+
plain "."
|
372
|
+
end
|
373
|
+
end,
|
374
|
+
diff:
|
375
|
+
proc do
|
376
|
+
plain_line " {"
|
377
|
+
expected_line %|- city: "Hill Valley"|
|
378
|
+
actual_line %|+ city: "Burbank"|
|
379
|
+
plain_line " }"
|
380
|
+
end
|
381
|
+
)
|
378
382
|
|
379
|
-
expect(program).
|
380
|
-
|
381
|
-
|
383
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
384
|
+
color_enabled
|
385
|
+
)
|
382
386
|
end
|
383
387
|
end
|
384
388
|
end
|
@@ -388,71 +392,72 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
388
392
|
it "produces the correct failure message when used in the positive" do
|
389
393
|
as_both_colored_and_uncolored do |color_enabled|
|
390
394
|
snippet = <<~TEST.strip
|
395
|
+
actual = ["b"]
|
391
396
|
expected = a_collection_including("a")
|
392
|
-
actual = ["b"]
|
393
397
|
expect(actual).to match(expected)
|
394
398
|
TEST
|
395
|
-
program =
|
396
|
-
snippet,
|
397
|
-
|
398
|
-
|
399
|
+
program =
|
400
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
401
|
+
|
402
|
+
expected_output =
|
403
|
+
build_expected_output(
|
404
|
+
color_enabled: color_enabled,
|
405
|
+
snippet: "expect(actual).to match(expected)",
|
406
|
+
expectation:
|
407
|
+
proc do
|
408
|
+
line do
|
409
|
+
plain "Expected "
|
410
|
+
actual %|["b"]|
|
411
|
+
plain " to match "
|
412
|
+
expected %|#<a collection including ("a")>|
|
413
|
+
plain "."
|
414
|
+
end
|
415
|
+
end,
|
416
|
+
diff:
|
417
|
+
proc do
|
418
|
+
plain_line " ["
|
419
|
+
plain_line %| "b"|
|
420
|
+
# expected_line %|- "a",| # FIXME
|
421
|
+
expected_line %|- "a"|
|
422
|
+
plain_line " ]"
|
423
|
+
end
|
424
|
+
)
|
399
425
|
|
400
|
-
|
401
|
-
color_enabled
|
402
|
-
snippet: %|expect(actual).to match(expected)|,
|
403
|
-
expectation: proc {
|
404
|
-
line do
|
405
|
-
plain %|Expected |
|
406
|
-
actual %|["b"]|
|
407
|
-
plain %| to match |
|
408
|
-
expected %|#<a collection including ("a")>|
|
409
|
-
plain %|.|
|
410
|
-
end
|
411
|
-
},
|
412
|
-
diff: proc {
|
413
|
-
plain_line %| [|
|
414
|
-
plain_line %| "b"|
|
415
|
-
# expected_line %|- "a",| # FIXME
|
416
|
-
expected_line %|- "a"|
|
417
|
-
plain_line %| ]|
|
418
|
-
},
|
426
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
427
|
+
color_enabled
|
419
428
|
)
|
420
|
-
|
421
|
-
expect(program).
|
422
|
-
to produce_output_when_run(expected_output).
|
423
|
-
in_color(color_enabled)
|
424
429
|
end
|
425
430
|
end
|
426
431
|
|
427
432
|
it "produces the correct failure message when used in the negative" do
|
428
433
|
as_both_colored_and_uncolored do |color_enabled|
|
429
434
|
snippet = <<~TEST.strip
|
435
|
+
actual = ["b"]
|
430
436
|
expected = a_collection_including("b")
|
431
|
-
actual = ["b"]
|
432
437
|
expect(actual).not_to match(expected)
|
433
438
|
TEST
|
434
|
-
program =
|
435
|
-
snippet,
|
436
|
-
|
437
|
-
|
439
|
+
program =
|
440
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
441
|
+
|
442
|
+
expected_output =
|
443
|
+
build_expected_output(
|
444
|
+
color_enabled: color_enabled,
|
445
|
+
snippet: "expect(actual).not_to match(expected)",
|
446
|
+
expectation:
|
447
|
+
proc do
|
448
|
+
line do
|
449
|
+
plain "Expected "
|
450
|
+
actual %|["b"]|
|
451
|
+
plain " not to match "
|
452
|
+
expected %|#<a collection including ("b")>|
|
453
|
+
plain "."
|
454
|
+
end
|
455
|
+
end
|
456
|
+
)
|
438
457
|
|
439
|
-
|
440
|
-
color_enabled
|
441
|
-
snippet: %|expect(actual).not_to match(expected)|,
|
442
|
-
expectation: proc {
|
443
|
-
line do
|
444
|
-
plain %|Expected |
|
445
|
-
actual %|["b"]|
|
446
|
-
plain %| not to match |
|
447
|
-
expected %|#<a collection including ("b")>|
|
448
|
-
plain %|.|
|
449
|
-
end
|
450
|
-
},
|
458
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
459
|
+
color_enabled
|
451
460
|
)
|
452
|
-
|
453
|
-
expect(program).
|
454
|
-
to produce_output_when_run(expected_output).
|
455
|
-
in_color(color_enabled)
|
456
461
|
end
|
457
462
|
end
|
458
463
|
end
|
@@ -461,229 +466,232 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
461
466
|
it "produces the correct failure message when used in the positive" do
|
462
467
|
as_both_colored_and_uncolored do |color_enabled|
|
463
468
|
snippet = <<~TEST.strip
|
469
|
+
actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
|
464
470
|
expected = a_collection_including("milk", "bread")
|
465
|
-
actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
|
466
471
|
expect(actual).to match(expected)
|
467
472
|
TEST
|
468
|
-
program =
|
469
|
-
snippet,
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
473
|
+
program =
|
474
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
475
|
+
|
476
|
+
expected_output =
|
477
|
+
build_expected_output(
|
478
|
+
color_enabled: color_enabled,
|
479
|
+
snippet: "expect(actual).to match(expected)",
|
480
|
+
expectation:
|
481
|
+
proc do
|
482
|
+
line do
|
483
|
+
plain "Expected "
|
484
|
+
actual %|["milk", "toast", "eggs", "cheese", "English muffins"]|
|
485
|
+
end
|
486
|
+
|
487
|
+
line do
|
488
|
+
plain "to match "
|
489
|
+
expected %|#<a collection including ("milk", "bread")>|
|
490
|
+
end
|
491
|
+
end,
|
492
|
+
diff:
|
493
|
+
proc do
|
494
|
+
plain_line " ["
|
495
|
+
plain_line %| "milk",|
|
496
|
+
plain_line %| "toast",|
|
497
|
+
plain_line %| "eggs",|
|
498
|
+
plain_line %| "cheese",|
|
499
|
+
# plain_line %| "English muffins",| # FIXME
|
500
|
+
plain_line %| "English muffins"|
|
501
|
+
expected_line %|- "bread"|
|
502
|
+
plain_line " ]"
|
503
|
+
end
|
504
|
+
)
|
481
505
|
|
482
|
-
|
483
|
-
|
484
|
-
expected %|#<a collection including ("milk", "bread")>|
|
485
|
-
end
|
486
|
-
},
|
487
|
-
diff: proc {
|
488
|
-
plain_line %| [|
|
489
|
-
plain_line %| "milk",|
|
490
|
-
plain_line %| "toast",|
|
491
|
-
plain_line %| "eggs",|
|
492
|
-
plain_line %| "cheese",|
|
493
|
-
# plain_line %| "English muffins",| # FIXME
|
494
|
-
plain_line %| "English muffins"|
|
495
|
-
expected_line %|- "bread"|
|
496
|
-
plain_line %| ]|
|
497
|
-
},
|
506
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
507
|
+
color_enabled
|
498
508
|
)
|
499
|
-
|
500
|
-
expect(program).
|
501
|
-
to produce_output_when_run(expected_output).
|
502
|
-
in_color(color_enabled)
|
503
509
|
end
|
504
510
|
end
|
505
511
|
|
506
512
|
it "produces the correct failure message when used in the negative" do
|
507
513
|
as_both_colored_and_uncolored do |color_enabled|
|
508
514
|
snippet = <<~TEST.strip
|
515
|
+
actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
|
509
516
|
expected = a_collection_including("milk", "toast")
|
510
|
-
actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
|
511
517
|
expect(actual).not_to match(expected)
|
512
518
|
TEST
|
513
|
-
program =
|
514
|
-
snippet,
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
519
|
+
program =
|
520
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
521
|
+
|
522
|
+
expected_output =
|
523
|
+
build_expected_output(
|
524
|
+
color_enabled: color_enabled,
|
525
|
+
snippet: "expect(actual).not_to match(expected)",
|
526
|
+
newline_before_expectation: true,
|
527
|
+
expectation:
|
528
|
+
proc do
|
529
|
+
line do
|
530
|
+
plain " Expected "
|
531
|
+
actual %|["milk", "toast", "eggs", "cheese", "English muffins"]|
|
532
|
+
end
|
533
|
+
|
534
|
+
line do
|
535
|
+
plain "not to match "
|
536
|
+
expected %|#<a collection including ("milk", "toast")>|
|
537
|
+
end
|
538
|
+
end
|
539
|
+
)
|
527
540
|
|
528
|
-
|
529
|
-
|
530
|
-
expected %|#<a collection including ("milk", "toast")>|
|
531
|
-
end
|
532
|
-
},
|
541
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
542
|
+
color_enabled
|
533
543
|
)
|
534
|
-
|
535
|
-
expect(program).
|
536
|
-
to produce_output_when_run(expected_output).
|
537
|
-
in_color(color_enabled)
|
538
544
|
end
|
539
545
|
end
|
540
546
|
end
|
541
547
|
end
|
542
548
|
|
543
549
|
context "when the expected value includes a collection-including-<something>" do
|
544
|
-
context "and the corresponding actual
|
550
|
+
context "and the corresponding actual value is an array" do
|
545
551
|
it "produces the correct failure message when used in the positive" do
|
546
552
|
as_both_colored_and_uncolored do |color_enabled|
|
547
553
|
snippet = <<~TEST.strip
|
548
|
-
|
554
|
+
actual = {
|
549
555
|
name: "shopping list",
|
550
|
-
contents:
|
556
|
+
contents: ["milk", "toast", "eggs"]
|
551
557
|
}
|
552
|
-
|
558
|
+
expected = {
|
553
559
|
name: "shopping list",
|
554
|
-
contents:
|
560
|
+
contents: a_collection_including("milk", "bread")
|
555
561
|
}
|
556
562
|
expect(actual).to match(expected)
|
557
563
|
TEST
|
558
|
-
program =
|
559
|
-
snippet,
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
564
|
+
program =
|
565
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
566
|
+
|
567
|
+
expected_output =
|
568
|
+
build_expected_output(
|
569
|
+
color_enabled: color_enabled,
|
570
|
+
snippet: "expect(actual).to match(expected)",
|
571
|
+
expectation:
|
572
|
+
proc do
|
573
|
+
line do
|
574
|
+
plain "Expected "
|
575
|
+
actual %|{ name: "shopping list", contents: ["milk", "toast", "eggs"] }|
|
576
|
+
end
|
577
|
+
|
578
|
+
line do
|
579
|
+
plain "to match "
|
580
|
+
expected %|{ name: "shopping list", contents: #<a collection including ("milk", "bread")> }|
|
581
|
+
end
|
582
|
+
end,
|
583
|
+
diff:
|
584
|
+
proc do
|
585
|
+
plain_line " {"
|
586
|
+
plain_line %| name: "shopping list",|
|
587
|
+
plain_line " contents: ["
|
588
|
+
plain_line %| "milk",|
|
589
|
+
plain_line %| "toast",|
|
590
|
+
# plain_line %| "eggs",| # FIXME
|
591
|
+
plain_line %| "eggs"|
|
592
|
+
expected_line %|- "bread"|
|
593
|
+
plain_line " ]"
|
594
|
+
plain_line " }"
|
595
|
+
end
|
596
|
+
)
|
571
597
|
|
572
|
-
|
573
|
-
|
574
|
-
expected %|{ name: "shopping list", contents: #<a collection including ("milk", "bread")> }|
|
575
|
-
end
|
576
|
-
},
|
577
|
-
diff: proc {
|
578
|
-
plain_line %| {|
|
579
|
-
plain_line %| name: "shopping list",|
|
580
|
-
plain_line %| contents: [|
|
581
|
-
plain_line %| "milk",|
|
582
|
-
plain_line %| "toast",|
|
583
|
-
# plain_line %| "eggs",| # FIXME
|
584
|
-
plain_line %| "eggs"|
|
585
|
-
expected_line %|- "bread"|
|
586
|
-
plain_line %| ]|
|
587
|
-
plain_line %| }|
|
588
|
-
},
|
598
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
599
|
+
color_enabled
|
589
600
|
)
|
590
|
-
|
591
|
-
expect(program).
|
592
|
-
to produce_output_when_run(expected_output).
|
593
|
-
in_color(color_enabled)
|
594
601
|
end
|
595
602
|
end
|
596
603
|
|
597
604
|
it "produces the correct failure message when used in the negative" do
|
598
605
|
as_both_colored_and_uncolored do |color_enabled|
|
599
606
|
snippet = <<~TEST.strip
|
600
|
-
|
607
|
+
actual = {
|
601
608
|
name: "shopping list",
|
602
|
-
contents:
|
609
|
+
contents: ["milk", "toast", "eggs"]
|
603
610
|
}
|
604
|
-
|
611
|
+
expected = {
|
605
612
|
name: "shopping list",
|
606
|
-
contents:
|
613
|
+
contents: a_collection_including("milk", "toast")
|
607
614
|
}
|
608
615
|
expect(actual).not_to match(expected)
|
609
616
|
TEST
|
610
|
-
program =
|
611
|
-
snippet,
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
617
|
+
program =
|
618
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
619
|
+
|
620
|
+
expected_output =
|
621
|
+
build_expected_output(
|
622
|
+
color_enabled: color_enabled,
|
623
|
+
snippet: "expect(actual).not_to match(expected)",
|
624
|
+
newline_before_expectation: true,
|
625
|
+
expectation:
|
626
|
+
proc do
|
627
|
+
line do
|
628
|
+
plain " Expected "
|
629
|
+
actual %|{ name: "shopping list", contents: ["milk", "toast", "eggs"] }|
|
630
|
+
end
|
631
|
+
|
632
|
+
line do
|
633
|
+
plain "not to match "
|
634
|
+
expected %|{ name: "shopping list", contents: #<a collection including ("milk", "toast")> }|
|
635
|
+
end
|
636
|
+
end
|
637
|
+
)
|
624
638
|
|
625
|
-
|
626
|
-
|
627
|
-
expected %|{ name: "shopping list", contents: #<a collection including ("milk", "toast")> }|
|
628
|
-
end
|
629
|
-
},
|
639
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
640
|
+
color_enabled
|
630
641
|
)
|
631
|
-
|
632
|
-
expect(program).
|
633
|
-
to produce_output_when_run(expected_output).
|
634
|
-
in_color(color_enabled)
|
635
642
|
end
|
636
643
|
end
|
637
644
|
end
|
638
645
|
|
639
|
-
context "when the corresponding actual
|
646
|
+
context "when the corresponding actual value is not an array" do
|
640
647
|
it "produces the correct failure message" do
|
641
648
|
as_both_colored_and_uncolored do |color_enabled|
|
642
649
|
snippet = <<~TEST.strip
|
643
|
-
|
650
|
+
actual = {
|
644
651
|
name: "shopping list",
|
645
|
-
contents:
|
652
|
+
contents: nil
|
646
653
|
}
|
647
|
-
|
654
|
+
expected = {
|
648
655
|
name: "shopping list",
|
649
|
-
contents:
|
656
|
+
contents: a_collection_including("milk", "bread")
|
650
657
|
}
|
651
658
|
expect(actual).to match(expected)
|
652
659
|
TEST
|
653
|
-
program =
|
654
|
-
snippet,
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
660
|
+
program =
|
661
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
662
|
+
|
663
|
+
expected_output =
|
664
|
+
build_expected_output(
|
665
|
+
color_enabled: color_enabled,
|
666
|
+
snippet: "expect(actual).to match(expected)",
|
667
|
+
expectation:
|
668
|
+
proc do
|
669
|
+
line do
|
670
|
+
plain "Expected "
|
671
|
+
actual %|{ name: "shopping list", contents: nil }|
|
672
|
+
end
|
673
|
+
|
674
|
+
line do
|
675
|
+
plain "to match "
|
676
|
+
expected %|{ name: "shopping list", contents: #<a collection including ("milk", "bread")> }|
|
677
|
+
end
|
678
|
+
end,
|
679
|
+
diff:
|
680
|
+
proc do
|
681
|
+
plain_line " {"
|
682
|
+
plain_line %! name: "shopping list",!
|
683
|
+
expected_line "- contents: #<a collection including ("
|
684
|
+
expected_line %!- "milk",!
|
685
|
+
expected_line %!- "bread"!
|
686
|
+
expected_line "- )>"
|
687
|
+
actual_line "+ contents: nil"
|
688
|
+
plain_line " }"
|
689
|
+
end
|
690
|
+
)
|
666
691
|
|
667
|
-
|
668
|
-
|
669
|
-
expected %|{ name: "shopping list", contents: #<a collection including ("milk", "bread")> }|
|
670
|
-
end
|
671
|
-
},
|
672
|
-
diff: proc {
|
673
|
-
plain_line %! {!
|
674
|
-
plain_line %! name: "shopping list",!
|
675
|
-
expected_line %!- contents: #<a collection including (!
|
676
|
-
expected_line %!- "milk",!
|
677
|
-
expected_line %!- "bread"!
|
678
|
-
expected_line %!- )>!
|
679
|
-
actual_line %!+ contents: nil!
|
680
|
-
plain_line %! }!
|
681
|
-
},
|
692
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
693
|
+
color_enabled
|
682
694
|
)
|
683
|
-
|
684
|
-
expect(program).
|
685
|
-
to produce_output_when_run(expected_output).
|
686
|
-
in_color(color_enabled)
|
687
695
|
end
|
688
696
|
end
|
689
697
|
end
|
@@ -693,39 +701,39 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
693
701
|
it "produces the correct failure message" do
|
694
702
|
as_both_colored_and_uncolored do |color_enabled|
|
695
703
|
snippet = <<~TEST.strip
|
704
|
+
actual = ["b"]
|
696
705
|
expected = array_including("a")
|
697
|
-
actual = ["b"]
|
698
706
|
expect(actual).to match(expected)
|
699
707
|
TEST
|
700
|
-
program = make_plain_test_program(
|
701
|
-
snippet,
|
702
|
-
color_enabled: color_enabled,
|
703
|
-
)
|
708
|
+
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
704
709
|
|
705
|
-
expected_output =
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
710
|
+
expected_output =
|
711
|
+
build_expected_output(
|
712
|
+
color_enabled: color_enabled,
|
713
|
+
snippet: "expect(actual).to match(expected)",
|
714
|
+
expectation:
|
715
|
+
proc do
|
716
|
+
line do
|
717
|
+
plain "Expected "
|
718
|
+
actual %|["b"]|
|
719
|
+
plain " to match "
|
720
|
+
expected %|#<a collection including ("a")>|
|
721
|
+
plain "."
|
722
|
+
end
|
723
|
+
end,
|
724
|
+
diff:
|
725
|
+
proc do
|
726
|
+
plain_line " ["
|
727
|
+
plain_line %| "b"|
|
728
|
+
# expected_line %|- "a",| # FIXME
|
729
|
+
expected_line %|- "a"|
|
730
|
+
plain_line " ]"
|
731
|
+
end
|
732
|
+
)
|
725
733
|
|
726
|
-
expect(program).
|
727
|
-
|
728
|
-
|
734
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
735
|
+
color_enabled
|
736
|
+
)
|
729
737
|
end
|
730
738
|
end
|
731
739
|
end
|
@@ -735,71 +743,72 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
735
743
|
it "produces the correct failure message when used in the positive" do
|
736
744
|
as_both_colored_and_uncolored do |color_enabled|
|
737
745
|
snippet = <<~TEST.strip
|
746
|
+
actual = A.new("a")
|
738
747
|
expected = an_object_having_attributes(name: "b")
|
739
|
-
actual = A.new("a")
|
740
748
|
expect(actual).to match(expected)
|
741
749
|
TEST
|
742
|
-
program =
|
743
|
-
snippet,
|
744
|
-
|
745
|
-
|
750
|
+
program =
|
751
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
752
|
+
|
753
|
+
expected_output =
|
754
|
+
build_expected_output(
|
755
|
+
color_enabled: color_enabled,
|
756
|
+
snippet: "expect(actual).to match(expected)",
|
757
|
+
expectation:
|
758
|
+
proc do
|
759
|
+
line do
|
760
|
+
plain "Expected "
|
761
|
+
actual %|#<A name: "a">|
|
762
|
+
plain " to match "
|
763
|
+
expected %|#<an object having attributes (name: "b")>|
|
764
|
+
plain "."
|
765
|
+
end
|
766
|
+
end,
|
767
|
+
diff:
|
768
|
+
proc do
|
769
|
+
plain_line " #<A {"
|
770
|
+
# expected_line %|- name: "b",| # FIXME
|
771
|
+
expected_line %|- name: "b"|
|
772
|
+
actual_line %|+ name: "a"|
|
773
|
+
plain_line " }>"
|
774
|
+
end
|
775
|
+
)
|
746
776
|
|
747
|
-
|
748
|
-
color_enabled
|
749
|
-
snippet: %|expect(actual).to match(expected)|,
|
750
|
-
expectation: proc {
|
751
|
-
line do
|
752
|
-
plain %|Expected |
|
753
|
-
actual %|#<A name: "a">|
|
754
|
-
plain %| to match |
|
755
|
-
expected %|#<an object having attributes (name: "b")>|
|
756
|
-
plain %|.|
|
757
|
-
end
|
758
|
-
},
|
759
|
-
diff: proc {
|
760
|
-
plain_line %| #<A {|
|
761
|
-
# expected_line %|- name: "b",| # FIXME
|
762
|
-
expected_line %|- name: "b"|
|
763
|
-
actual_line %|+ name: "a"|
|
764
|
-
plain_line %| }>|
|
765
|
-
},
|
777
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
778
|
+
color_enabled
|
766
779
|
)
|
767
|
-
|
768
|
-
expect(program).
|
769
|
-
to produce_output_when_run(expected_output).
|
770
|
-
in_color(color_enabled)
|
771
780
|
end
|
772
781
|
end
|
773
782
|
|
774
783
|
it "produces the correct failure message when used in the negative" do
|
775
784
|
as_both_colored_and_uncolored do |color_enabled|
|
776
785
|
snippet = <<~TEST.strip
|
786
|
+
actual = A.new("b")
|
777
787
|
expected = an_object_having_attributes(name: "b")
|
778
|
-
actual = A.new("b")
|
779
788
|
expect(actual).not_to match(expected)
|
780
789
|
TEST
|
781
|
-
program =
|
782
|
-
snippet,
|
783
|
-
|
784
|
-
|
790
|
+
program =
|
791
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
792
|
+
|
793
|
+
expected_output =
|
794
|
+
build_expected_output(
|
795
|
+
color_enabled: color_enabled,
|
796
|
+
snippet: "expect(actual).not_to match(expected)",
|
797
|
+
expectation:
|
798
|
+
proc do
|
799
|
+
line do
|
800
|
+
plain "Expected "
|
801
|
+
actual %|#<A name: "b">|
|
802
|
+
plain " not to match "
|
803
|
+
expected %|#<an object having attributes (name: "b")>|
|
804
|
+
plain "."
|
805
|
+
end
|
806
|
+
end
|
807
|
+
)
|
785
808
|
|
786
|
-
|
787
|
-
color_enabled
|
788
|
-
snippet: %|expect(actual).not_to match(expected)|,
|
789
|
-
expectation: proc {
|
790
|
-
line do
|
791
|
-
plain %|Expected |
|
792
|
-
actual %|#<A name: "b">|
|
793
|
-
plain %| not to match |
|
794
|
-
expected %|#<an object having attributes (name: "b")>|
|
795
|
-
plain %|.|
|
796
|
-
end
|
797
|
-
},
|
809
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
810
|
+
color_enabled
|
798
811
|
)
|
799
|
-
|
800
|
-
expect(program).
|
801
|
-
to produce_output_when_run(expected_output).
|
802
|
-
in_color(color_enabled)
|
803
812
|
end
|
804
813
|
end
|
805
814
|
end
|
@@ -808,6 +817,13 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
808
817
|
it "produces the correct failure message when used in the positive" do
|
809
818
|
as_both_colored_and_uncolored do |color_enabled|
|
810
819
|
snippet = <<~TEST.strip
|
820
|
+
actual = SuperDiff::Test::ShippingAddress.new(
|
821
|
+
line_1: "456 Ponderosa Ct.",
|
822
|
+
line_2: nil,
|
823
|
+
city: "Hill Valley",
|
824
|
+
state: "CA",
|
825
|
+
zip: "90382"
|
826
|
+
)
|
811
827
|
expected = an_object_having_attributes(
|
812
828
|
line_1: "123 Main St.",
|
813
829
|
city: "Oakland",
|
@@ -815,100 +831,94 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
815
831
|
state: "CA",
|
816
832
|
something_else: "blah"
|
817
833
|
)
|
818
|
-
actual = SuperDiff::Test::ShippingAddress.new(
|
819
|
-
line_1: "456 Ponderosa Ct.",
|
820
|
-
line_2: nil,
|
821
|
-
city: "Hill Valley",
|
822
|
-
state: "CA",
|
823
|
-
zip: "90382"
|
824
|
-
)
|
825
834
|
expect(actual).to match(expected)
|
826
835
|
TEST
|
827
|
-
program =
|
828
|
-
snippet,
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
836
|
+
program =
|
837
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
838
|
+
|
839
|
+
expected_output =
|
840
|
+
build_expected_output(
|
841
|
+
color_enabled: color_enabled,
|
842
|
+
snippet: "expect(actual).to match(expected)",
|
843
|
+
expectation:
|
844
|
+
proc do
|
845
|
+
line do
|
846
|
+
plain "Expected "
|
847
|
+
actual %|#<SuperDiff::Test::ShippingAddress line_1: "456 Ponderosa Ct.", line_2: nil, city: "Hill Valley", state: "CA", zip: "90382">|
|
848
|
+
end
|
849
|
+
|
850
|
+
line do
|
851
|
+
plain "to match "
|
852
|
+
expected %|#<an object having attributes (line_1: "123 Main St.", city: "Oakland", zip: "91234", state: "CA", something_else: "blah")>|
|
853
|
+
end
|
854
|
+
end,
|
855
|
+
diff:
|
856
|
+
proc do
|
857
|
+
plain_line " #<SuperDiff::Test::ShippingAddress {"
|
858
|
+
expected_line %|- line_1: "123 Main St.",|
|
859
|
+
actual_line %|+ line_1: "456 Ponderosa Ct.",|
|
860
|
+
plain_line " line_2: nil,"
|
861
|
+
expected_line %|- city: "Oakland",|
|
862
|
+
actual_line %|+ city: "Hill Valley",|
|
863
|
+
plain_line %| state: "CA",|
|
864
|
+
# expected_line %|- zip: "91234",| # FIXME
|
865
|
+
# actual_line %|+ zip: "90382",| # FIXME
|
866
|
+
expected_line %|- zip: "91234"|
|
867
|
+
actual_line %|+ zip: "90382"|
|
868
|
+
# expected_line %|- something_else: "blah"| # TODO
|
869
|
+
expected_line %|- something_else: "blah",|
|
870
|
+
plain_line " }>"
|
871
|
+
end
|
872
|
+
)
|
840
873
|
|
841
|
-
|
842
|
-
|
843
|
-
expected %|#<an object having attributes (line_1: "123 Main St.", city: "Oakland", zip: "91234", state: "CA", something_else: "blah")>|
|
844
|
-
end
|
845
|
-
},
|
846
|
-
diff: proc {
|
847
|
-
plain_line %| #<SuperDiff::Test::ShippingAddress {|
|
848
|
-
expected_line %|- line_1: "123 Main St.",|
|
849
|
-
actual_line %|+ line_1: "456 Ponderosa Ct.",|
|
850
|
-
plain_line %| line_2: nil,|
|
851
|
-
expected_line %|- city: "Oakland",|
|
852
|
-
actual_line %|+ city: "Hill Valley",|
|
853
|
-
plain_line %| state: "CA",|
|
854
|
-
# expected_line %|- zip: "91234",| # FIXME
|
855
|
-
# actual_line %|+ zip: "90382",| # FIXME
|
856
|
-
expected_line %|- zip: "91234"|
|
857
|
-
actual_line %|+ zip: "90382"|
|
858
|
-
# expected_line %|- something_else: "blah"| # TODO
|
859
|
-
expected_line %|- something_else: "blah",|
|
860
|
-
plain_line %| }>|
|
861
|
-
},
|
874
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
875
|
+
color_enabled
|
862
876
|
)
|
863
|
-
|
864
|
-
expect(program).
|
865
|
-
to produce_output_when_run(expected_output).
|
866
|
-
in_color(color_enabled)
|
867
877
|
end
|
868
878
|
end
|
869
879
|
|
870
880
|
it "produces the correct failure message when used in the negative" do
|
871
881
|
as_both_colored_and_uncolored do |color_enabled|
|
872
882
|
snippet = <<~TEST.strip
|
873
|
-
|
874
|
-
line_1: "123 Main St.",
|
875
|
-
city: "Oakland",
|
876
|
-
zip: "91234"
|
877
|
-
)
|
878
|
-
actual = SuperDiff::Test::ShippingAddress.new(
|
883
|
+
actual = SuperDiff::Test::ShippingAddress.new(
|
879
884
|
line_1: "123 Main St.",
|
880
885
|
line_2: nil,
|
881
886
|
city: "Oakland",
|
882
887
|
zip: "91234",
|
883
888
|
state: "CA"
|
884
889
|
)
|
890
|
+
expected = an_object_having_attributes(
|
891
|
+
line_1: "123 Main St.",
|
892
|
+
city: "Oakland",
|
893
|
+
zip: "91234"
|
894
|
+
)
|
885
895
|
expect(actual).not_to match(expected)
|
886
896
|
TEST
|
887
|
-
program =
|
888
|
-
snippet,
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
897
|
+
program =
|
898
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
899
|
+
|
900
|
+
expected_output =
|
901
|
+
build_expected_output(
|
902
|
+
color_enabled: color_enabled,
|
903
|
+
snippet: "expect(actual).not_to match(expected)",
|
904
|
+
newline_before_expectation: true,
|
905
|
+
expectation:
|
906
|
+
proc do
|
907
|
+
line do
|
908
|
+
plain " Expected "
|
909
|
+
actual %|#<SuperDiff::Test::ShippingAddress line_1: "123 Main St.", line_2: nil, city: "Oakland", state: "CA", zip: "91234">|
|
910
|
+
end
|
911
|
+
|
912
|
+
line do
|
913
|
+
plain "not to match "
|
914
|
+
expected %|#<an object having attributes (line_1: "123 Main St.", city: "Oakland", zip: "91234")>|
|
915
|
+
end
|
916
|
+
end
|
917
|
+
)
|
901
918
|
|
902
|
-
|
903
|
-
|
904
|
-
expected %|#<an object having attributes (line_1: "123 Main St.", city: "Oakland", zip: "91234")>|
|
905
|
-
end
|
906
|
-
},
|
919
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
920
|
+
color_enabled
|
907
921
|
)
|
908
|
-
|
909
|
-
expect(program).
|
910
|
-
to produce_output_when_run(expected_output).
|
911
|
-
in_color(color_enabled)
|
912
922
|
end
|
913
923
|
end
|
914
924
|
end
|
@@ -918,6 +928,16 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
918
928
|
it "produces the correct failure message when used in the positive" do
|
919
929
|
as_both_colored_and_uncolored do |color_enabled|
|
920
930
|
snippet = <<~TEST.strip
|
931
|
+
actual = {
|
932
|
+
name: "Marty McFly",
|
933
|
+
shipping_address: SuperDiff::Test::ShippingAddress.new(
|
934
|
+
line_1: "456 Ponderosa Ct.",
|
935
|
+
line_2: nil,
|
936
|
+
city: "Hill Valley",
|
937
|
+
state: "CA",
|
938
|
+
zip: "90382"
|
939
|
+
)
|
940
|
+
}
|
921
941
|
expected = {
|
922
942
|
name: "Marty McFly",
|
923
943
|
shipping_address: an_object_having_attributes(
|
@@ -928,112 +948,101 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
928
948
|
something_else: "blah"
|
929
949
|
)
|
930
950
|
}
|
931
|
-
actual = {
|
932
|
-
name: "Marty McFly",
|
933
|
-
shipping_address: SuperDiff::Test::ShippingAddress.new(
|
934
|
-
line_1: "456 Ponderosa Ct.",
|
935
|
-
line_2: nil,
|
936
|
-
city: "Hill Valley",
|
937
|
-
state: "CA",
|
938
|
-
zip: "90382"
|
939
|
-
)
|
940
|
-
}
|
941
951
|
expect(actual).to match(expected)
|
942
952
|
TEST
|
943
|
-
program = make_plain_test_program(
|
944
|
-
snippet,
|
945
|
-
color_enabled: color_enabled,
|
946
|
-
)
|
953
|
+
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
947
954
|
|
948
|
-
expected_output =
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
955
|
+
expected_output =
|
956
|
+
build_expected_output(
|
957
|
+
color_enabled: color_enabled,
|
958
|
+
snippet: "expect(actual).to match(expected)",
|
959
|
+
expectation:
|
960
|
+
proc do
|
961
|
+
line do
|
962
|
+
plain "Expected "
|
963
|
+
actual %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::ShippingAddress line_1: "456 Ponderosa Ct.", line_2: nil, city: "Hill Valley", state: "CA", zip: "90382"> }|
|
964
|
+
end
|
965
|
+
|
966
|
+
line do
|
967
|
+
plain "to match "
|
968
|
+
expected %|{ name: "Marty McFly", shipping_address: #<an object having attributes (line_1: "123 Main St.", city: "Oakland", state: "CA", zip: "91234", something_else: "blah")> }|
|
969
|
+
end
|
970
|
+
end,
|
971
|
+
diff:
|
972
|
+
proc do
|
973
|
+
plain_line " {"
|
974
|
+
plain_line %| name: "Marty McFly",|
|
975
|
+
plain_line " shipping_address: #<SuperDiff::Test::ShippingAddress {"
|
976
|
+
expected_line %|- line_1: "123 Main St.",|
|
977
|
+
actual_line %|+ line_1: "456 Ponderosa Ct.",|
|
978
|
+
plain_line " line_2: nil,"
|
979
|
+
expected_line %|- city: "Oakland",|
|
980
|
+
actual_line %|+ city: "Hill Valley",|
|
981
|
+
plain_line %| state: "CA",|
|
982
|
+
# expected_line %|- zip: "91234",| # FIXME
|
983
|
+
expected_line %|- zip: "91234"|
|
984
|
+
actual_line %|+ zip: "90382"|
|
985
|
+
# expected_line %|- something_else: "blah"| # TODO
|
986
|
+
expected_line %|- something_else: "blah",|
|
987
|
+
plain_line " }>"
|
988
|
+
plain_line " }"
|
989
|
+
end
|
990
|
+
)
|
981
991
|
|
982
|
-
expect(program).
|
983
|
-
|
984
|
-
|
992
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
993
|
+
color_enabled
|
994
|
+
)
|
985
995
|
end
|
986
996
|
end
|
987
997
|
|
988
998
|
it "produces the correct failure message when used the negative" do
|
989
999
|
as_both_colored_and_uncolored do |color_enabled|
|
990
1000
|
snippet = <<~TEST.strip
|
991
|
-
|
1001
|
+
actual = {
|
992
1002
|
name: "Marty McFly",
|
993
|
-
shipping_address:
|
1003
|
+
shipping_address: SuperDiff::Test::ShippingAddress.new(
|
994
1004
|
line_1: "123 Main St.",
|
1005
|
+
line_2: nil,
|
995
1006
|
city: "Oakland",
|
996
1007
|
state: "CA",
|
997
|
-
zip: "91234"
|
1008
|
+
zip: "91234",
|
998
1009
|
)
|
999
1010
|
}
|
1000
|
-
|
1011
|
+
expected = {
|
1001
1012
|
name: "Marty McFly",
|
1002
|
-
shipping_address:
|
1013
|
+
shipping_address: an_object_having_attributes(
|
1003
1014
|
line_1: "123 Main St.",
|
1004
|
-
line_2: nil,
|
1005
1015
|
city: "Oakland",
|
1006
1016
|
state: "CA",
|
1007
|
-
zip: "91234"
|
1017
|
+
zip: "91234"
|
1008
1018
|
)
|
1009
1019
|
}
|
1010
1020
|
expect(actual).not_to match(expected)
|
1011
1021
|
TEST
|
1012
|
-
program = make_plain_test_program(
|
1013
|
-
snippet,
|
1014
|
-
color_enabled: color_enabled,
|
1015
|
-
)
|
1022
|
+
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
1016
1023
|
|
1017
|
-
expected_output =
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1024
|
+
expected_output =
|
1025
|
+
build_expected_output(
|
1026
|
+
color_enabled: color_enabled,
|
1027
|
+
snippet: "expect(actual).not_to match(expected)",
|
1028
|
+
newline_before_expectation: true,
|
1029
|
+
expectation:
|
1030
|
+
proc do
|
1031
|
+
line do
|
1032
|
+
plain " Expected "
|
1033
|
+
actual %|{ name: "Marty McFly", shipping_address: #<SuperDiff::Test::ShippingAddress line_1: "123 Main St.", line_2: nil, city: "Oakland", state: "CA", zip: "91234"> }|
|
1034
|
+
end
|
1035
|
+
|
1036
|
+
line do
|
1037
|
+
plain "not to match "
|
1038
|
+
expected %|{ name: "Marty McFly", shipping_address: #<an object having attributes (line_1: "123 Main St.", city: "Oakland", state: "CA", zip: "91234")> }|
|
1039
|
+
end
|
1040
|
+
end
|
1041
|
+
)
|
1033
1042
|
|
1034
|
-
expect(program).
|
1035
|
-
|
1036
|
-
|
1043
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
1044
|
+
color_enabled
|
1045
|
+
)
|
1037
1046
|
end
|
1038
1047
|
end
|
1039
1048
|
end
|
@@ -1043,71 +1052,72 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
1043
1052
|
it "produces the correct failure message when used in the positive" do
|
1044
1053
|
as_both_colored_and_uncolored do |color_enabled|
|
1045
1054
|
snippet = <<~TEST.strip
|
1055
|
+
actual = ["b"]
|
1046
1056
|
expected = a_collection_containing_exactly("a")
|
1047
|
-
actual = ["b"]
|
1048
1057
|
expect(actual).to match(expected)
|
1049
1058
|
TEST
|
1050
|
-
program =
|
1051
|
-
snippet,
|
1052
|
-
|
1053
|
-
|
1059
|
+
program =
|
1060
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1061
|
+
|
1062
|
+
expected_output =
|
1063
|
+
build_expected_output(
|
1064
|
+
color_enabled: color_enabled,
|
1065
|
+
snippet: "expect(actual).to match(expected)",
|
1066
|
+
expectation:
|
1067
|
+
proc do
|
1068
|
+
line do
|
1069
|
+
plain "Expected "
|
1070
|
+
actual %|["b"]|
|
1071
|
+
plain " to match "
|
1072
|
+
expected %|#<a collection containing exactly ("a")>|
|
1073
|
+
plain "."
|
1074
|
+
end
|
1075
|
+
end,
|
1076
|
+
diff:
|
1077
|
+
proc do
|
1078
|
+
plain_line " ["
|
1079
|
+
actual_line %|+ "b",|
|
1080
|
+
# expected_line %|- "a"| # TODO
|
1081
|
+
expected_line %|- "a",|
|
1082
|
+
plain_line " ]"
|
1083
|
+
end
|
1084
|
+
)
|
1054
1085
|
|
1055
|
-
|
1056
|
-
color_enabled
|
1057
|
-
snippet: %|expect(actual).to match(expected)|,
|
1058
|
-
expectation: proc {
|
1059
|
-
line do
|
1060
|
-
plain %|Expected |
|
1061
|
-
actual %|["b"]|
|
1062
|
-
plain %| to match |
|
1063
|
-
expected %|#<a collection containing exactly ("a")>|
|
1064
|
-
plain %|.|
|
1065
|
-
end
|
1066
|
-
},
|
1067
|
-
diff: proc {
|
1068
|
-
plain_line %| [|
|
1069
|
-
actual_line %|+ "b",|
|
1070
|
-
# expected_line %|- "a"| # TODO
|
1071
|
-
expected_line %|- "a",|
|
1072
|
-
plain_line %| ]|
|
1073
|
-
},
|
1086
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
1087
|
+
color_enabled
|
1074
1088
|
)
|
1075
|
-
|
1076
|
-
expect(program).
|
1077
|
-
to produce_output_when_run(expected_output).
|
1078
|
-
in_color(color_enabled)
|
1079
1089
|
end
|
1080
1090
|
end
|
1081
1091
|
|
1082
1092
|
it "produces the correct failure message when used in the negative" do
|
1083
1093
|
as_both_colored_and_uncolored do |color_enabled|
|
1084
1094
|
snippet = <<~TEST.strip
|
1095
|
+
actual = ["b"]
|
1085
1096
|
expected = a_collection_containing_exactly("b")
|
1086
|
-
actual = ["b"]
|
1087
1097
|
expect(actual).not_to match(expected)
|
1088
1098
|
TEST
|
1089
|
-
program =
|
1090
|
-
snippet,
|
1091
|
-
|
1092
|
-
|
1099
|
+
program =
|
1100
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1101
|
+
|
1102
|
+
expected_output =
|
1103
|
+
build_expected_output(
|
1104
|
+
color_enabled: color_enabled,
|
1105
|
+
snippet: "expect(actual).not_to match(expected)",
|
1106
|
+
expectation:
|
1107
|
+
proc do
|
1108
|
+
line do
|
1109
|
+
plain "Expected "
|
1110
|
+
actual %|["b"]|
|
1111
|
+
plain " not to match "
|
1112
|
+
expected %|#<a collection containing exactly ("b")>|
|
1113
|
+
plain "."
|
1114
|
+
end
|
1115
|
+
end
|
1116
|
+
)
|
1093
1117
|
|
1094
|
-
|
1095
|
-
color_enabled
|
1096
|
-
snippet: %|expect(actual).not_to match(expected)|,
|
1097
|
-
expectation: proc {
|
1098
|
-
line do
|
1099
|
-
plain %|Expected |
|
1100
|
-
actual %|["b"]|
|
1101
|
-
plain %| not to match |
|
1102
|
-
expected %|#<a collection containing exactly ("b")>|
|
1103
|
-
plain %|.|
|
1104
|
-
end
|
1105
|
-
},
|
1118
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
1119
|
+
color_enabled
|
1106
1120
|
)
|
1107
|
-
|
1108
|
-
expect(program).
|
1109
|
-
to produce_output_when_run(expected_output).
|
1110
|
-
in_color(color_enabled)
|
1111
1121
|
end
|
1112
1122
|
end
|
1113
1123
|
end
|
@@ -1116,229 +1126,232 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
1116
1126
|
it "produces the correct failure message when used in the positive" do
|
1117
1127
|
as_both_colored_and_uncolored do |color_enabled|
|
1118
1128
|
snippet = <<~TEST.strip
|
1129
|
+
actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
|
1119
1130
|
expected = a_collection_containing_exactly("milk", "bread")
|
1120
|
-
actual = ["milk", "toast", "eggs", "cheese", "English muffins"]
|
1121
1131
|
expect(actual).to match(expected)
|
1122
1132
|
TEST
|
1123
|
-
program =
|
1124
|
-
snippet,
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1133
|
+
program =
|
1134
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1135
|
+
|
1136
|
+
expected_output =
|
1137
|
+
build_expected_output(
|
1138
|
+
color_enabled: color_enabled,
|
1139
|
+
snippet: "expect(actual).to match(expected)",
|
1140
|
+
expectation:
|
1141
|
+
proc do
|
1142
|
+
line do
|
1143
|
+
plain "Expected "
|
1144
|
+
actual %|["milk", "toast", "eggs", "cheese", "English muffins"]|
|
1145
|
+
end
|
1146
|
+
|
1147
|
+
line do
|
1148
|
+
plain "to match "
|
1149
|
+
expected %|#<a collection containing exactly ("milk", "bread")>|
|
1150
|
+
end
|
1151
|
+
end,
|
1152
|
+
diff:
|
1153
|
+
proc do
|
1154
|
+
plain_line " ["
|
1155
|
+
plain_line %| "milk",|
|
1156
|
+
actual_line %|+ "toast",|
|
1157
|
+
actual_line %|+ "eggs",|
|
1158
|
+
actual_line %|+ "cheese",|
|
1159
|
+
actual_line %|+ "English muffins",|
|
1160
|
+
# expected_line %|- "bread"| # TODO
|
1161
|
+
expected_line %|- "bread",|
|
1162
|
+
plain_line " ]"
|
1163
|
+
end
|
1164
|
+
)
|
1136
1165
|
|
1137
|
-
|
1138
|
-
|
1139
|
-
expected %|#<a collection containing exactly ("milk", "bread")>|
|
1140
|
-
end
|
1141
|
-
},
|
1142
|
-
diff: proc {
|
1143
|
-
plain_line %| [|
|
1144
|
-
plain_line %| "milk",|
|
1145
|
-
actual_line %|+ "toast",|
|
1146
|
-
actual_line %|+ "eggs",|
|
1147
|
-
actual_line %|+ "cheese",|
|
1148
|
-
actual_line %|+ "English muffins",|
|
1149
|
-
# expected_line %|- "bread"| # TODO
|
1150
|
-
expected_line %|- "bread",|
|
1151
|
-
plain_line %| ]|
|
1152
|
-
},
|
1166
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
1167
|
+
color_enabled
|
1153
1168
|
)
|
1154
|
-
|
1155
|
-
expect(program).
|
1156
|
-
to produce_output_when_run(expected_output).
|
1157
|
-
in_color(color_enabled)
|
1158
1169
|
end
|
1159
1170
|
end
|
1160
1171
|
|
1161
1172
|
it "produces the correct failure message when used in the negative" do
|
1162
1173
|
as_both_colored_and_uncolored do |color_enabled|
|
1163
1174
|
snippet = <<~TEST.strip
|
1175
|
+
actual = ["milk", "toast", "eggs"]
|
1164
1176
|
expected = a_collection_containing_exactly("milk", "eggs", "toast")
|
1165
|
-
actual = ["milk", "toast", "eggs"]
|
1166
1177
|
expect(actual).not_to match(expected)
|
1167
1178
|
TEST
|
1168
|
-
program =
|
1169
|
-
snippet,
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1179
|
+
program =
|
1180
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1181
|
+
|
1182
|
+
expected_output =
|
1183
|
+
build_expected_output(
|
1184
|
+
color_enabled: color_enabled,
|
1185
|
+
snippet: "expect(actual).not_to match(expected)",
|
1186
|
+
newline_before_expectation: true,
|
1187
|
+
expectation:
|
1188
|
+
proc do
|
1189
|
+
line do
|
1190
|
+
plain " Expected "
|
1191
|
+
actual %|["milk", "toast", "eggs"]|
|
1192
|
+
end
|
1193
|
+
|
1194
|
+
line do
|
1195
|
+
plain "not to match "
|
1196
|
+
expected %|#<a collection containing exactly ("milk", "eggs", "toast")>|
|
1197
|
+
end
|
1198
|
+
end
|
1199
|
+
)
|
1182
1200
|
|
1183
|
-
|
1184
|
-
|
1185
|
-
expected %|#<a collection containing exactly ("milk", "eggs", "toast")>|
|
1186
|
-
end
|
1187
|
-
},
|
1201
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
1202
|
+
color_enabled
|
1188
1203
|
)
|
1189
|
-
|
1190
|
-
expect(program).
|
1191
|
-
to produce_output_when_run(expected_output).
|
1192
|
-
in_color(color_enabled)
|
1193
1204
|
end
|
1194
1205
|
end
|
1195
1206
|
end
|
1196
1207
|
end
|
1197
1208
|
|
1198
1209
|
context "when the expected value includes a collection-containing-exactly-<something>" do
|
1199
|
-
context "and the corresponding actual
|
1210
|
+
context "and the corresponding actual value is an array" do
|
1200
1211
|
it "produces the correct failure message when used in the positive" do
|
1201
1212
|
as_both_colored_and_uncolored do |color_enabled|
|
1202
1213
|
snippet = <<~TEST.strip
|
1203
|
-
|
1214
|
+
actual = {
|
1204
1215
|
name: "shopping list",
|
1205
|
-
contents:
|
1216
|
+
contents: ["milk", "toast", "eggs"]
|
1206
1217
|
}
|
1207
|
-
|
1218
|
+
expected = {
|
1208
1219
|
name: "shopping list",
|
1209
|
-
contents:
|
1220
|
+
contents: a_collection_containing_exactly("milk", "bread")
|
1210
1221
|
}
|
1211
1222
|
expect(actual).to match(expected)
|
1212
1223
|
TEST
|
1213
|
-
program =
|
1214
|
-
snippet,
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1224
|
+
program =
|
1225
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1226
|
+
|
1227
|
+
expected_output =
|
1228
|
+
build_expected_output(
|
1229
|
+
color_enabled: color_enabled,
|
1230
|
+
snippet: "expect(actual).to match(expected)",
|
1231
|
+
expectation:
|
1232
|
+
proc do
|
1233
|
+
line do
|
1234
|
+
plain "Expected "
|
1235
|
+
actual %|{ name: "shopping list", contents: ["milk", "toast", "eggs"] }|
|
1236
|
+
end
|
1237
|
+
|
1238
|
+
line do
|
1239
|
+
plain "to match "
|
1240
|
+
expected %|{ name: "shopping list", contents: #<a collection containing exactly ("milk", "bread")> }|
|
1241
|
+
end
|
1242
|
+
end,
|
1243
|
+
diff:
|
1244
|
+
proc do
|
1245
|
+
plain_line " {"
|
1246
|
+
plain_line %| name: "shopping list",|
|
1247
|
+
plain_line " contents: ["
|
1248
|
+
plain_line %| "milk",|
|
1249
|
+
actual_line %|+ "toast",|
|
1250
|
+
actual_line %|+ "eggs",|
|
1251
|
+
# expected_line %|- "bread"| # TODO
|
1252
|
+
expected_line %|- "bread",|
|
1253
|
+
plain_line " ]"
|
1254
|
+
plain_line " }"
|
1255
|
+
end
|
1256
|
+
)
|
1226
1257
|
|
1227
|
-
|
1228
|
-
|
1229
|
-
expected %|{ name: "shopping list", contents: #<a collection containing exactly ("milk", "bread")> }|
|
1230
|
-
end
|
1231
|
-
},
|
1232
|
-
diff: proc {
|
1233
|
-
plain_line %| {|
|
1234
|
-
plain_line %| name: "shopping list",|
|
1235
|
-
plain_line %| contents: [|
|
1236
|
-
plain_line %| "milk",|
|
1237
|
-
actual_line %|+ "toast",|
|
1238
|
-
actual_line %|+ "eggs",|
|
1239
|
-
# expected_line %|- "bread"| # TODO
|
1240
|
-
expected_line %|- "bread",|
|
1241
|
-
plain_line %| ]|
|
1242
|
-
plain_line %| }|
|
1243
|
-
},
|
1258
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
1259
|
+
color_enabled
|
1244
1260
|
)
|
1245
|
-
|
1246
|
-
expect(program).
|
1247
|
-
to produce_output_when_run(expected_output).
|
1248
|
-
in_color(color_enabled)
|
1249
1261
|
end
|
1250
1262
|
end
|
1251
1263
|
|
1252
1264
|
it "produces the correct failure message when used in the negative" do
|
1253
1265
|
as_both_colored_and_uncolored do |color_enabled|
|
1254
1266
|
snippet = <<~TEST.strip
|
1255
|
-
|
1267
|
+
actual = {
|
1256
1268
|
name: "shopping list",
|
1257
|
-
contents:
|
1269
|
+
contents: ["milk", "toast", "eggs"]
|
1258
1270
|
}
|
1259
|
-
|
1271
|
+
expected = {
|
1260
1272
|
name: "shopping list",
|
1261
|
-
contents:
|
1273
|
+
contents: a_collection_containing_exactly("milk", "eggs", "toast")
|
1262
1274
|
}
|
1263
1275
|
expect(actual).not_to match(expected)
|
1264
1276
|
TEST
|
1265
|
-
program =
|
1266
|
-
snippet,
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1277
|
+
program =
|
1278
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1279
|
+
|
1280
|
+
expected_output =
|
1281
|
+
build_expected_output(
|
1282
|
+
color_enabled: color_enabled,
|
1283
|
+
snippet: "expect(actual).not_to match(expected)",
|
1284
|
+
newline_before_expectation: true,
|
1285
|
+
expectation:
|
1286
|
+
proc do
|
1287
|
+
line do
|
1288
|
+
plain " Expected "
|
1289
|
+
actual %|{ name: "shopping list", contents: ["milk", "toast", "eggs"] }|
|
1290
|
+
end
|
1291
|
+
|
1292
|
+
line do
|
1293
|
+
plain "not to match "
|
1294
|
+
expected %|{ name: "shopping list", contents: #<a collection containing exactly ("milk", "eggs", "toast")> }|
|
1295
|
+
end
|
1296
|
+
end
|
1297
|
+
)
|
1279
1298
|
|
1280
|
-
|
1281
|
-
|
1282
|
-
expected %|{ name: "shopping list", contents: #<a collection containing exactly ("milk", "eggs", "toast")> }|
|
1283
|
-
end
|
1284
|
-
},
|
1299
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
1300
|
+
color_enabled
|
1285
1301
|
)
|
1286
|
-
|
1287
|
-
expect(program).
|
1288
|
-
to produce_output_when_run(expected_output).
|
1289
|
-
in_color(color_enabled)
|
1290
1302
|
end
|
1291
1303
|
end
|
1292
1304
|
end
|
1293
1305
|
|
1294
|
-
context "when the corresponding actual
|
1306
|
+
context "when the corresponding actual value is not an array" do
|
1295
1307
|
it "produces the correct failure message" do
|
1296
1308
|
as_both_colored_and_uncolored do |color_enabled|
|
1297
1309
|
snippet = <<~TEST.strip
|
1298
|
-
|
1310
|
+
actual = {
|
1299
1311
|
name: "shopping list",
|
1300
|
-
contents:
|
1312
|
+
contents: nil
|
1301
1313
|
}
|
1302
|
-
|
1314
|
+
expected = {
|
1303
1315
|
name: "shopping list",
|
1304
|
-
contents:
|
1316
|
+
contents: a_collection_containing_exactly("milk", "bread")
|
1305
1317
|
}
|
1306
1318
|
expect(actual).to match(expected)
|
1307
1319
|
TEST
|
1308
|
-
program =
|
1309
|
-
snippet,
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1320
|
+
program =
|
1321
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
1322
|
+
|
1323
|
+
expected_output =
|
1324
|
+
build_expected_output(
|
1325
|
+
color_enabled: color_enabled,
|
1326
|
+
snippet: "expect(actual).to match(expected)",
|
1327
|
+
expectation:
|
1328
|
+
proc do
|
1329
|
+
line do
|
1330
|
+
plain "Expected "
|
1331
|
+
actual %|{ name: "shopping list", contents: nil }|
|
1332
|
+
end
|
1333
|
+
|
1334
|
+
line do
|
1335
|
+
plain "to match "
|
1336
|
+
expected %|{ name: "shopping list", contents: #<a collection containing exactly ("milk", "bread")> }|
|
1337
|
+
end
|
1338
|
+
end,
|
1339
|
+
diff:
|
1340
|
+
proc do
|
1341
|
+
plain_line " {"
|
1342
|
+
plain_line %! name: "shopping list",!
|
1343
|
+
expected_line "- contents: #<a collection containing exactly ("
|
1344
|
+
expected_line %!- "milk",!
|
1345
|
+
expected_line %!- "bread"!
|
1346
|
+
expected_line "- )>"
|
1347
|
+
actual_line "+ contents: nil"
|
1348
|
+
plain_line " }"
|
1349
|
+
end
|
1350
|
+
)
|
1321
1351
|
|
1322
|
-
|
1323
|
-
|
1324
|
-
expected %|{ name: "shopping list", contents: #<a collection containing exactly ("milk", "bread")> }|
|
1325
|
-
end
|
1326
|
-
},
|
1327
|
-
diff: proc {
|
1328
|
-
plain_line %! {!
|
1329
|
-
plain_line %! name: "shopping list",!
|
1330
|
-
expected_line %!- contents: #<a collection containing exactly (!
|
1331
|
-
expected_line %!- "milk",!
|
1332
|
-
expected_line %!- "bread"!
|
1333
|
-
expected_line %!- )>!
|
1334
|
-
actual_line %!+ contents: nil!
|
1335
|
-
plain_line %! }!
|
1336
|
-
},
|
1352
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
1353
|
+
color_enabled
|
1337
1354
|
)
|
1338
|
-
|
1339
|
-
expect(program).
|
1340
|
-
to produce_output_when_run(expected_output).
|
1341
|
-
in_color(color_enabled)
|
1342
1355
|
end
|
1343
1356
|
end
|
1344
1357
|
end
|