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,46 +1,48 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
RSpec.describe "Integration with RSpec's #include matcher",
|
3
|
+
RSpec.describe "Integration with RSpec's #include matcher",
|
4
|
+
type: :integration do
|
4
5
|
context "when used against an array" do
|
5
6
|
context "that is small" do
|
6
7
|
it "produces the correct failure message when used in the positive" do
|
7
8
|
as_both_colored_and_uncolored do |color_enabled|
|
8
9
|
snippet = <<~TEST.strip
|
10
|
+
actual = ["Marty", "Jennifer", "Doc"]
|
9
11
|
expected = ["Marty", "Einie"]
|
10
|
-
actual = ["Marty", "Jennifer", "Doc"]
|
11
12
|
expect(actual).to include(*expected)
|
12
13
|
TEST
|
13
|
-
program =
|
14
|
-
snippet,
|
15
|
-
color_enabled: color_enabled,
|
16
|
-
)
|
14
|
+
program =
|
15
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
17
16
|
|
18
|
-
expected_output =
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
17
|
+
expected_output =
|
18
|
+
build_expected_output(
|
19
|
+
color_enabled: color_enabled,
|
20
|
+
snippet: "expect(actual).to include(*expected)",
|
21
|
+
expectation:
|
22
|
+
proc do
|
23
|
+
line do
|
24
|
+
plain "Expected "
|
25
|
+
actual %|["Marty", "Jennifer", "Doc"]|
|
26
|
+
plain " to include "
|
27
|
+
expected %|"Einie"|
|
28
|
+
plain "."
|
29
|
+
end
|
30
|
+
end,
|
31
|
+
diff:
|
32
|
+
proc do
|
33
|
+
plain_line " ["
|
34
|
+
plain_line %| "Marty",|
|
35
|
+
plain_line %| "Jennifer",|
|
36
|
+
# plain_line %| "Doc",| # FIXME
|
37
|
+
plain_line %| "Doc"|
|
38
|
+
expected_line %|- "Einie"|
|
39
|
+
plain_line " ]"
|
40
|
+
end
|
41
|
+
)
|
40
42
|
|
41
|
-
expect(program).
|
42
|
-
|
43
|
-
|
43
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
44
|
+
color_enabled
|
45
|
+
)
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
@@ -50,28 +52,28 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
50
52
|
values = ["Marty", "Einie"]
|
51
53
|
expect(values).not_to include(*values)
|
52
54
|
TEST
|
53
|
-
program =
|
54
|
-
snippet,
|
55
|
-
color_enabled: color_enabled,
|
56
|
-
)
|
55
|
+
program =
|
56
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
57
57
|
|
58
|
-
expected_output =
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
58
|
+
expected_output =
|
59
|
+
build_expected_output(
|
60
|
+
color_enabled: color_enabled,
|
61
|
+
snippet: "expect(values).not_to include(*values)",
|
62
|
+
expectation:
|
63
|
+
proc do
|
64
|
+
line do
|
65
|
+
plain "Expected "
|
66
|
+
actual %|["Marty", "Einie"]|
|
67
|
+
plain " not to include "
|
68
|
+
expected %|"Marty" and "Einie"|
|
69
|
+
plain "."
|
70
|
+
end
|
71
|
+
end
|
72
|
+
)
|
71
73
|
|
72
|
-
expect(program).
|
73
|
-
|
74
|
-
|
74
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
75
|
+
color_enabled
|
76
|
+
)
|
75
77
|
end
|
76
78
|
end
|
77
79
|
end
|
@@ -80,104 +82,105 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
80
82
|
it "produces the correct failure message when used in the positive" do
|
81
83
|
as_both_colored_and_uncolored do |color_enabled|
|
82
84
|
snippet = <<~TEST.strip
|
83
|
-
|
85
|
+
actual = [
|
84
86
|
"Marty McFly",
|
85
87
|
"Doc Brown",
|
86
88
|
"Einie",
|
87
|
-
"Biff Tannen",
|
88
|
-
"George McFly",
|
89
89
|
"Lorraine McFly"
|
90
90
|
]
|
91
|
-
|
91
|
+
expected = [
|
92
92
|
"Marty McFly",
|
93
93
|
"Doc Brown",
|
94
94
|
"Einie",
|
95
|
+
"Biff Tannen",
|
96
|
+
"George McFly",
|
95
97
|
"Lorraine McFly"
|
96
98
|
]
|
97
99
|
expect(actual).to include(*expected)
|
98
100
|
TEST
|
99
|
-
program =
|
100
|
-
snippet,
|
101
|
-
color_enabled: color_enabled,
|
102
|
-
)
|
101
|
+
program =
|
102
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
103
103
|
|
104
|
-
expected_output =
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
plain %|to include |
|
115
|
-
expected %|"Biff Tannen" and "George McFly"|
|
116
|
-
end
|
117
|
-
},
|
118
|
-
diff: proc {
|
119
|
-
plain_line %| [|
|
120
|
-
plain_line %| "Marty McFly",|
|
121
|
-
plain_line %| "Doc Brown",|
|
122
|
-
plain_line %| "Einie",|
|
123
|
-
# plain_line %| "Lorraine McFly",| # FIXME
|
124
|
-
plain_line %| "Lorraine McFly"|
|
125
|
-
expected_line %|- "Biff Tannen",|
|
126
|
-
expected_line %|- "George McFly"|
|
127
|
-
plain_line %| ]|
|
128
|
-
},
|
129
|
-
)
|
104
|
+
expected_output =
|
105
|
+
build_expected_output(
|
106
|
+
color_enabled: color_enabled,
|
107
|
+
snippet: "expect(actual).to include(*expected)",
|
108
|
+
expectation:
|
109
|
+
proc do
|
110
|
+
line do
|
111
|
+
plain " Expected "
|
112
|
+
actual %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
|
113
|
+
end
|
130
114
|
|
131
|
-
|
132
|
-
|
133
|
-
|
115
|
+
line do
|
116
|
+
plain "to include "
|
117
|
+
expected %|"Biff Tannen" and "George McFly"|
|
118
|
+
end
|
119
|
+
end,
|
120
|
+
diff:
|
121
|
+
proc do
|
122
|
+
plain_line " ["
|
123
|
+
plain_line %| "Marty McFly",|
|
124
|
+
plain_line %| "Doc Brown",|
|
125
|
+
plain_line %| "Einie",|
|
126
|
+
# plain_line %| "Lorraine McFly",| # FIXME
|
127
|
+
plain_line %| "Lorraine McFly"|
|
128
|
+
expected_line %|- "Biff Tannen",|
|
129
|
+
expected_line %|- "George McFly"|
|
130
|
+
plain_line " ]"
|
131
|
+
end
|
132
|
+
)
|
133
|
+
|
134
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
135
|
+
color_enabled
|
136
|
+
)
|
134
137
|
end
|
135
138
|
end
|
136
139
|
|
137
140
|
it "produces the correct failure message when used in the negative" do
|
138
141
|
as_both_colored_and_uncolored do |color_enabled|
|
139
142
|
snippet = <<~TEST.strip
|
140
|
-
|
143
|
+
actual = [
|
141
144
|
"Marty McFly",
|
142
145
|
"Doc Brown",
|
143
146
|
"Einie",
|
147
|
+
"Biff Tannen",
|
148
|
+
"George McFly",
|
144
149
|
"Lorraine McFly"
|
145
150
|
]
|
146
|
-
|
151
|
+
expected = [
|
147
152
|
"Marty McFly",
|
148
153
|
"Doc Brown",
|
149
154
|
"Einie",
|
150
|
-
"Biff Tannen",
|
151
|
-
"George McFly",
|
152
155
|
"Lorraine McFly"
|
153
156
|
]
|
154
157
|
expect(actual).not_to include(*expected)
|
155
158
|
TEST
|
156
|
-
program =
|
157
|
-
snippet,
|
158
|
-
color_enabled: color_enabled,
|
159
|
-
)
|
159
|
+
program =
|
160
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
160
161
|
|
161
|
-
expected_output =
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
162
|
+
expected_output =
|
163
|
+
build_expected_output(
|
164
|
+
color_enabled: color_enabled,
|
165
|
+
snippet: "expect(actual).not_to include(*expected)",
|
166
|
+
newline_before_expectation: true,
|
167
|
+
expectation:
|
168
|
+
proc do
|
169
|
+
line do
|
170
|
+
plain " Expected "
|
171
|
+
actual %|["Marty McFly", "Doc Brown", "Einie", "Biff Tannen", "George McFly", "Lorraine McFly"]|
|
172
|
+
end
|
173
|
+
|
174
|
+
line do
|
175
|
+
plain "not to include "
|
176
|
+
expected %|"Marty McFly", "Doc Brown", "Einie", and "Lorraine McFly"|
|
177
|
+
end
|
178
|
+
end
|
179
|
+
)
|
177
180
|
|
178
|
-
expect(program).
|
179
|
-
|
180
|
-
|
181
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
182
|
+
color_enabled
|
183
|
+
)
|
181
184
|
end
|
182
185
|
end
|
183
186
|
end
|
@@ -188,74 +191,116 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
188
191
|
it "produces the correct failure message when used in the positive" do
|
189
192
|
as_both_colored_and_uncolored do |color_enabled|
|
190
193
|
snippet = <<~TEST.strip
|
194
|
+
actual = { city: "Burbank", zip: "90210" }
|
191
195
|
expected = { city: "Hill Valley", state: "CA" }
|
192
|
-
actual = { city: "Burbank", zip: "90210" }
|
193
196
|
expect(actual).to include(expected)
|
194
197
|
TEST
|
195
|
-
program =
|
196
|
-
snippet,
|
197
|
-
color_enabled: color_enabled,
|
198
|
-
)
|
198
|
+
program =
|
199
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
199
200
|
|
200
|
-
expected_output =
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
201
|
+
expected_output =
|
202
|
+
build_expected_output(
|
203
|
+
color_enabled: color_enabled,
|
204
|
+
snippet: "expect(actual).to include(expected)",
|
205
|
+
expectation:
|
206
|
+
proc do
|
207
|
+
line do
|
208
|
+
plain "Expected "
|
209
|
+
actual %|{ city: "Burbank", zip: "90210" }|
|
210
|
+
plain " to include "
|
211
|
+
expected %|(city: "Hill Valley", state: "CA")|
|
212
|
+
plain "."
|
213
|
+
end
|
214
|
+
end,
|
215
|
+
diff:
|
216
|
+
proc do
|
217
|
+
plain_line " {"
|
218
|
+
expected_line %|- city: "Hill Valley",|
|
219
|
+
actual_line %|+ city: "Burbank",|
|
220
|
+
# FIXME
|
221
|
+
# expected_line %|- state: "CA",|
|
222
|
+
expected_line %|- state: "CA"|
|
223
|
+
plain_line %| zip: "90210"|
|
224
|
+
plain_line " }"
|
225
|
+
end
|
226
|
+
)
|
223
227
|
|
224
|
-
expect(program).
|
225
|
-
|
226
|
-
|
228
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
229
|
+
color_enabled
|
230
|
+
)
|
227
231
|
end
|
228
232
|
end
|
229
233
|
|
230
234
|
it "produces the correct failure message when used in the negative" do
|
231
235
|
as_both_colored_and_uncolored do |color_enabled|
|
232
236
|
snippet = <<~TEST.strip
|
237
|
+
actual = { city: "Burbank", zip: "90210" }
|
233
238
|
expected = { city: "Burbank" }
|
234
|
-
actual = { city: "Burbank", zip: "90210" }
|
235
239
|
expect(actual).not_to include(expected)
|
236
240
|
TEST
|
237
|
-
program =
|
238
|
-
snippet,
|
239
|
-
color_enabled: color_enabled,
|
240
|
-
)
|
241
|
+
program =
|
242
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
241
243
|
|
242
|
-
expected_output =
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
244
|
+
expected_output =
|
245
|
+
build_expected_output(
|
246
|
+
color_enabled: color_enabled,
|
247
|
+
snippet: "expect(actual).not_to include(expected)",
|
248
|
+
expectation:
|
249
|
+
proc do
|
250
|
+
line do
|
251
|
+
plain "Expected "
|
252
|
+
actual %|{ city: "Burbank", zip: "90210" }|
|
253
|
+
plain " not to include "
|
254
|
+
expected %|(city: "Burbank")|
|
255
|
+
plain "."
|
256
|
+
end
|
257
|
+
end
|
258
|
+
)
|
259
|
+
|
260
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
261
|
+
color_enabled
|
254
262
|
)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
it "produces the correct failure message when fuzzy matching" do
|
267
|
+
as_both_colored_and_uncolored do |color_enabled|
|
268
|
+
snippet = <<~TEST.strip
|
269
|
+
actual = { number: 42, city: "Burbank", zip: "90210" }
|
270
|
+
expected = { number: a_kind_of(Numeric), city: /burb/i, state: "CA" }
|
271
|
+
expect(actual).to include(expected)
|
272
|
+
TEST
|
273
|
+
program =
|
274
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
275
|
+
|
276
|
+
expected_output =
|
277
|
+
build_expected_output(
|
278
|
+
color_enabled: color_enabled,
|
279
|
+
snippet: "expect(actual).to include(expected)",
|
280
|
+
expectation:
|
281
|
+
proc do
|
282
|
+
line do
|
283
|
+
plain "Expected "
|
284
|
+
actual %|{ number: 42, city: "Burbank", zip: "90210" }|
|
285
|
+
plain " to include "
|
286
|
+
expected %|(state: "CA")|
|
287
|
+
plain "."
|
288
|
+
end
|
289
|
+
end,
|
290
|
+
diff:
|
291
|
+
proc do
|
292
|
+
plain_line " {"
|
293
|
+
plain_line " number: 42,"
|
294
|
+
plain_line %| city: "Burbank",|
|
295
|
+
plain_line %| zip: "90210"|
|
296
|
+
expected_line %|- state: "CA"|
|
297
|
+
plain_line " }"
|
298
|
+
end
|
299
|
+
)
|
255
300
|
|
256
|
-
expect(program).
|
257
|
-
|
258
|
-
|
301
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
302
|
+
color_enabled
|
303
|
+
)
|
259
304
|
end
|
260
305
|
end
|
261
306
|
end
|
@@ -264,85 +309,142 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
264
309
|
it "produces the correct failure message when used in the positive" do
|
265
310
|
as_both_colored_and_uncolored do |color_enabled|
|
266
311
|
snippet = <<~TEST.strip
|
267
|
-
|
268
|
-
city: "Hill Valley",
|
269
|
-
zip: "90382"
|
270
|
-
}
|
271
|
-
actual = {
|
312
|
+
actual = {
|
272
313
|
city: "Burbank",
|
273
314
|
state: "CA",
|
274
315
|
zip: "90210"
|
275
316
|
}
|
317
|
+
expected = {
|
318
|
+
city: "Hill Valley",
|
319
|
+
zip: "90382"
|
320
|
+
}
|
276
321
|
expect(actual).to include(expected)
|
277
322
|
TEST
|
278
|
-
program =
|
279
|
-
snippet,
|
280
|
-
color_enabled: color_enabled,
|
281
|
-
)
|
323
|
+
program =
|
324
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
282
325
|
|
283
|
-
expected_output =
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
plain %|to include |
|
294
|
-
expected %|(city: "Hill Valley", zip: "90382")|
|
295
|
-
end
|
296
|
-
},
|
297
|
-
diff: proc {
|
298
|
-
plain_line %| {|
|
299
|
-
expected_line %|- city: "Hill Valley",|
|
300
|
-
actual_line %|+ city: "Burbank",|
|
301
|
-
plain_line %| state: "CA",|
|
302
|
-
expected_line %|- zip: "90382"|
|
303
|
-
actual_line %|+ zip: "90210"|
|
304
|
-
plain_line %| }|
|
305
|
-
},
|
306
|
-
)
|
326
|
+
expected_output =
|
327
|
+
build_expected_output(
|
328
|
+
color_enabled: color_enabled,
|
329
|
+
snippet: "expect(actual).to include(expected)",
|
330
|
+
expectation:
|
331
|
+
proc do
|
332
|
+
line do
|
333
|
+
plain " Expected "
|
334
|
+
actual %|{ city: "Burbank", state: "CA", zip: "90210" }|
|
335
|
+
end
|
307
336
|
|
308
|
-
|
309
|
-
|
310
|
-
|
337
|
+
line do
|
338
|
+
plain "to include "
|
339
|
+
expected %|(city: "Hill Valley", zip: "90382")|
|
340
|
+
end
|
341
|
+
end,
|
342
|
+
diff:
|
343
|
+
proc do
|
344
|
+
plain_line " {"
|
345
|
+
expected_line %|- city: "Hill Valley",|
|
346
|
+
actual_line %|+ city: "Burbank",|
|
347
|
+
plain_line %| state: "CA",|
|
348
|
+
expected_line %|- zip: "90382"|
|
349
|
+
actual_line %|+ zip: "90210"|
|
350
|
+
plain_line " }"
|
351
|
+
end
|
352
|
+
)
|
353
|
+
|
354
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
355
|
+
color_enabled
|
356
|
+
)
|
311
357
|
end
|
312
358
|
end
|
313
359
|
|
314
360
|
it "produces the correct failure message when used in the negative" do
|
315
361
|
as_both_colored_and_uncolored do |color_enabled|
|
316
362
|
snippet = <<~TEST.strip
|
363
|
+
actual = { city: "Hill Valley", state: "CA", zip: "90210" }
|
317
364
|
expected = { city: "Hill Valley", state: "CA" }
|
318
|
-
actual = { city: "Hill Valley", state: "CA", zip: "90210" }
|
319
365
|
expect(actual).not_to include(expected)
|
320
366
|
TEST
|
321
|
-
program =
|
322
|
-
snippet,
|
323
|
-
|
324
|
-
|
367
|
+
program =
|
368
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
369
|
+
|
370
|
+
expected_output =
|
371
|
+
build_expected_output(
|
372
|
+
color_enabled: color_enabled,
|
373
|
+
snippet: "expect(actual).not_to include(expected)",
|
374
|
+
newline_before_expectation: true,
|
375
|
+
expectation:
|
376
|
+
proc do
|
377
|
+
line do
|
378
|
+
plain " Expected "
|
379
|
+
actual %|{ city: "Hill Valley", state: "CA", zip: "90210" }|
|
380
|
+
end
|
325
381
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
line do
|
337
|
-
plain %|not to include |
|
338
|
-
expected %|(city: "Hill Valley", state: "CA")|
|
339
|
-
end
|
340
|
-
},
|
382
|
+
line do
|
383
|
+
plain "not to include "
|
384
|
+
expected %|(city: "Hill Valley", state: "CA")|
|
385
|
+
end
|
386
|
+
end
|
387
|
+
)
|
388
|
+
|
389
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
390
|
+
color_enabled
|
341
391
|
)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
it "produces the correct failure message when fuzzy matching" do
|
396
|
+
as_both_colored_and_uncolored do |color_enabled|
|
397
|
+
snippet = <<~TEST.strip
|
398
|
+
actual = {
|
399
|
+
number: 42,
|
400
|
+
street: "Yoshie Circles",
|
401
|
+
city: "Burbank",
|
402
|
+
state: "CA",
|
403
|
+
zip: "90210"
|
404
|
+
}
|
405
|
+
expected = {
|
406
|
+
number: a_kind_of(Numeric),
|
407
|
+
street: "Yoshie Circles",
|
408
|
+
city: /burb/i,
|
409
|
+
zip: "90382"
|
410
|
+
}
|
411
|
+
expect(actual).to include(expected)
|
412
|
+
TEST
|
413
|
+
program =
|
414
|
+
make_plain_test_program(snippet, color_enabled: color_enabled)
|
415
|
+
|
416
|
+
expected_output =
|
417
|
+
build_expected_output(
|
418
|
+
color_enabled: color_enabled,
|
419
|
+
snippet: "expect(actual).to include(expected)",
|
420
|
+
expectation:
|
421
|
+
proc do
|
422
|
+
line do
|
423
|
+
plain " Expected "
|
424
|
+
actual %|{ number: 42, street: "Yoshie Circles", city: "Burbank", state: "CA", zip: "90210" }|
|
425
|
+
end
|
342
426
|
|
343
|
-
|
344
|
-
|
345
|
-
|
427
|
+
line do
|
428
|
+
plain "to include "
|
429
|
+
expected %|(zip: "90382")|
|
430
|
+
end
|
431
|
+
end,
|
432
|
+
diff:
|
433
|
+
proc do
|
434
|
+
plain_line " {"
|
435
|
+
plain_line " number: 42,"
|
436
|
+
plain_line %| street: "Yoshie Circles",|
|
437
|
+
plain_line %| city: "Burbank",|
|
438
|
+
plain_line %| state: "CA",|
|
439
|
+
expected_line %|- zip: "90382"|
|
440
|
+
actual_line %|+ zip: "90210"|
|
441
|
+
plain_line " }"
|
442
|
+
end
|
443
|
+
)
|
444
|
+
|
445
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
446
|
+
color_enabled
|
447
|
+
)
|
346
448
|
end
|
347
449
|
end
|
348
450
|
end
|