super_diff 0.10.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/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_model.rb +24 -12
- data/lib/super_diff/active_record/object_inspection/inspection_tree_builders/active_record_relation.rb +15 -6
- data/lib/super_diff/active_support/object_inspection/inspection_tree_builders/hash_with_indifferent_access.rb +23 -8
- 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 +4 -0
- data/lib/super_diff/active_support.rb +2 -1
- data/lib/super_diff/differs/date_like.rb +15 -0
- data/lib/super_diff/differs/defaults.rb +1 -0
- data/lib/super_diff/differs.rb +1 -0
- data/lib/super_diff/errors.rb +0 -4
- data/lib/super_diff/object_inspection/inspection_tree.rb +25 -20
- data/lib/super_diff/object_inspection/inspection_tree_builders/array.rb +31 -12
- data/lib/super_diff/object_inspection/inspection_tree_builders/custom_object.rb +19 -9
- 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 +46 -21
- data/lib/super_diff/object_inspection/inspection_tree_builders/defaults.rb +1 -0
- data/lib/super_diff/object_inspection/inspection_tree_builders/hash.rb +39 -14
- 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 +31 -20
- data/lib/super_diff/object_inspection/inspection_tree_builders.rb +4 -0
- data/lib/super_diff/object_inspection/nodes/as_lines_when_rendering_to_lines.rb +3 -2
- data/lib/super_diff/operation_tree_builders/date_like.rb +15 -0
- data/lib/super_diff/operation_tree_builders/defaults.rb +1 -1
- data/lib/super_diff/operation_tree_builders.rb +1 -0
- data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +3 -7
- data/lib/super_diff/rspec/monkey_patches.rb +59 -8
- 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 +19 -13
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb +30 -26
- 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 +19 -14
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb +9 -10
- data/lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb +9 -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 +4 -0
- data/lib/super_diff/rspec.rb +10 -9
- data/lib/super_diff/version.rb +1 -1
- data/lib/super_diff.rb +9 -0
- data/spec/examples.txt +543 -493
- data/spec/integration/rails/engines_spec.rb +8 -3
- data/spec/integration/rspec/contain_exactly_matcher_spec.rb +19 -19
- data/spec/integration/rspec/eq_matcher_spec.rb +111 -39
- data/spec/integration/rspec/generic_describable_matchers_spec.rb +177 -0
- data/spec/integration/rspec/have_attributes_matcher_spec.rb +25 -25
- data/spec/integration/rspec/include_matcher_spec.rb +23 -23
- data/spec/integration/rspec/magic_metadata_spec.rb +51 -0
- data/spec/integration/rspec/match_array_matcher_spec.rb +30 -30
- data/spec/integration/rspec/match_matcher_spec.rb +93 -93
- data/spec/integration/rspec/raise_error_matcher_spec.rb +813 -69
- data/spec/internal/log/test.log +0 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/integration/helpers.rb +15 -10
- data/spec/support/integration/matchers.rb +34 -0
- data/spec/support/integration/test_programs/base.rb +6 -6
- data/spec/support/integration/test_programs/rspec_rails_engine.rb +3 -13
- data/spec/support/shared_examples/active_record.rb +33 -33
- data/spec/support/shared_examples/active_support.rb +125 -4
- data/spec/support/shared_examples/elided_diffs.rb +48 -48
- data/spec/support/shared_examples/hash_with_indifferent_access.rb +88 -88
- data/spec/support/shared_examples/key.rb +10 -10
- data/spec/unit/active_support/object_inspection_spec.rb +170 -0
- data/spec/unit/rspec/matchers/raise_error_spec.rb +43 -11
- data/spec/unit/rspec/object_inspection/rspec_matcher_spec.rb +91 -0
- data/spec/unit/rspec/object_inspection_spec.rb +2 -2
- data/spec/unit/super_diff_spec.rb +64 -0
- metadata +17 -4
- 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
@@ -8,8 +8,8 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher",
|
|
8
8
|
it "produces the correct output when used in the positive" do
|
9
9
|
as_both_colored_and_uncolored do |color_enabled|
|
10
10
|
snippet = <<~TEST.strip
|
11
|
-
expected = { name: "b" }
|
12
11
|
actual = SuperDiff::Test::Person.new(name: "a", age: 9)
|
12
|
+
expected = { name: "b" }
|
13
13
|
expect(actual).to have_attributes(expected)
|
14
14
|
TEST
|
15
15
|
program =
|
@@ -49,8 +49,8 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher",
|
|
49
49
|
it "produces the correct output when used in the negative" do
|
50
50
|
as_both_colored_and_uncolored do |color_enabled|
|
51
51
|
snippet = <<~TEST.strip
|
52
|
-
expected = { name: "a" }
|
53
52
|
actual = SuperDiff::Test::Person.new(name: "a", age: 9)
|
53
|
+
expected = { name: "a" }
|
54
54
|
expect(actual).not_to have_attributes(expected)
|
55
55
|
TEST
|
56
56
|
program =
|
@@ -83,8 +83,8 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher",
|
|
83
83
|
it "produces the correct output" do
|
84
84
|
as_both_colored_and_uncolored do |color_enabled|
|
85
85
|
snippet = <<~TEST.strip
|
86
|
-
expected = { name: "b", foo: "bar" }
|
87
86
|
actual = SuperDiff::Test::Person.new(name: "a", age: 9)
|
87
|
+
expected = { name: "b", foo: "bar" }
|
88
88
|
expect(actual).to have_attributes(expected)
|
89
89
|
TEST
|
90
90
|
program =
|
@@ -131,12 +131,6 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher",
|
|
131
131
|
it "produces the correct output when used in the positive" do
|
132
132
|
as_both_colored_and_uncolored do |color_enabled|
|
133
133
|
snippet = <<~TEST.strip
|
134
|
-
expected = {
|
135
|
-
line_1: "123 Main St.",
|
136
|
-
city: "Oakland",
|
137
|
-
state: "CA",
|
138
|
-
zip: "91234"
|
139
|
-
}
|
140
134
|
actual = SuperDiff::Test::ShippingAddress.new(
|
141
135
|
line_1: "456 Ponderosa Ct.",
|
142
136
|
line_2: nil,
|
@@ -144,6 +138,12 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher",
|
|
144
138
|
state: "CA",
|
145
139
|
zip: "90382"
|
146
140
|
)
|
141
|
+
expected = {
|
142
|
+
line_1: "123 Main St.",
|
143
|
+
city: "Oakland",
|
144
|
+
state: "CA",
|
145
|
+
zip: "91234"
|
146
|
+
}
|
147
147
|
expect(actual).to have_attributes(expected)
|
148
148
|
TEST
|
149
149
|
program =
|
@@ -189,19 +189,19 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher",
|
|
189
189
|
it "produces the correct output when used in the negative" do
|
190
190
|
as_both_colored_and_uncolored do |color_enabled|
|
191
191
|
snippet = <<~TEST.strip
|
192
|
-
|
192
|
+
actual = SuperDiff::Test::ShippingAddress.new(
|
193
193
|
line_1: "123 Main St.",
|
194
|
+
line_2: nil,
|
194
195
|
city: "Oakland",
|
195
196
|
state: "CA",
|
196
197
|
zip: "91234"
|
197
|
-
|
198
|
-
|
198
|
+
)
|
199
|
+
expected = {
|
199
200
|
line_1: "123 Main St.",
|
200
|
-
line_2: nil,
|
201
201
|
city: "Oakland",
|
202
202
|
state: "CA",
|
203
203
|
zip: "91234"
|
204
|
-
|
204
|
+
}
|
205
205
|
expect(actual).not_to have_attributes(expected)
|
206
206
|
TEST
|
207
207
|
program =
|
@@ -237,6 +237,13 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher",
|
|
237
237
|
it "produces the correct output" do
|
238
238
|
as_both_colored_and_uncolored do |color_enabled|
|
239
239
|
snippet = <<~TEST.strip
|
240
|
+
actual = SuperDiff::Test::ShippingAddress.new(
|
241
|
+
line_1: "456 Ponderosa Ct.",
|
242
|
+
line_2: nil,
|
243
|
+
city: "Hill Valley",
|
244
|
+
state: "CA",
|
245
|
+
zip: "90382"
|
246
|
+
)
|
240
247
|
expected = {
|
241
248
|
line_1: "123 Main St.",
|
242
249
|
city: "Oakland",
|
@@ -245,13 +252,6 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher",
|
|
245
252
|
foo: "bar",
|
246
253
|
baz: "qux"
|
247
254
|
}
|
248
|
-
actual = SuperDiff::Test::ShippingAddress.new(
|
249
|
-
line_1: "456 Ponderosa Ct.",
|
250
|
-
line_2: nil,
|
251
|
-
city: "Hill Valley",
|
252
|
-
state: "CA",
|
253
|
-
zip: "90382"
|
254
|
-
)
|
255
255
|
expect(actual).to have_attributes(expected)
|
256
256
|
TEST
|
257
257
|
program =
|
@@ -307,8 +307,8 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher",
|
|
307
307
|
it "displays the diff as if we were comparing hashes" do
|
308
308
|
as_both_colored_and_uncolored do |color_enabled|
|
309
309
|
snippet = <<~TEST.strip
|
310
|
-
expected = { name: "Elliot", age: 32 }
|
311
310
|
actual = {}
|
311
|
+
expected = { name: "Elliot", age: 32 }
|
312
312
|
expect(actual).to have_attributes(expected)
|
313
313
|
TEST
|
314
314
|
|
@@ -347,11 +347,12 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher",
|
|
347
347
|
end
|
348
348
|
end
|
349
349
|
|
350
|
-
# TODO: Add as many
|
351
|
-
context "that contains
|
350
|
+
# TODO: Add as many RSpec matchers as we can here
|
351
|
+
context "that contains RSpec matchers" do
|
352
352
|
it "displays the hash correctly" do
|
353
353
|
as_both_colored_and_uncolored do |color_enabled|
|
354
354
|
snippet = <<~TEST.strip
|
355
|
+
actual = {}
|
355
356
|
expected = {
|
356
357
|
name: "Elliot",
|
357
358
|
shipping_address: an_object_having_attributes(
|
@@ -365,7 +366,6 @@ RSpec.describe "Integration with RSpec's #have_attributes matcher",
|
|
365
366
|
data: a_hash_including(active: true),
|
366
367
|
created_at: a_value_within(1).of(Time.utc(2020, 4, 9))
|
367
368
|
}
|
368
|
-
actual = {}
|
369
369
|
|
370
370
|
expect(actual).to have_attributes(expected)
|
371
371
|
TEST
|
@@ -7,8 +7,8 @@ RSpec.describe "Integration with RSpec's #include matcher",
|
|
7
7
|
it "produces the correct failure message when used in the positive" do
|
8
8
|
as_both_colored_and_uncolored do |color_enabled|
|
9
9
|
snippet = <<~TEST.strip
|
10
|
-
expected = ["Marty", "Einie"]
|
11
10
|
actual = ["Marty", "Jennifer", "Doc"]
|
11
|
+
expected = ["Marty", "Einie"]
|
12
12
|
expect(actual).to include(*expected)
|
13
13
|
TEST
|
14
14
|
program =
|
@@ -82,18 +82,18 @@ RSpec.describe "Integration with RSpec's #include matcher",
|
|
82
82
|
it "produces the correct failure message when used in the positive" do
|
83
83
|
as_both_colored_and_uncolored do |color_enabled|
|
84
84
|
snippet = <<~TEST.strip
|
85
|
-
|
85
|
+
actual = [
|
86
86
|
"Marty McFly",
|
87
87
|
"Doc Brown",
|
88
88
|
"Einie",
|
89
|
-
"Biff Tannen",
|
90
|
-
"George McFly",
|
91
89
|
"Lorraine McFly"
|
92
90
|
]
|
93
|
-
|
91
|
+
expected = [
|
94
92
|
"Marty McFly",
|
95
93
|
"Doc Brown",
|
96
94
|
"Einie",
|
95
|
+
"Biff Tannen",
|
96
|
+
"George McFly",
|
97
97
|
"Lorraine McFly"
|
98
98
|
]
|
99
99
|
expect(actual).to include(*expected)
|
@@ -140,18 +140,18 @@ RSpec.describe "Integration with RSpec's #include matcher",
|
|
140
140
|
it "produces the correct failure message when used in the negative" do
|
141
141
|
as_both_colored_and_uncolored do |color_enabled|
|
142
142
|
snippet = <<~TEST.strip
|
143
|
-
|
143
|
+
actual = [
|
144
144
|
"Marty McFly",
|
145
145
|
"Doc Brown",
|
146
146
|
"Einie",
|
147
|
+
"Biff Tannen",
|
148
|
+
"George McFly",
|
147
149
|
"Lorraine McFly"
|
148
150
|
]
|
149
|
-
|
151
|
+
expected = [
|
150
152
|
"Marty McFly",
|
151
153
|
"Doc Brown",
|
152
154
|
"Einie",
|
153
|
-
"Biff Tannen",
|
154
|
-
"George McFly",
|
155
155
|
"Lorraine McFly"
|
156
156
|
]
|
157
157
|
expect(actual).not_to include(*expected)
|
@@ -191,8 +191,8 @@ RSpec.describe "Integration with RSpec's #include matcher",
|
|
191
191
|
it "produces the correct failure message when used in the positive" do
|
192
192
|
as_both_colored_and_uncolored do |color_enabled|
|
193
193
|
snippet = <<~TEST.strip
|
194
|
-
expected = { city: "Hill Valley", state: "CA" }
|
195
194
|
actual = { city: "Burbank", zip: "90210" }
|
195
|
+
expected = { city: "Hill Valley", state: "CA" }
|
196
196
|
expect(actual).to include(expected)
|
197
197
|
TEST
|
198
198
|
program =
|
@@ -234,8 +234,8 @@ RSpec.describe "Integration with RSpec's #include matcher",
|
|
234
234
|
it "produces the correct failure message when used in the negative" do
|
235
235
|
as_both_colored_and_uncolored do |color_enabled|
|
236
236
|
snippet = <<~TEST.strip
|
237
|
-
expected = { city: "Burbank" }
|
238
237
|
actual = { city: "Burbank", zip: "90210" }
|
238
|
+
expected = { city: "Burbank" }
|
239
239
|
expect(actual).not_to include(expected)
|
240
240
|
TEST
|
241
241
|
program =
|
@@ -266,8 +266,8 @@ RSpec.describe "Integration with RSpec's #include matcher",
|
|
266
266
|
it "produces the correct failure message when fuzzy matching" do
|
267
267
|
as_both_colored_and_uncolored do |color_enabled|
|
268
268
|
snippet = <<~TEST.strip
|
269
|
-
expected = { number: a_kind_of(Numeric), city: /burb/i, state: "CA" }
|
270
269
|
actual = { number: 42, city: "Burbank", zip: "90210" }
|
270
|
+
expected = { number: a_kind_of(Numeric), city: /burb/i, state: "CA" }
|
271
271
|
expect(actual).to include(expected)
|
272
272
|
TEST
|
273
273
|
program =
|
@@ -309,15 +309,15 @@ RSpec.describe "Integration with RSpec's #include matcher",
|
|
309
309
|
it "produces the correct failure message when used in the positive" do
|
310
310
|
as_both_colored_and_uncolored do |color_enabled|
|
311
311
|
snippet = <<~TEST.strip
|
312
|
-
expected = {
|
313
|
-
city: "Hill Valley",
|
314
|
-
zip: "90382"
|
315
|
-
}
|
316
312
|
actual = {
|
317
313
|
city: "Burbank",
|
318
314
|
state: "CA",
|
319
315
|
zip: "90210"
|
320
316
|
}
|
317
|
+
expected = {
|
318
|
+
city: "Hill Valley",
|
319
|
+
zip: "90382"
|
320
|
+
}
|
321
321
|
expect(actual).to include(expected)
|
322
322
|
TEST
|
323
323
|
program =
|
@@ -360,8 +360,8 @@ RSpec.describe "Integration with RSpec's #include matcher",
|
|
360
360
|
it "produces the correct failure message when used in the negative" do
|
361
361
|
as_both_colored_and_uncolored do |color_enabled|
|
362
362
|
snippet = <<~TEST.strip
|
363
|
-
expected = { city: "Hill Valley", state: "CA" }
|
364
363
|
actual = { city: "Hill Valley", state: "CA", zip: "90210" }
|
364
|
+
expected = { city: "Hill Valley", state: "CA" }
|
365
365
|
expect(actual).not_to include(expected)
|
366
366
|
TEST
|
367
367
|
program =
|
@@ -395,12 +395,6 @@ RSpec.describe "Integration with RSpec's #include matcher",
|
|
395
395
|
it "produces the correct failure message when fuzzy matching" do
|
396
396
|
as_both_colored_and_uncolored do |color_enabled|
|
397
397
|
snippet = <<~TEST.strip
|
398
|
-
expected = {
|
399
|
-
number: a_kind_of(Numeric),
|
400
|
-
street: "Yoshie Circles",
|
401
|
-
city: /burb/i,
|
402
|
-
zip: "90382"
|
403
|
-
}
|
404
398
|
actual = {
|
405
399
|
number: 42,
|
406
400
|
street: "Yoshie Circles",
|
@@ -408,6 +402,12 @@ RSpec.describe "Integration with RSpec's #include matcher",
|
|
408
402
|
state: "CA",
|
409
403
|
zip: "90210"
|
410
404
|
}
|
405
|
+
expected = {
|
406
|
+
number: a_kind_of(Numeric),
|
407
|
+
street: "Yoshie Circles",
|
408
|
+
city: /burb/i,
|
409
|
+
zip: "90382"
|
410
|
+
}
|
411
411
|
expect(actual).to include(expected)
|
412
412
|
TEST
|
413
413
|
program =
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Integration with RSpec's magic metadata", type: :integration do
|
4
|
+
it "includes extra_failure_lines in failure messages" do
|
5
|
+
as_both_colored_and_uncolored do |color_enabled|
|
6
|
+
snippet = <<~TEST.strip
|
7
|
+
RSpec.describe "test" do
|
8
|
+
it { expect(true).to be(false) }
|
9
|
+
|
10
|
+
after do
|
11
|
+
RSpec.current_example.metadata[:extra_failure_lines] = "foo\nbar"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
TEST
|
15
|
+
program =
|
16
|
+
make_plain_test_program(
|
17
|
+
snippet,
|
18
|
+
color_enabled: color_enabled,
|
19
|
+
preserve_as_whole_file: true
|
20
|
+
)
|
21
|
+
|
22
|
+
expected_output =
|
23
|
+
build_expected_output(
|
24
|
+
color_enabled: color_enabled,
|
25
|
+
test_name: "test is expected to equal false",
|
26
|
+
snippet: "it { expect(true).to be(false) }",
|
27
|
+
expectation:
|
28
|
+
proc do
|
29
|
+
line do
|
30
|
+
plain "Expected "
|
31
|
+
actual "true"
|
32
|
+
plain " to equal "
|
33
|
+
expected "false"
|
34
|
+
plain "."
|
35
|
+
end
|
36
|
+
end,
|
37
|
+
extra_failure_lines:
|
38
|
+
proc do
|
39
|
+
indent by: 5 do
|
40
|
+
line "foo"
|
41
|
+
line "bar"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
)
|
45
|
+
|
46
|
+
expect(program).to produce_output_when_run(expected_output).in_color(
|
47
|
+
color_enabled
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -6,8 +6,8 @@ RSpec.describe "Integration with RSpec's #match_array matcher",
|
|
6
6
|
it "produces the correct failure message when used in the positive" do
|
7
7
|
as_both_colored_and_uncolored do |color_enabled|
|
8
8
|
snippet = <<~TEST.strip
|
9
|
-
expected = ["Einie", "Marty"]
|
10
9
|
actual = ["Marty", "Jennifer", "Doc"]
|
10
|
+
expected = ["Einie", "Marty"]
|
11
11
|
expect(actual).to match_array(expected)
|
12
12
|
TEST
|
13
13
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
@@ -84,6 +84,12 @@ RSpec.describe "Integration with RSpec's #match_array matcher",
|
|
84
84
|
it "produces the correct failure message when used in the positive" do
|
85
85
|
as_both_colored_and_uncolored do |color_enabled|
|
86
86
|
snippet = <<~TEST.strip
|
87
|
+
actual = [
|
88
|
+
"Marty McFly",
|
89
|
+
"Doc Brown",
|
90
|
+
"Einie",
|
91
|
+
"Lorraine McFly"
|
92
|
+
]
|
87
93
|
expected = [
|
88
94
|
"Doc Brown",
|
89
95
|
"Marty McFly",
|
@@ -91,12 +97,6 @@ RSpec.describe "Integration with RSpec's #match_array matcher",
|
|
91
97
|
"George McFly",
|
92
98
|
"Lorraine McFly"
|
93
99
|
]
|
94
|
-
actual = [
|
95
|
-
"Marty McFly",
|
96
|
-
"Doc Brown",
|
97
|
-
"Einie",
|
98
|
-
"Lorraine McFly"
|
99
|
-
]
|
100
100
|
expect(actual).to match_array(expected)
|
101
101
|
TEST
|
102
102
|
program =
|
@@ -196,6 +196,12 @@ RSpec.describe "Integration with RSpec's #match_array matcher",
|
|
196
196
|
it "produces the correct failure message when used in the positive" do
|
197
197
|
as_both_colored_and_uncolored do |color_enabled|
|
198
198
|
snippet = <<~TEST
|
199
|
+
actual = [
|
200
|
+
"Marty McFly",
|
201
|
+
"Doc Brown",
|
202
|
+
"Einie",
|
203
|
+
"Lorraine McFly"
|
204
|
+
]
|
199
205
|
expected = [
|
200
206
|
/ Brown$/,
|
201
207
|
"Marty McFly",
|
@@ -203,12 +209,6 @@ RSpec.describe "Integration with RSpec's #match_array matcher",
|
|
203
209
|
/Georg McFly/,
|
204
210
|
/Lorrain McFly/
|
205
211
|
]
|
206
|
-
actual = [
|
207
|
-
"Marty McFly",
|
208
|
-
"Doc Brown",
|
209
|
-
"Einie",
|
210
|
-
"Lorraine McFly"
|
211
|
-
]
|
212
212
|
expect(actual).to match_array(expected)
|
213
213
|
TEST
|
214
214
|
program =
|
@@ -310,20 +310,20 @@ RSpec.describe "Integration with RSpec's #match_array matcher",
|
|
310
310
|
end
|
311
311
|
end
|
312
312
|
|
313
|
-
context "and some of them are
|
313
|
+
context "and some of them are RSpec matchers" do
|
314
314
|
it "produces the correct failure message" do
|
315
315
|
as_both_colored_and_uncolored do |color_enabled|
|
316
316
|
snippet = <<~TEST.strip
|
317
|
-
expected = [
|
318
|
-
a_hash_including(foo: "bar"),
|
319
|
-
a_collection_containing_exactly("zing"),
|
320
|
-
an_object_having_attributes(baz: "qux"),
|
321
|
-
]
|
322
317
|
actual = [
|
323
318
|
{ foo: "bar" },
|
324
319
|
double(baz: "qux"),
|
325
320
|
{ blargh: "riddle" }
|
326
321
|
]
|
322
|
+
expected = [
|
323
|
+
a_hash_including(foo: "bar"),
|
324
|
+
a_collection_containing_exactly("zing"),
|
325
|
+
an_object_having_attributes(baz: "qux"),
|
326
|
+
]
|
327
327
|
expect(actual).to match_array(expected)
|
328
328
|
TEST
|
329
329
|
program =
|
@@ -379,12 +379,12 @@ RSpec.describe "Integration with RSpec's #match_array matcher",
|
|
379
379
|
end
|
380
380
|
end
|
381
381
|
|
382
|
-
context "when the input value is a
|
383
|
-
it "produces the correct failure message
|
382
|
+
context "when the input value is not an array, and especially not a value that could be turned into one" do
|
383
|
+
it "produces the correct failure message, as though an array had been given" do
|
384
384
|
as_both_colored_and_uncolored do |color_enabled|
|
385
385
|
snippet = <<~TEST.strip
|
386
|
-
|
387
|
-
|
386
|
+
actual = [:marty, :jennifer, :doc]
|
387
|
+
expected = :einie
|
388
388
|
expect(actual).to match_array(expected)
|
389
389
|
TEST
|
390
390
|
program = make_plain_test_program(snippet, color_enabled: color_enabled)
|
@@ -397,20 +397,20 @@ RSpec.describe "Integration with RSpec's #match_array matcher",
|
|
397
397
|
proc do
|
398
398
|
line do
|
399
399
|
plain "Expected "
|
400
|
-
actual
|
400
|
+
actual "[:marty, :jennifer, :doc]"
|
401
401
|
plain " to match array with "
|
402
|
-
expected
|
402
|
+
expected ":einie"
|
403
403
|
plain "."
|
404
404
|
end
|
405
405
|
end,
|
406
406
|
diff:
|
407
407
|
proc do
|
408
408
|
plain_line " ["
|
409
|
-
actual_line
|
410
|
-
actual_line
|
411
|
-
actual_line
|
412
|
-
# expected_line %|-
|
413
|
-
expected_line
|
409
|
+
actual_line "+ :marty,"
|
410
|
+
actual_line "+ :jennifer,"
|
411
|
+
actual_line "+ :doc,"
|
412
|
+
# expected_line %|- :einie| # TODO
|
413
|
+
expected_line "- :einie,"
|
414
414
|
plain_line " ]"
|
415
415
|
end
|
416
416
|
)
|