super_diff 0.4.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +64 -24
- data/lib/super_diff.rb +20 -17
- data/lib/super_diff/active_record.rb +20 -24
- 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/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/colorized_document_extensions.rb +4 -4
- data/lib/super_diff/configuration.rb +70 -0
- data/lib/super_diff/csi.rb +2 -1
- 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 +3 -3
- 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 +7 -7
- 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 +3 -9
- data/lib/super_diff/equality_matchers/base.rb +1 -1
- data/lib/super_diff/equality_matchers/default.rb +3 -9
- data/lib/super_diff/equality_matchers/defaults.rb +12 -0
- data/lib/super_diff/equality_matchers/hash.rb +3 -9
- data/lib/super_diff/equality_matchers/main.rb +21 -0
- data/lib/super_diff/equality_matchers/multiline_string.rb +3 -9
- data/lib/super_diff/equality_matchers/primitive.rb +2 -2
- data/lib/super_diff/equality_matchers/singleline_string.rb +2 -2
- 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/gem_version.rb +45 -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_sequences → operation_trees}/base.rb +9 -1
- 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/recursion_guard.rb +2 -0
- data/lib/super_diff/rspec.rb +49 -13
- 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/collection_containing_exactly.rb +2 -7
- data/lib/super_diff/rspec/differs/collection_including.rb +2 -7
- data/lib/super_diff/rspec/differs/hash_including.rb +2 -7
- data/lib/super_diff/rspec/differs/object_having_attributes.rb +2 -7
- data/lib/super_diff/rspec/matcher_text_builders/base.rb +7 -7
- data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +6 -6
- data/lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb +1 -1
- data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +4 -4
- data/lib/super_diff/rspec/matcher_text_builders/match.rb +1 -1
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +1 -1
- data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +6 -6
- data/lib/super_diff/rspec/matcher_text_template.rb +1 -1
- data/lib/super_diff/rspec/monkey_patches.rb +23 -14
- data/lib/super_diff/rspec/object_inspection.rb +0 -1
- data/lib/super_diff/rspec/object_inspection/inspectors.rb +16 -0
- 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 +15 -9
- data/lib/super_diff/rspec/object_inspection/inspectors/hash_including.rb +20 -10
- 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 +20 -11
- 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 +17 -6
- data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/collection_including.rb +2 -2
- data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/hash_including.rb +3 -11
- data/lib/super_diff/rspec/{operational_sequencers → operation_tree_builders}/object_having_attributes.rb +4 -8
- data/lib/super_diff/version.rb +1 -1
- data/spec/examples.txt +393 -393
- data/spec/integration/rspec/be_falsey_matcher_spec.rb +10 -10
- data/spec/integration/rspec/be_matcher_spec.rb +100 -100
- data/spec/integration/rspec/be_nil_matcher_spec.rb +10 -10
- data/spec/integration/rspec/be_predicate_matcher_spec.rb +103 -103
- data/spec/integration/rspec/be_truthy_matcher_spec.rb +10 -10
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +107 -107
- data/spec/integration/rspec/eq_matcher_spec.rb +230 -230
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +360 -233
- data/spec/integration/rspec/have_predicate_matcher_spec.rb +65 -65
- data/spec/integration/rspec/include_matcher_spec.rb +73 -73
- data/spec/integration/rspec/match_array_matcher_spec.rb +149 -107
- data/spec/integration/rspec/match_matcher_spec.rb +274 -274
- data/spec/integration/rspec/raise_error_matcher_spec.rb +86 -86
- data/spec/integration/rspec/respond_to_matcher_spec.rb +240 -240
- data/spec/integration/rspec/third_party_matcher_spec.rb +8 -8
- data/spec/integration/rspec/unhandled_errors_spec.rb +69 -13
- data/spec/spec_helper.rb +22 -13
- data/spec/support/command_runner.rb +3 -0
- data/spec/support/integration/helpers.rb +15 -95
- data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +15 -30
- data/spec/support/integration/test_programs/base.rb +122 -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_active_support.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/shipping_address.rb +10 -14
- data/spec/support/object_id.rb +6 -5
- data/spec/support/shared_examples/active_record.rb +108 -108
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +196 -232
- data/spec/tmp/integration_spec.rb +15 -0
- data/spec/unit/{equality_matcher_spec.rb → equality_matchers/main_spec.rb} +518 -362
- data/spec/unit/object_inspection_spec.rb +77 -1
- data/super_diff.gemspec +3 -2
- metadata +83 -54
- 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/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/object_inspection/map_extension.rb +0 -23
- data/lib/super_diff/rspec/operational_sequencers.rb +0 -22
@@ -16,11 +16,11 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
16
16
|
snippet: snippet,
|
17
17
|
expectation: proc {
|
18
18
|
line do
|
19
|
-
plain
|
20
|
-
|
21
|
-
plain
|
22
|
-
|
23
|
-
plain
|
19
|
+
plain %|Expected |
|
20
|
+
actual %|:words|
|
21
|
+
plain %| to respond to |
|
22
|
+
expected %|has_power?|
|
23
|
+
plain %|.|
|
24
24
|
end
|
25
25
|
},
|
26
26
|
)
|
@@ -32,7 +32,7 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
context "when the inspected version of the actual
|
35
|
+
context "when the inspected version of the actual value is long" do
|
36
36
|
it "produces the correct failure message" do
|
37
37
|
as_both_colored_and_uncolored do |color_enabled|
|
38
38
|
snippet = <<~TEST.strip
|
@@ -50,13 +50,13 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
50
50
|
newline_before_expectation: true,
|
51
51
|
expectation: proc {
|
52
52
|
line do
|
53
|
-
plain
|
54
|
-
|
53
|
+
plain %| Expected |
|
54
|
+
actual %|{ a: "lot", of: "keys", and: "things", like: "that", lets: "add", more: "keys" }|
|
55
55
|
end
|
56
56
|
|
57
57
|
line do
|
58
|
-
plain
|
59
|
-
|
58
|
+
plain %|to respond to |
|
59
|
+
expected %|has_mapping?|
|
60
60
|
end
|
61
61
|
},
|
62
62
|
)
|
@@ -71,7 +71,7 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
71
71
|
|
72
72
|
context "when the predicate method exists on the object" do
|
73
73
|
context "but is private" do
|
74
|
-
context "when the inspected version of the actual
|
74
|
+
context "when the inspected version of the actual value is short" do
|
75
75
|
it "produces the correct failure message" do
|
76
76
|
as_both_colored_and_uncolored do |color_enabled|
|
77
77
|
snippet = <<~TEST.strip
|
@@ -91,11 +91,11 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
91
91
|
snippet: %|expect(Robot.new).to have_arms|,
|
92
92
|
expectation: proc {
|
93
93
|
line do
|
94
|
-
plain
|
95
|
-
|
96
|
-
plain
|
97
|
-
|
98
|
-
plain
|
94
|
+
plain %|Expected |
|
95
|
+
actual %|#<Robot>|
|
96
|
+
plain %| to have a public method |
|
97
|
+
expected %|has_arms?|
|
98
|
+
plain %|.|
|
99
99
|
end
|
100
100
|
},
|
101
101
|
)
|
@@ -108,7 +108,7 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
context "when the inspected version of the actual
|
111
|
+
context "when the inspected version of the actual value is long" do
|
112
112
|
it "produces the correct failure message" do
|
113
113
|
as_both_colored_and_uncolored do |color_enabled|
|
114
114
|
snippet = <<~TEST.strip
|
@@ -131,13 +131,13 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
131
131
|
newline_before_expectation: true,
|
132
132
|
expectation: proc {
|
133
133
|
line do
|
134
|
-
plain
|
135
|
-
|
134
|
+
plain %| Expected |
|
135
|
+
actual %|{ a: "lot", of: "keys", and: "things", like: "that", lets: "add", more: "keys" }|
|
136
136
|
end
|
137
137
|
|
138
138
|
line do
|
139
|
-
plain
|
140
|
-
|
139
|
+
plain %|to have a public method |
|
140
|
+
expected %|has_mapping?|
|
141
141
|
end
|
142
142
|
},
|
143
143
|
)
|
@@ -154,7 +154,7 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
154
154
|
context "and is public" do
|
155
155
|
context "and returns false" do
|
156
156
|
context "and takes arguments" do
|
157
|
-
context "when the inspected version of the actual
|
157
|
+
context "when the inspected version of the actual value is short" do
|
158
158
|
it "produces the correct failure message" do
|
159
159
|
as_both_colored_and_uncolored do |color_enabled|
|
160
160
|
snippet = <<~TEST.strip
|
@@ -174,11 +174,11 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
174
174
|
snippet: %|expect(Drink.new).to have_ingredients(:vodka)|,
|
175
175
|
expectation: proc {
|
176
176
|
line do
|
177
|
-
plain
|
178
|
-
|
179
|
-
plain
|
180
|
-
|
181
|
-
plain
|
177
|
+
plain %|Expected |
|
178
|
+
actual %|#<Drink>|
|
179
|
+
plain %| to return a truthy result for |
|
180
|
+
expected %|has_ingredients?(:vodka)|
|
181
|
+
plain %|.|
|
182
182
|
end
|
183
183
|
},
|
184
184
|
)
|
@@ -191,7 +191,7 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
194
|
-
context "when the inspected version of the actual
|
194
|
+
context "when the inspected version of the actual value is long" do
|
195
195
|
it "produces the correct failure message" do
|
196
196
|
as_both_colored_and_uncolored do |color_enabled|
|
197
197
|
snippet = <<~TEST.strip
|
@@ -214,13 +214,13 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
214
214
|
newline_before_expectation: true,
|
215
215
|
expectation: proc {
|
216
216
|
line do
|
217
|
-
plain
|
218
|
-
|
217
|
+
plain %| Expected |
|
218
|
+
actual %|{ a: "lot", of: "keys", and: "things", like: "that", lets: "add", more: "keys" }|
|
219
219
|
end
|
220
220
|
|
221
221
|
line do
|
222
|
-
plain
|
223
|
-
|
222
|
+
plain %|to return a truthy result for |
|
223
|
+
expected %|has_contents?("keys", "upon", "keys")|
|
224
224
|
end
|
225
225
|
},
|
226
226
|
)
|
@@ -235,7 +235,7 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
235
235
|
end
|
236
236
|
|
237
237
|
context "and takes no arguments" do
|
238
|
-
context "when the inspected version of the actual
|
238
|
+
context "when the inspected version of the actual value is short" do
|
239
239
|
it "produces the correct failure message" do
|
240
240
|
as_both_colored_and_uncolored do |color_enabled|
|
241
241
|
snippet = <<~TEST.strip
|
@@ -255,11 +255,11 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
255
255
|
snippet: %|expect(Robot.new).to have_arms|,
|
256
256
|
expectation: proc {
|
257
257
|
line do
|
258
|
-
plain
|
259
|
-
|
260
|
-
plain
|
261
|
-
|
262
|
-
plain
|
258
|
+
plain %|Expected |
|
259
|
+
actual %|#<Robot>|
|
260
|
+
plain %| to return a truthy result for |
|
261
|
+
expected %|has_arms?|
|
262
|
+
plain %|.|
|
263
263
|
end
|
264
264
|
},
|
265
265
|
)
|
@@ -272,7 +272,7 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
272
272
|
end
|
273
273
|
end
|
274
274
|
|
275
|
-
context "when the inspected version of the actual
|
275
|
+
context "when the inspected version of the actual value is long" do
|
276
276
|
it "produces the correct failure message" do
|
277
277
|
as_both_colored_and_uncolored do |color_enabled|
|
278
278
|
snippet = <<~TEST.strip
|
@@ -295,13 +295,13 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
295
295
|
newline_before_expectation: true,
|
296
296
|
expectation: proc {
|
297
297
|
line do
|
298
|
-
plain
|
299
|
-
|
298
|
+
plain %| Expected |
|
299
|
+
actual %|{ a: "lot", of: "keys", and: "things", like: "that", lets: "add", more: "keys" }|
|
300
300
|
end
|
301
301
|
|
302
302
|
line do
|
303
|
-
plain
|
304
|
-
|
303
|
+
plain %|to return a truthy result for |
|
304
|
+
expected %|has_mapping?|
|
305
305
|
end
|
306
306
|
},
|
307
307
|
)
|
@@ -318,7 +318,7 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
318
318
|
|
319
319
|
context "and returns true" do
|
320
320
|
context "and takes arguments" do
|
321
|
-
context "when the inspected version of the actual
|
321
|
+
context "when the inspected version of the actual value is short" do
|
322
322
|
it "produces the correct failure message" do
|
323
323
|
as_both_colored_and_uncolored do |color_enabled|
|
324
324
|
snippet = <<~TEST.strip
|
@@ -338,11 +338,11 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
338
338
|
snippet: %|expect(Drink.new).not_to have_ingredients(:vodka)|,
|
339
339
|
expectation: proc {
|
340
340
|
line do
|
341
|
-
plain
|
342
|
-
|
343
|
-
plain
|
344
|
-
|
345
|
-
plain
|
341
|
+
plain %|Expected |
|
342
|
+
actual %|#<Drink>|
|
343
|
+
plain %| not to return a truthy result for |
|
344
|
+
expected %|has_ingredients?(:vodka)|
|
345
|
+
plain %|.|
|
346
346
|
end
|
347
347
|
},
|
348
348
|
)
|
@@ -355,7 +355,7 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
355
355
|
end
|
356
356
|
end
|
357
357
|
|
358
|
-
context "when the inspected version of the actual
|
358
|
+
context "when the inspected version of the actual value is long" do
|
359
359
|
it "produces the correct failure message" do
|
360
360
|
as_both_colored_and_uncolored do |color_enabled|
|
361
361
|
snippet = <<~TEST.strip
|
@@ -378,13 +378,13 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
378
378
|
newline_before_expectation: true,
|
379
379
|
expectation: proc {
|
380
380
|
line do
|
381
|
-
plain
|
382
|
-
|
381
|
+
plain %| Expected |
|
382
|
+
actual %|{ a: "lot", of: "keys", and: "things", like: "that", lets: "add", more: "keys" }|
|
383
383
|
end
|
384
384
|
|
385
385
|
line do
|
386
|
-
plain
|
387
|
-
|
386
|
+
plain %|not to return a truthy result for |
|
387
|
+
expected %|has_contents?("keys", "upon", "keys")|
|
388
388
|
end
|
389
389
|
},
|
390
390
|
)
|
@@ -399,7 +399,7 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
399
399
|
end
|
400
400
|
|
401
401
|
context "and takes no arguments" do
|
402
|
-
context "when the inspected version of the actual
|
402
|
+
context "when the inspected version of the actual value is short" do
|
403
403
|
it "produces the correct failure message when used in the negative" do
|
404
404
|
as_both_colored_and_uncolored do |color_enabled|
|
405
405
|
snippet = <<~TEST.strip
|
@@ -419,11 +419,11 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
419
419
|
snippet: %|expect(Robot.new).not_to have_arms|,
|
420
420
|
expectation: proc {
|
421
421
|
line do
|
422
|
-
plain
|
423
|
-
|
424
|
-
plain
|
425
|
-
|
426
|
-
plain
|
422
|
+
plain %|Expected |
|
423
|
+
actual %|#<Robot>|
|
424
|
+
plain %| not to return a truthy result for |
|
425
|
+
expected %|has_arms?|
|
426
|
+
plain %|.|
|
427
427
|
end
|
428
428
|
},
|
429
429
|
)
|
@@ -436,7 +436,7 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
436
436
|
end
|
437
437
|
end
|
438
438
|
|
439
|
-
context "when the inspected version of the actual
|
439
|
+
context "when the inspected version of the actual value is long" do
|
440
440
|
it "produces the correct failure message when used in the negative" do
|
441
441
|
as_both_colored_and_uncolored do |color_enabled|
|
442
442
|
snippet = <<~TEST.strip
|
@@ -459,13 +459,13 @@ RSpec.describe "Integration with RSpec's #have_<predicate> matcher", type: :inte
|
|
459
459
|
newline_before_expectation: true,
|
460
460
|
expectation: proc {
|
461
461
|
line do
|
462
|
-
plain
|
463
|
-
|
462
|
+
plain %| Expected |
|
463
|
+
actual %|{ a: "lot", of: "keys", and: "things", like: "that", lets: "add", more: "keys" }|
|
464
464
|
end
|
465
465
|
|
466
466
|
line do
|
467
|
-
plain
|
468
|
-
|
467
|
+
plain %|not to return a truthy result for |
|
468
|
+
expected %|has_mapping?|
|
469
469
|
end
|
470
470
|
},
|
471
471
|
)
|
@@ -7,7 +7,7 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
7
7
|
as_both_colored_and_uncolored do |color_enabled|
|
8
8
|
snippet = <<~TEST.strip
|
9
9
|
expected = ["Marty", "Einie"]
|
10
|
-
actual
|
10
|
+
actual = ["Marty", "Jennifer", "Doc"]
|
11
11
|
expect(actual).to include(*expected)
|
12
12
|
TEST
|
13
13
|
program = make_plain_test_program(
|
@@ -20,21 +20,21 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
20
20
|
snippet: %|expect(actual).to include(*expected)|,
|
21
21
|
expectation: proc {
|
22
22
|
line do
|
23
|
-
plain
|
24
|
-
|
25
|
-
plain
|
26
|
-
|
27
|
-
plain
|
23
|
+
plain %|Expected |
|
24
|
+
actual %|["Marty", "Jennifer", "Doc"]|
|
25
|
+
plain %| to include |
|
26
|
+
expected %|"Einie"|
|
27
|
+
plain %|.|
|
28
28
|
end
|
29
29
|
},
|
30
30
|
diff: proc {
|
31
|
-
plain_line
|
32
|
-
plain_line
|
33
|
-
plain_line
|
34
|
-
# plain_line
|
35
|
-
plain_line
|
36
|
-
|
37
|
-
plain_line
|
31
|
+
plain_line %| [|
|
32
|
+
plain_line %| "Marty",|
|
33
|
+
plain_line %| "Jennifer",|
|
34
|
+
# plain_line %| "Doc",| # FIXME
|
35
|
+
plain_line %| "Doc"|
|
36
|
+
expected_line %|- "Einie"|
|
37
|
+
plain_line %| ]|
|
38
38
|
},
|
39
39
|
)
|
40
40
|
|
@@ -60,11 +60,11 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
60
60
|
snippet: %|expect(values).not_to include(*values)|,
|
61
61
|
expectation: proc {
|
62
62
|
line do
|
63
|
-
plain
|
64
|
-
|
65
|
-
plain
|
66
|
-
|
67
|
-
plain
|
63
|
+
plain %|Expected |
|
64
|
+
actual %|["Marty", "Einie"]|
|
65
|
+
plain %| not to include |
|
66
|
+
expected %|"Marty" and "Einie"|
|
67
|
+
plain %|.|
|
68
68
|
end
|
69
69
|
},
|
70
70
|
)
|
@@ -88,7 +88,7 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
88
88
|
"George McFly",
|
89
89
|
"Lorraine McFly"
|
90
90
|
]
|
91
|
-
actual
|
91
|
+
actual = [
|
92
92
|
"Marty McFly",
|
93
93
|
"Doc Brown",
|
94
94
|
"Einie",
|
@@ -106,25 +106,25 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
106
106
|
snippet: %|expect(actual).to include(*expected)|,
|
107
107
|
expectation: proc {
|
108
108
|
line do
|
109
|
-
plain
|
110
|
-
|
109
|
+
plain %| Expected |
|
110
|
+
actual %|["Marty McFly", "Doc Brown", "Einie", "Lorraine McFly"]|
|
111
111
|
end
|
112
112
|
|
113
113
|
line do
|
114
|
-
plain
|
115
|
-
|
114
|
+
plain %|to include |
|
115
|
+
expected %|"Biff Tannen" and "George McFly"|
|
116
116
|
end
|
117
117
|
},
|
118
118
|
diff: proc {
|
119
|
-
plain_line
|
120
|
-
plain_line
|
121
|
-
plain_line
|
122
|
-
plain_line
|
123
|
-
# plain_line
|
124
|
-
plain_line
|
125
|
-
|
126
|
-
|
127
|
-
plain_line
|
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
128
|
},
|
129
129
|
)
|
130
130
|
|
@@ -143,7 +143,7 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
143
143
|
"Einie",
|
144
144
|
"Lorraine McFly"
|
145
145
|
]
|
146
|
-
actual
|
146
|
+
actual = [
|
147
147
|
"Marty McFly",
|
148
148
|
"Doc Brown",
|
149
149
|
"Einie",
|
@@ -164,13 +164,13 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
164
164
|
newline_before_expectation: true,
|
165
165
|
expectation: proc {
|
166
166
|
line do
|
167
|
-
plain
|
168
|
-
|
167
|
+
plain %| Expected |
|
168
|
+
actual %|["Marty McFly", "Doc Brown", "Einie", "Biff Tannen", "George McFly", "Lorraine McFly"]|
|
169
169
|
end
|
170
170
|
|
171
171
|
line do
|
172
|
-
plain
|
173
|
-
|
172
|
+
plain %|not to include |
|
173
|
+
expected %|"Marty McFly", "Doc Brown", "Einie", and "Lorraine McFly"|
|
174
174
|
end
|
175
175
|
},
|
176
176
|
)
|
@@ -189,7 +189,7 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
189
189
|
as_both_colored_and_uncolored do |color_enabled|
|
190
190
|
snippet = <<~TEST.strip
|
191
191
|
expected = { city: "Hill Valley", state: "CA" }
|
192
|
-
actual
|
192
|
+
actual = { city: "Burbank", zip: "90210" }
|
193
193
|
expect(actual).to include(expected)
|
194
194
|
TEST
|
195
195
|
program = make_plain_test_program(
|
@@ -202,22 +202,22 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
202
202
|
snippet: %|expect(actual).to include(expected)|,
|
203
203
|
expectation: proc {
|
204
204
|
line do
|
205
|
-
plain
|
206
|
-
|
207
|
-
plain
|
208
|
-
|
209
|
-
plain
|
205
|
+
plain %|Expected |
|
206
|
+
actual %|{ city: "Burbank", zip: "90210" }|
|
207
|
+
plain %| to include |
|
208
|
+
expected %|(city: "Hill Valley", state: "CA")|
|
209
|
+
plain %|.|
|
210
210
|
end
|
211
211
|
},
|
212
212
|
diff: proc {
|
213
|
-
plain_line
|
214
|
-
|
215
|
-
|
213
|
+
plain_line %| {|
|
214
|
+
expected_line %|- city: "Hill Valley",|
|
215
|
+
actual_line %|+ city: "Burbank",|
|
216
216
|
# FIXME
|
217
|
-
#
|
218
|
-
|
219
|
-
|
220
|
-
plain_line
|
217
|
+
# expected_line %|- state: "CA",|
|
218
|
+
expected_line %|- state: "CA"|
|
219
|
+
plain_line %| zip: "90210"|
|
220
|
+
plain_line %| }|
|
221
221
|
},
|
222
222
|
)
|
223
223
|
|
@@ -231,7 +231,7 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
231
231
|
as_both_colored_and_uncolored do |color_enabled|
|
232
232
|
snippet = <<~TEST.strip
|
233
233
|
expected = { city: "Burbank" }
|
234
|
-
actual
|
234
|
+
actual = { city: "Burbank", zip: "90210" }
|
235
235
|
expect(actual).not_to include(expected)
|
236
236
|
TEST
|
237
237
|
program = make_plain_test_program(
|
@@ -244,11 +244,11 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
244
244
|
snippet: %|expect(actual).not_to include(expected)|,
|
245
245
|
expectation: proc {
|
246
246
|
line do
|
247
|
-
plain
|
248
|
-
|
249
|
-
plain
|
250
|
-
|
251
|
-
plain
|
247
|
+
plain %|Expected |
|
248
|
+
actual %|{ city: "Burbank", zip: "90210" }|
|
249
|
+
plain %| not to include |
|
250
|
+
expected %|(city: "Burbank")|
|
251
|
+
plain %|.|
|
252
252
|
end
|
253
253
|
},
|
254
254
|
)
|
@@ -268,7 +268,7 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
268
268
|
city: "Hill Valley",
|
269
269
|
zip: "90382"
|
270
270
|
}
|
271
|
-
actual
|
271
|
+
actual = {
|
272
272
|
city: "Burbank",
|
273
273
|
state: "CA",
|
274
274
|
zip: "90210"
|
@@ -285,23 +285,23 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
285
285
|
snippet: %|expect(actual).to include(expected)|,
|
286
286
|
expectation: proc {
|
287
287
|
line do
|
288
|
-
plain
|
289
|
-
|
288
|
+
plain %| Expected |
|
289
|
+
actual %|{ city: "Burbank", state: "CA", zip: "90210" }|
|
290
290
|
end
|
291
291
|
|
292
292
|
line do
|
293
|
-
plain
|
294
|
-
|
293
|
+
plain %|to include |
|
294
|
+
expected %|(city: "Hill Valley", zip: "90382")|
|
295
295
|
end
|
296
296
|
},
|
297
297
|
diff: proc {
|
298
|
-
plain_line
|
299
|
-
|
300
|
-
|
301
|
-
plain_line
|
302
|
-
|
303
|
-
|
304
|
-
plain_line
|
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
305
|
},
|
306
306
|
)
|
307
307
|
|
@@ -315,7 +315,7 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
315
315
|
as_both_colored_and_uncolored do |color_enabled|
|
316
316
|
snippet = <<~TEST.strip
|
317
317
|
expected = { city: "Hill Valley", state: "CA" }
|
318
|
-
actual
|
318
|
+
actual = { city: "Hill Valley", state: "CA", zip: "90210" }
|
319
319
|
expect(actual).not_to include(expected)
|
320
320
|
TEST
|
321
321
|
program = make_plain_test_program(
|
@@ -329,13 +329,13 @@ RSpec.describe "Integration with RSpec's #include matcher", type: :integration d
|
|
329
329
|
newline_before_expectation: true,
|
330
330
|
expectation: proc {
|
331
331
|
line do
|
332
|
-
plain
|
333
|
-
|
332
|
+
plain %| Expected |
|
333
|
+
actual %|{ city: "Hill Valley", state: "CA", zip: "90210" }|
|
334
334
|
end
|
335
335
|
|
336
336
|
line do
|
337
|
-
plain
|
338
|
-
|
337
|
+
plain %|not to include |
|
338
|
+
expected %|(city: "Hill Valley", state: "CA")|
|
339
339
|
end
|
340
340
|
},
|
341
341
|
)
|