super_diff 0.3.0 → 0.5.1
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 +104 -73
- data/lib/super_diff.rb +20 -11
- data/lib/super_diff/active_record.rb +21 -23
- data/lib/super_diff/active_record/diff_formatters/active_record_relation.rb +3 -3
- data/lib/super_diff/active_record/differs/active_record_relation.rb +3 -5
- data/lib/super_diff/active_record/monkey_patches.rb +9 -0
- data/lib/super_diff/active_record/object_inspection/inspectors/active_record_model.rb +32 -22
- data/lib/super_diff/active_record/object_inspection/inspectors/active_record_relation.rb +17 -7
- data/lib/super_diff/active_record/operation_tree_builders.rb +14 -0
- data/lib/super_diff/active_record/{operational_sequencers → operation_tree_builders}/active_record_model.rb +2 -2
- data/lib/super_diff/active_record/{operational_sequencers → operation_tree_builders}/active_record_relation.rb +4 -4
- data/lib/super_diff/active_record/{operation_sequences.rb → operation_trees.rb} +2 -2
- data/lib/super_diff/active_record/{operation_sequences → operation_trees}/active_record_relation.rb +2 -2
- data/lib/super_diff/active_support.rb +16 -19
- data/lib/super_diff/active_support/diff_formatters/hash_with_indifferent_access.rb +3 -3
- data/lib/super_diff/active_support/differs/hash_with_indifferent_access.rb +3 -5
- data/lib/super_diff/active_support/object_inspection/inspectors/hash_with_indifferent_access.rb +17 -7
- data/lib/super_diff/active_support/operation_tree_builders.rb +10 -0
- data/lib/super_diff/active_support/{operational_sequencers → operation_tree_builders}/hash_with_indifferent_access.rb +2 -2
- data/lib/super_diff/active_support/{operation_sequences.rb → operation_trees.rb} +2 -2
- data/lib/super_diff/active_support/{operation_sequences → operation_trees}/hash_with_indifferent_access.rb +2 -2
- data/lib/super_diff/configuration.rb +60 -0
- data/lib/super_diff/csi.rb +4 -0
- data/lib/super_diff/diff_formatters.rb +3 -3
- data/lib/super_diff/diff_formatters/array.rb +3 -3
- data/lib/super_diff/diff_formatters/base.rb +3 -2
- data/lib/super_diff/diff_formatters/collection.rb +2 -2
- data/lib/super_diff/diff_formatters/custom_object.rb +3 -3
- data/lib/super_diff/diff_formatters/default_object.rb +6 -8
- data/lib/super_diff/diff_formatters/defaults.rb +10 -0
- data/lib/super_diff/diff_formatters/hash.rb +3 -3
- data/lib/super_diff/diff_formatters/main.rb +41 -0
- data/lib/super_diff/diff_formatters/multiline_string.rb +3 -3
- data/lib/super_diff/differs.rb +4 -11
- data/lib/super_diff/differs/array.rb +2 -11
- data/lib/super_diff/differs/base.rb +20 -3
- data/lib/super_diff/differs/custom_object.rb +2 -11
- data/lib/super_diff/differs/default_object.rb +2 -8
- data/lib/super_diff/differs/defaults.rb +12 -0
- data/lib/super_diff/differs/hash.rb +2 -11
- data/lib/super_diff/differs/main.rb +48 -0
- data/lib/super_diff/differs/multiline_string.rb +2 -14
- data/lib/super_diff/differs/time_like.rb +15 -0
- data/lib/super_diff/equality_matchers.rb +3 -9
- data/lib/super_diff/equality_matchers/array.rb +1 -7
- data/lib/super_diff/equality_matchers/base.rb +1 -1
- data/lib/super_diff/equality_matchers/default.rb +2 -8
- data/lib/super_diff/equality_matchers/defaults.rb +12 -0
- data/lib/super_diff/equality_matchers/hash.rb +1 -7
- data/lib/super_diff/equality_matchers/main.rb +21 -0
- data/lib/super_diff/equality_matchers/multiline_string.rb +1 -7
- data/lib/super_diff/errors.rb +16 -0
- data/lib/super_diff/errors/no_diff_formatter_available_error.rb +21 -0
- data/lib/super_diff/errors/no_differ_available_error.rb +24 -0
- data/lib/super_diff/errors/no_operational_sequencer_available_error.rb +22 -0
- data/lib/super_diff/implementation_checks.rb +19 -0
- data/lib/super_diff/object_inspection.rb +1 -10
- data/lib/super_diff/object_inspection/inspection_tree.rb +6 -2
- data/lib/super_diff/object_inspection/inspectors.rb +5 -1
- data/lib/super_diff/object_inspection/inspectors/array.rb +20 -10
- data/lib/super_diff/object_inspection/inspectors/base.rb +36 -0
- data/lib/super_diff/object_inspection/inspectors/custom_object.rb +24 -14
- data/lib/super_diff/object_inspection/inspectors/default_object.rb +44 -30
- data/lib/super_diff/object_inspection/inspectors/defaults.rb +15 -0
- data/lib/super_diff/object_inspection/inspectors/hash.rb +20 -10
- data/lib/super_diff/object_inspection/inspectors/main.rb +35 -0
- data/lib/super_diff/object_inspection/inspectors/primitive.rb +20 -5
- data/lib/super_diff/object_inspection/inspectors/string.rb +15 -5
- data/lib/super_diff/object_inspection/inspectors/time_like.rb +23 -0
- data/lib/super_diff/object_inspection/nodes/inspection.rb +9 -2
- data/lib/super_diff/operation_tree_builders.rb +18 -0
- data/lib/super_diff/{operational_sequencers → operation_tree_builders}/array.rb +38 -59
- data/lib/super_diff/operation_tree_builders/base.rb +98 -0
- data/lib/super_diff/{operational_sequencers → operation_tree_builders}/custom_object.rb +3 -3
- data/lib/super_diff/{operational_sequencers → operation_tree_builders}/default_object.rb +8 -3
- data/lib/super_diff/operation_tree_builders/defaults.rb +5 -0
- data/lib/super_diff/operation_tree_builders/hash.rb +226 -0
- data/lib/super_diff/operation_tree_builders/main.rb +42 -0
- data/lib/super_diff/{operational_sequencers → operation_tree_builders}/multiline_string.rb +3 -3
- data/lib/super_diff/operation_tree_builders/time_like.rb +34 -0
- data/lib/super_diff/operation_trees.rb +13 -0
- data/lib/super_diff/{operation_sequences → operation_trees}/array.rb +5 -1
- data/lib/super_diff/operation_trees/base.rb +31 -0
- data/lib/super_diff/{operation_sequences → operation_trees}/custom_object.rb +5 -1
- data/lib/super_diff/{operation_sequences → operation_trees}/default_object.rb +10 -8
- data/lib/super_diff/operation_trees/defaults.rb +5 -0
- data/lib/super_diff/{operation_sequences → operation_trees}/hash.rb +5 -1
- data/lib/super_diff/operation_trees/main.rb +35 -0
- data/lib/super_diff/operation_trees/multiline_string.rb +18 -0
- data/lib/super_diff/operations/unary_operation.rb +3 -0
- data/lib/super_diff/rspec.rb +54 -22
- data/lib/super_diff/rspec/augmented_matcher.rb +1 -1
- data/lib/super_diff/rspec/differ.rb +2 -17
- data/lib/super_diff/rspec/differs.rb +9 -3
- data/lib/super_diff/rspec/differs/collection_containing_exactly.rb +3 -8
- data/lib/super_diff/rspec/differs/collection_including.rb +18 -0
- data/lib/super_diff/rspec/differs/hash_including.rb +18 -0
- data/lib/super_diff/rspec/differs/object_having_attributes.rb +17 -0
- data/lib/super_diff/rspec/matcher_text_builders.rb +4 -0
- data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +26 -7
- data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +61 -0
- data/lib/super_diff/rspec/matcher_text_builders/match.rb +1 -1
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +13 -1
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +1 -1
- data/lib/super_diff/rspec/matcher_text_template.rb +1 -1
- data/lib/super_diff/rspec/monkey_patches.rb +226 -115
- data/lib/super_diff/rspec/object_inspection.rb +0 -1
- data/lib/super_diff/rspec/object_inspection/inspectors.rb +22 -6
- data/lib/super_diff/rspec/object_inspection/inspectors/collection_containing_exactly.rb +17 -8
- data/lib/super_diff/rspec/object_inspection/inspectors/collection_including.rb +28 -0
- data/lib/super_diff/rspec/object_inspection/inspectors/hash_including.rb +31 -0
- data/lib/super_diff/rspec/object_inspection/inspectors/instance_of.rb +23 -0
- data/lib/super_diff/rspec/object_inspection/inspectors/kind_of.rb +23 -0
- data/lib/super_diff/rspec/object_inspection/inspectors/object_having_attributes.rb +31 -0
- data/lib/super_diff/rspec/object_inspection/inspectors/primitive.rb +13 -0
- data/lib/super_diff/rspec/object_inspection/inspectors/value_within.rb +29 -0
- data/lib/super_diff/rspec/operation_tree_builders.rb +22 -0
- data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/collection_containing_exactly.rb +6 -6
- data/lib/super_diff/rspec/{operational_sequencers/partial_array.rb → operation_tree_builders/collection_including.rb} +4 -3
- data/lib/super_diff/rspec/operation_tree_builders/hash_including.rb +25 -0
- data/lib/super_diff/rspec/{operational_sequencers/partial_object.rb → operation_tree_builders/object_having_attributes.rb} +5 -11
- data/lib/super_diff/version.rb +1 -1
- data/spec/examples.txt +5 -350
- data/spec/integration/rails/active_record_spec.rb +1 -1
- data/spec/integration/rails/hash_with_indifferent_access_spec.rb +1 -1
- data/spec/integration/rspec/be_predicate_matcher_spec.rb +111 -59
- data/spec/integration/rspec/eq_matcher_spec.rb +1 -1
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +354 -227
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +484 -0
- data/spec/integration/rspec/include_matcher_spec.rb +2 -2
- data/spec/integration/rspec/match_array_matcher_spec.rb +372 -0
- data/spec/integration/rspec/match_matcher_spec.rb +8 -8
- data/spec/integration/rspec/raise_error_matcher_spec.rb +605 -226
- data/spec/integration/rspec/third_party_matcher_spec.rb +241 -0
- data/spec/integration/rspec/unhandled_errors_spec.rb +110 -58
- data/spec/spec_helper.rb +18 -7
- data/spec/support/command_runner.rb +3 -0
- data/spec/support/integration/helpers.rb +14 -90
- data/spec/support/integration/matchers.rb +143 -0
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +14 -29
- data/spec/support/integration/test_programs/base.rb +120 -0
- data/spec/support/integration/test_programs/plain.rb +13 -0
- data/spec/support/integration/test_programs/rspec_active_record.rb +17 -0
- data/spec/support/integration/test_programs/rspec_rails.rb +17 -0
- data/spec/support/models/active_record/person.rb +4 -11
- data/spec/support/models/active_record/query.rb +15 -0
- data/spec/support/models/active_record/shipping_address.rb +10 -14
- data/spec/support/object_id.rb +27 -0
- data/spec/support/ruby_versions.rb +4 -0
- data/spec/support/shared_examples/active_record.rb +71 -0
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +724 -208
- data/spec/unit/{equality_matcher_spec.rb → equality_matchers/main_spec.rb} +165 -9
- data/spec/unit/object_inspection_spec.rb +94 -18
- data/spec/unit/rspec/matchers/have_predicate_spec.rb +21 -0
- data/spec/unit/rspec/matchers/match_array_spec.rb +11 -0
- data/spec/unit/rspec/matchers/raise_error_spec.rb +16 -0
- data/super_diff.gemspec +4 -6
- metadata +99 -82
- data/lib/super_diff/active_record/object_inspection/map_extension.rb +0 -18
- data/lib/super_diff/active_record/operational_sequencers.rb +0 -14
- data/lib/super_diff/active_support/object_inspection/map_extension.rb +0 -15
- data/lib/super_diff/active_support/operational_sequencers.rb +0 -10
- data/lib/super_diff/diff_formatter.rb +0 -32
- data/lib/super_diff/differ.rb +0 -51
- data/lib/super_diff/differs/time.rb +0 -24
- data/lib/super_diff/equality_matcher.rb +0 -32
- data/lib/super_diff/no_differ_available_error.rb +0 -22
- data/lib/super_diff/no_operational_sequencer_available_error.rb +0 -20
- data/lib/super_diff/object_inspection/inspector.rb +0 -27
- data/lib/super_diff/object_inspection/inspectors/time.rb +0 -13
- data/lib/super_diff/object_inspection/map.rb +0 -30
- data/lib/super_diff/operation_sequences.rb +0 -9
- data/lib/super_diff/operation_sequences/base.rb +0 -11
- data/lib/super_diff/operational_sequencer.rb +0 -48
- data/lib/super_diff/operational_sequencers.rb +0 -17
- data/lib/super_diff/operational_sequencers/base.rb +0 -89
- data/lib/super_diff/operational_sequencers/hash.rb +0 -85
- data/lib/super_diff/operational_sequencers/time_like.rb +0 -30
- data/lib/super_diff/rspec/configuration.rb +0 -31
- data/lib/super_diff/rspec/differs/partial_array.rb +0 -22
- data/lib/super_diff/rspec/differs/partial_hash.rb +0 -22
- data/lib/super_diff/rspec/differs/partial_object.rb +0 -22
- data/lib/super_diff/rspec/object_inspection/inspectors/partial_array.rb +0 -22
- data/lib/super_diff/rspec/object_inspection/inspectors/partial_hash.rb +0 -21
- data/lib/super_diff/rspec/object_inspection/inspectors/partial_object.rb +0 -21
- data/lib/super_diff/rspec/object_inspection/map_extension.rb +0 -23
- data/lib/super_diff/rspec/operational_sequencers.rb +0 -22
- data/lib/super_diff/rspec/operational_sequencers/partial_hash.rb +0 -32
@@ -214,9 +214,9 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
214
214
|
alpha_line %|- city: "Hill Valley",|
|
215
215
|
beta_line %|+ city: "Burbank",|
|
216
216
|
# FIXME
|
217
|
-
#
|
218
|
-
plain_line %| zip: "90210"|
|
217
|
+
# alpha_line %|- state: "CA",|
|
219
218
|
alpha_line %|- state: "CA"|
|
219
|
+
plain_line %| zip: "90210"|
|
220
220
|
plain_line %| }|
|
221
221
|
},
|
222
222
|
)
|
@@ -0,0 +1,372 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Integration with RSpec's #match_array matcher", type: :integration do
|
4
|
+
context "when a few number of values are given" do
|
5
|
+
it "produces the correct failure message when used in the positive" do
|
6
|
+
as_both_colored_and_uncolored do |color_enabled|
|
7
|
+
snippet = <<~TEST.strip
|
8
|
+
expected = ["Einie", "Marty"]
|
9
|
+
actual = ["Marty", "Jennifer", "Doc"]
|
10
|
+
expect(actual).to match_array(expected)
|
11
|
+
TEST
|
12
|
+
program = make_plain_test_program(
|
13
|
+
snippet,
|
14
|
+
color_enabled: color_enabled,
|
15
|
+
)
|
16
|
+
|
17
|
+
expected_output = build_expected_output(
|
18
|
+
color_enabled: color_enabled,
|
19
|
+
snippet: %|expect(actual).to match_array(expected)|,
|
20
|
+
expectation: proc {
|
21
|
+
line do
|
22
|
+
plain "Expected "
|
23
|
+
beta %|["Marty", "Jennifer", "Doc"]|
|
24
|
+
plain " to match array with "
|
25
|
+
alpha %|"Einie"|
|
26
|
+
plain " and "
|
27
|
+
alpha %|"Marty"|
|
28
|
+
plain "."
|
29
|
+
end
|
30
|
+
},
|
31
|
+
diff: proc {
|
32
|
+
plain_line %| [|
|
33
|
+
plain_line %| "Marty",|
|
34
|
+
plain_line %| "Jennifer",|
|
35
|
+
plain_line %| "Doc",|
|
36
|
+
alpha_line %|- "Einie"|
|
37
|
+
plain_line %| ]|
|
38
|
+
},
|
39
|
+
)
|
40
|
+
|
41
|
+
expect(program).
|
42
|
+
to produce_output_when_run(expected_output).
|
43
|
+
in_color(color_enabled)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it "produces the correct failure message when used in the negative" do
|
48
|
+
as_both_colored_and_uncolored do |color_enabled|
|
49
|
+
snippet = <<~TEST.strip
|
50
|
+
values = ["Einie", "Marty"]
|
51
|
+
expect(values).not_to match_array(values)
|
52
|
+
TEST
|
53
|
+
program = make_plain_test_program(
|
54
|
+
snippet,
|
55
|
+
color_enabled: color_enabled,
|
56
|
+
)
|
57
|
+
|
58
|
+
expected_output = build_expected_output(
|
59
|
+
color_enabled: color_enabled,
|
60
|
+
snippet: %|expect(values).not_to match_array(values)|,
|
61
|
+
expectation: proc {
|
62
|
+
line do
|
63
|
+
plain "Expected "
|
64
|
+
beta %|["Einie", "Marty"]|
|
65
|
+
plain " not to match array with "
|
66
|
+
alpha %|"Einie"|
|
67
|
+
plain " and "
|
68
|
+
alpha %|"Marty"|
|
69
|
+
plain "."
|
70
|
+
end
|
71
|
+
},
|
72
|
+
)
|
73
|
+
|
74
|
+
expect(program).
|
75
|
+
to produce_output_when_run(expected_output).
|
76
|
+
in_color(color_enabled)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "when a large number of values are given" do
|
82
|
+
context "and they are only simple strings" do
|
83
|
+
it "produces the correct failure message when used in the positive" do
|
84
|
+
as_both_colored_and_uncolored do |color_enabled|
|
85
|
+
snippet = <<~TEST.strip
|
86
|
+
expected = [
|
87
|
+
"Doc Brown",
|
88
|
+
"Marty McFly",
|
89
|
+
"Biff Tannen",
|
90
|
+
"George McFly",
|
91
|
+
"Lorraine McFly"
|
92
|
+
]
|
93
|
+
actual = [
|
94
|
+
"Marty McFly",
|
95
|
+
"Doc Brown",
|
96
|
+
"Einie",
|
97
|
+
"Lorraine McFly"
|
98
|
+
]
|
99
|
+
expect(actual).to match_array(expected)
|
100
|
+
TEST
|
101
|
+
program = make_plain_test_program(
|
102
|
+
snippet,
|
103
|
+
color_enabled: color_enabled,
|
104
|
+
)
|
105
|
+
|
106
|
+
expected_output = build_expected_output(
|
107
|
+
color_enabled: color_enabled,
|
108
|
+
snippet: %|expect(actual).to match_array(expected)|,
|
109
|
+
expectation: proc {
|
110
|
+
line do
|
111
|
+
plain " Expected "
|
112
|
+
beta %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
|
113
|
+
end
|
114
|
+
|
115
|
+
line do
|
116
|
+
plain "to match array with "
|
117
|
+
alpha %|"Doc Brown"|
|
118
|
+
plain ", "
|
119
|
+
alpha %|"Marty McFly"|
|
120
|
+
plain ", "
|
121
|
+
alpha %|"Biff Tannen"|
|
122
|
+
plain ", "
|
123
|
+
alpha %|"George McFly"|
|
124
|
+
plain " and "
|
125
|
+
alpha %|"Lorraine McFly"|
|
126
|
+
end
|
127
|
+
},
|
128
|
+
diff: proc {
|
129
|
+
plain_line %| [|
|
130
|
+
plain_line %| "Marty McFly",|
|
131
|
+
plain_line %| "Doc Brown",|
|
132
|
+
plain_line %| "Einie",|
|
133
|
+
plain_line %| "Lorraine McFly",|
|
134
|
+
alpha_line %|- "Biff Tannen",|
|
135
|
+
alpha_line %|- "George McFly"|
|
136
|
+
plain_line %| ]|
|
137
|
+
},
|
138
|
+
)
|
139
|
+
|
140
|
+
expect(program).
|
141
|
+
to produce_output_when_run(expected_output).
|
142
|
+
in_color(color_enabled)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
it "produces the correct failure message when used in the negative" do
|
147
|
+
as_both_colored_and_uncolored do |color_enabled|
|
148
|
+
snippet = <<~TEST.strip
|
149
|
+
values = [
|
150
|
+
"Marty McFly",
|
151
|
+
"Doc Brown",
|
152
|
+
"Einie",
|
153
|
+
"Lorraine McFly"
|
154
|
+
]
|
155
|
+
expect(values).not_to match_array(values)
|
156
|
+
TEST
|
157
|
+
program = make_plain_test_program(
|
158
|
+
snippet,
|
159
|
+
color_enabled: color_enabled,
|
160
|
+
)
|
161
|
+
|
162
|
+
expected_output = build_expected_output(
|
163
|
+
color_enabled: color_enabled,
|
164
|
+
snippet: %|expect(values).not_to match_array(values)|,
|
165
|
+
newline_before_expectation: true,
|
166
|
+
expectation: proc {
|
167
|
+
line do
|
168
|
+
plain " Expected "
|
169
|
+
beta %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
|
170
|
+
end
|
171
|
+
|
172
|
+
line do
|
173
|
+
plain "not to match array with "
|
174
|
+
alpha %|"Marty McFly"|
|
175
|
+
plain ", "
|
176
|
+
alpha %|"Doc Brown"|
|
177
|
+
plain ", "
|
178
|
+
alpha %|"Einie"|
|
179
|
+
plain " and "
|
180
|
+
alpha %|"Lorraine McFly"|
|
181
|
+
end
|
182
|
+
},
|
183
|
+
)
|
184
|
+
|
185
|
+
expect(program).
|
186
|
+
to produce_output_when_run(expected_output).
|
187
|
+
in_color(color_enabled)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
context "and some of them are regexen" do
|
193
|
+
it "produces the correct failure message when used in the positive" do
|
194
|
+
as_both_colored_and_uncolored do |color_enabled|
|
195
|
+
snippet = <<~TEST
|
196
|
+
expected = [
|
197
|
+
/ Brown$/,
|
198
|
+
"Marty McFly",
|
199
|
+
"Biff Tannen",
|
200
|
+
/Georg McFly/,
|
201
|
+
/Lorrain McFly/
|
202
|
+
]
|
203
|
+
actual = [
|
204
|
+
"Marty McFly",
|
205
|
+
"Doc Brown",
|
206
|
+
"Einie",
|
207
|
+
"Lorraine McFly"
|
208
|
+
]
|
209
|
+
expect(actual).to match_array(expected)
|
210
|
+
TEST
|
211
|
+
program = make_plain_test_program(
|
212
|
+
snippet,
|
213
|
+
color_enabled: color_enabled,
|
214
|
+
)
|
215
|
+
|
216
|
+
expected_output = build_expected_output(
|
217
|
+
color_enabled: color_enabled,
|
218
|
+
snippet: %|expect(actual).to match_array(expected)|,
|
219
|
+
expectation: proc {
|
220
|
+
line do
|
221
|
+
plain " Expected "
|
222
|
+
beta %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
|
223
|
+
end
|
224
|
+
|
225
|
+
line do
|
226
|
+
plain "to match array with "
|
227
|
+
alpha %|/ Brown$/|
|
228
|
+
plain ", "
|
229
|
+
alpha %|"Marty McFly"|
|
230
|
+
plain ", "
|
231
|
+
alpha %|"Biff Tannen"|
|
232
|
+
plain ", "
|
233
|
+
alpha %|/Georg McFly/|
|
234
|
+
plain " and "
|
235
|
+
alpha %|/Lorrain McFly/|
|
236
|
+
end
|
237
|
+
},
|
238
|
+
diff: proc {
|
239
|
+
plain_line %| [|
|
240
|
+
plain_line %| "Marty McFly",|
|
241
|
+
plain_line %| "Doc Brown",|
|
242
|
+
plain_line %| "Einie",|
|
243
|
+
plain_line %| "Lorraine McFly",|
|
244
|
+
alpha_line %|- "Biff Tannen",|
|
245
|
+
alpha_line %|- /Georg McFly/,|
|
246
|
+
alpha_line %|- /Lorrain McFly/|
|
247
|
+
plain_line %| ]|
|
248
|
+
},
|
249
|
+
)
|
250
|
+
|
251
|
+
expect(program).
|
252
|
+
to produce_output_when_run(expected_output).
|
253
|
+
in_color(color_enabled)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
it "produces the correct failure message when used in the negative" do
|
258
|
+
as_both_colored_and_uncolored do |color_enabled|
|
259
|
+
snippet = <<~TEST
|
260
|
+
values = [
|
261
|
+
/ Brown$/,
|
262
|
+
"Marty McFly",
|
263
|
+
"Biff Tannen",
|
264
|
+
/Georg McFly/,
|
265
|
+
/Lorrain McFly/
|
266
|
+
]
|
267
|
+
expect(values).not_to match_array(values)
|
268
|
+
TEST
|
269
|
+
program = make_plain_test_program(
|
270
|
+
snippet,
|
271
|
+
color_enabled: color_enabled,
|
272
|
+
)
|
273
|
+
|
274
|
+
expected_output = build_expected_output(
|
275
|
+
color_enabled: color_enabled,
|
276
|
+
snippet: %|expect(values).not_to match_array(values)|,
|
277
|
+
newline_before_expectation: true,
|
278
|
+
expectation: proc {
|
279
|
+
line do
|
280
|
+
plain " Expected "
|
281
|
+
# rubocop:disable Metrics/LineLength
|
282
|
+
beta %|[/ Brown$/, "Marty McFly", "Biff Tannen", /Georg McFly/, /Lorrain McFly/]|
|
283
|
+
# rubocop:enable Metrics/LineLength
|
284
|
+
end
|
285
|
+
|
286
|
+
line do
|
287
|
+
plain "not to match array with "
|
288
|
+
alpha %|/ Brown$/|
|
289
|
+
plain ", "
|
290
|
+
alpha %|"Marty McFly"|
|
291
|
+
plain ", "
|
292
|
+
alpha %|"Biff Tannen"|
|
293
|
+
plain ", "
|
294
|
+
alpha %|/Georg McFly/|
|
295
|
+
plain " and "
|
296
|
+
alpha %|/Lorrain McFly/|
|
297
|
+
end
|
298
|
+
},
|
299
|
+
)
|
300
|
+
|
301
|
+
expect(program).
|
302
|
+
to produce_output_when_run(expected_output).
|
303
|
+
in_color(color_enabled)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
context "and some of them are fuzzy objects" do
|
309
|
+
it "produces the correct failure message" do
|
310
|
+
as_both_colored_and_uncolored do |color_enabled|
|
311
|
+
snippet = <<~TEST.strip
|
312
|
+
expected = [
|
313
|
+
a_hash_including(foo: "bar"),
|
314
|
+
a_collection_containing_exactly("zing"),
|
315
|
+
an_object_having_attributes(baz: "qux"),
|
316
|
+
]
|
317
|
+
actual = [
|
318
|
+
{ foo: "bar" },
|
319
|
+
double(baz: "qux"),
|
320
|
+
{ blargh: "riddle" }
|
321
|
+
]
|
322
|
+
expect(actual).to match_array(expected)
|
323
|
+
TEST
|
324
|
+
program = make_plain_test_program(
|
325
|
+
snippet,
|
326
|
+
color_enabled: color_enabled,
|
327
|
+
)
|
328
|
+
|
329
|
+
expected_output = build_expected_output(
|
330
|
+
color_enabled: color_enabled,
|
331
|
+
snippet: %|expect(actual).to match_array(expected)|,
|
332
|
+
expectation: proc {
|
333
|
+
line do
|
334
|
+
plain " Expected "
|
335
|
+
# rubocop:disable Metrics/LineLength
|
336
|
+
beta %|[{ foo: "bar" }, #<Double (anonymous)>, { blargh: "riddle" }]|
|
337
|
+
# rubocop:enable Metrics/LineLength
|
338
|
+
end
|
339
|
+
|
340
|
+
line do
|
341
|
+
plain "to match array with "
|
342
|
+
alpha %|#<a hash including (foo: "bar")>|
|
343
|
+
plain ", "
|
344
|
+
alpha %|#<a collection containing exactly ("zing")>|
|
345
|
+
plain " and "
|
346
|
+
alpha %|#<an object having attributes (baz: "qux")>|
|
347
|
+
end
|
348
|
+
},
|
349
|
+
diff: proc {
|
350
|
+
plain_line %| [|
|
351
|
+
plain_line %| {|
|
352
|
+
plain_line %| foo: "bar"|
|
353
|
+
plain_line %| },|
|
354
|
+
plain_line %| #<Double (anonymous)>,|
|
355
|
+
plain_line %| {|
|
356
|
+
plain_line %| blargh: "riddle"|
|
357
|
+
plain_line %| },|
|
358
|
+
alpha_line %|- #<a collection containing exactly (|
|
359
|
+
alpha_line %|- "zing"|
|
360
|
+
alpha_line %|- )>|
|
361
|
+
plain_line %| ]|
|
362
|
+
},
|
363
|
+
)
|
364
|
+
|
365
|
+
expect(program).
|
366
|
+
to produce_output_when_run(expected_output).
|
367
|
+
in_color(color_enabled)
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
4
|
-
context "when the expected value is a
|
4
|
+
context "when the expected value is a hash-including-<something>" do
|
5
5
|
context "that is small" 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|
|
@@ -172,7 +172,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
|
-
context "when the expected value includes a
|
175
|
+
context "when the expected value includes a hash-including-<something>" do
|
176
176
|
context "and the corresponding actual value is a hash" do
|
177
177
|
it "produces the correct failure message when used in the positive" do
|
178
178
|
as_both_colored_and_uncolored do |color_enabled|
|
@@ -341,7 +341,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
341
341
|
end
|
342
342
|
end
|
343
343
|
|
344
|
-
context "when the expected value is a
|
344
|
+
context "when the expected value is a collection-including-<something>" do
|
345
345
|
context "that is small" do
|
346
346
|
it "produces the correct failure message when used in the positive" do
|
347
347
|
as_both_colored_and_uncolored do |color_enabled|
|
@@ -498,7 +498,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
498
498
|
end
|
499
499
|
end
|
500
500
|
|
501
|
-
context "when the expected value includes a
|
501
|
+
context "when the expected value includes a collection-including-<something>" do
|
502
502
|
context "and the corresponding actual value is an array" do
|
503
503
|
it "produces the correct failure message when used in the positive" do
|
504
504
|
as_both_colored_and_uncolored do |color_enabled|
|
@@ -647,7 +647,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
647
647
|
end
|
648
648
|
end
|
649
649
|
|
650
|
-
context "when the expected value is
|
650
|
+
context "when the expected value is an object-having-attributes" do
|
651
651
|
context "that is small" do
|
652
652
|
it "produces the correct failure message when used in the positive" do
|
653
653
|
as_both_colored_and_uncolored do |color_enabled|
|
@@ -830,7 +830,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
830
830
|
end
|
831
831
|
end
|
832
832
|
|
833
|
-
context "when the expected value includes
|
833
|
+
context "when the expected value includes an object-having-attributes" do
|
834
834
|
it "produces the correct failure message when used in the positive" do
|
835
835
|
as_both_colored_and_uncolored do |color_enabled|
|
836
836
|
snippet = <<~TEST.strip
|
@@ -953,7 +953,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
953
953
|
end
|
954
954
|
end
|
955
955
|
|
956
|
-
context "when the expected value is
|
956
|
+
context "when the expected value is a collection-containing-exactly-<something>" do
|
957
957
|
context "that is small" do
|
958
958
|
it "produces the correct failure message when used in the positive" do
|
959
959
|
as_both_colored_and_uncolored do |color_enabled|
|
@@ -1108,7 +1108,7 @@ RSpec.describe "Integration with RSpec's #match matcher", type: :integration do
|
|
1108
1108
|
end
|
1109
1109
|
end
|
1110
1110
|
|
1111
|
-
context "when the expected value includes
|
1111
|
+
context "when the expected value includes a collection-containing-exactly-<something>" do
|
1112
1112
|
context "and the corresponding actual value is an array" do
|
1113
1113
|
it "produces the correct failure message when used in the positive" do
|
1114
1114
|
as_both_colored_and_uncolored do |color_enabled|
|