super_diff 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +46 -19
  3. data/lib/super_diff.rb +1 -7
  4. data/lib/super_diff/colorized_document_extensions.rb +4 -4
  5. data/lib/super_diff/configuration.rb +32 -22
  6. data/lib/super_diff/csi.rb +2 -1
  7. data/lib/super_diff/diff_formatters/collection.rb +1 -1
  8. data/lib/super_diff/diff_formatters/multiline_string.rb +4 -4
  9. data/lib/super_diff/equality_matchers/array.rb +2 -2
  10. data/lib/super_diff/equality_matchers/default.rb +2 -2
  11. data/lib/super_diff/equality_matchers/hash.rb +2 -2
  12. data/lib/super_diff/equality_matchers/multiline_string.rb +2 -2
  13. data/lib/super_diff/equality_matchers/primitive.rb +2 -2
  14. data/lib/super_diff/equality_matchers/singleline_string.rb +2 -2
  15. data/lib/super_diff/gem_version.rb +45 -0
  16. data/lib/super_diff/rspec.rb +4 -0
  17. data/lib/super_diff/rspec/matcher_text_builders/base.rb +7 -7
  18. data/lib/super_diff/rspec/matcher_text_builders/be_predicate.rb +6 -6
  19. data/lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb +1 -1
  20. data/lib/super_diff/rspec/matcher_text_builders/have_predicate.rb +4 -4
  21. data/lib/super_diff/rspec/matcher_text_builders/raise_error.rb +1 -1
  22. data/lib/super_diff/rspec/matcher_text_builders/respond_to.rb +5 -5
  23. data/lib/super_diff/rspec/monkey_patches.rb +22 -13
  24. data/lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb +12 -1
  25. data/lib/super_diff/version.rb +1 -1
  26. data/spec/examples.txt +393 -5
  27. data/spec/integration/rspec/be_falsey_matcher_spec.rb +10 -10
  28. data/spec/integration/rspec/be_matcher_spec.rb +100 -100
  29. data/spec/integration/rspec/be_nil_matcher_spec.rb +10 -10
  30. data/spec/integration/rspec/be_predicate_matcher_spec.rb +103 -103
  31. data/spec/integration/rspec/be_truthy_matcher_spec.rb +10 -10
  32. data/spec/integration/rspec/contain_exactly_matcher_spec.rb +107 -107
  33. data/spec/integration/rspec/eq_matcher_spec.rb +230 -230
  34. data/spec/integration/rspec/have_attributes_matcher_spec.rb +129 -129
  35. data/spec/integration/rspec/have_predicate_matcher_spec.rb +65 -65
  36. data/spec/integration/rspec/include_matcher_spec.rb +73 -73
  37. data/spec/integration/rspec/match_array_matcher_spec.rb +119 -119
  38. data/spec/integration/rspec/match_matcher_spec.rb +274 -274
  39. data/spec/integration/rspec/raise_error_matcher_spec.rb +86 -86
  40. data/spec/integration/rspec/respond_to_matcher_spec.rb +240 -240
  41. data/spec/integration/rspec/third_party_matcher_spec.rb +8 -8
  42. data/spec/integration/rspec/unhandled_errors_spec.rb +5 -5
  43. data/spec/spec_helper.rb +22 -13
  44. data/spec/support/integration/helpers.rb +6 -2
  45. data/spec/support/integration/matchers/produce_output_when_run_matcher.rb +1 -1
  46. data/spec/support/integration/test_programs/base.rb +2 -0
  47. data/spec/support/integration/test_programs/rspec_active_record.rb +1 -1
  48. data/spec/support/integration/test_programs/rspec_active_support.rb +17 -0
  49. data/spec/support/integration/test_programs/rspec_rails.rb +1 -1
  50. data/spec/support/shared_examples/active_record.rb +108 -108
  51. data/spec/support/shared_examples/hash_with_indifferent_access.rb +196 -232
  52. data/spec/tmp/integration_spec.rb +15 -0
  53. data/spec/unit/equality_matchers/main_spec.rb +403 -403
  54. data/super_diff.gemspec +1 -1
  55. metadata +11 -3
@@ -1,6 +1,6 @@
1
1
  shared_examples_for "integration with HashWithIndifferentAccess" do
2
2
  describe "and RSpec's #eq matcher" do
3
- context "when the actual value is a HashWithIndifferentAccess" do
3
+ context "when the actual value is a HashWithIndifferentAccess" do
4
4
  context "and both hashes are one-dimensional" do
5
5
  context "and the expected hash contains symbol keys" do
6
6
  it "produces the correct output" do
@@ -12,7 +12,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
12
12
  state: "CA",
13
13
  zip: "90382",
14
14
  }
15
- actual = HashWithIndifferentAccess.new({
15
+ actual = HashWithIndifferentAccess.new({
16
16
  line_1: "456 Ponderosa Ct.",
17
17
  city: "Oakland",
18
18
  state: "CA",
@@ -20,35 +20,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
20
20
  })
21
21
  expect(actual).to eq(expected)
22
22
  TEST
23
- program = make_rspec_rails_test_program(
24
- snippet,
25
- color_enabled: color_enabled,
26
- )
23
+ program = make_program(snippet, color_enabled: color_enabled)
27
24
 
28
25
  expected_output = build_expected_output(
29
26
  color_enabled: color_enabled,
30
27
  snippet: "expect(actual).to eq(expected)",
31
28
  expectation: proc {
32
29
  line do
33
- plain "Expected "
34
- beta %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
30
+ plain %|Expected |
31
+ actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
35
32
  end
36
33
 
37
34
  line do
38
- plain " to eq "
39
- alpha %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
35
+ plain %| to eq |
36
+ expected %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
40
37
  end
41
38
  },
42
39
  diff: proc {
43
- plain_line %| #<HashWithIndifferentAccess {|
44
- alpha_line %|- "line_1" => "123 Main St.",|
45
- beta_line %|+ "line_1" => "456 Ponderosa Ct.",|
46
- alpha_line %|- "city" => "Hill Valley",|
47
- beta_line %|+ "city" => "Oakland",|
48
- plain_line %| "state" => "CA",|
49
- alpha_line %|- "zip" => "90382"|
50
- beta_line %|+ "zip" => "91234"|
51
- plain_line %| }>|
40
+ plain_line %| #<HashWithIndifferentAccess {|
41
+ expected_line %|- "line_1" => "123 Main St.",|
42
+ actual_line %|+ "line_1" => "456 Ponderosa Ct.",|
43
+ expected_line %|- "city" => "Hill Valley",|
44
+ actual_line %|+ "city" => "Oakland",|
45
+ plain_line %| "state" => "CA",|
46
+ expected_line %|- "zip" => "90382"|
47
+ actual_line %|+ "zip" => "91234"|
48
+ plain_line %| }>|
52
49
  },
53
50
  )
54
51
 
@@ -69,7 +66,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
69
66
  "state" => "CA",
70
67
  "zip" => "90382",
71
68
  }
72
- actual = HashWithIndifferentAccess.new({
69
+ actual = HashWithIndifferentAccess.new({
73
70
  line_1: "456 Ponderosa Ct.",
74
71
  city: "Oakland",
75
72
  state: "CA",
@@ -77,35 +74,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
77
74
  })
78
75
  expect(actual).to eq(expected)
79
76
  TEST
80
- program = make_rspec_rails_test_program(
81
- snippet,
82
- color_enabled: color_enabled,
83
- )
77
+ program = make_program(snippet, color_enabled: color_enabled)
84
78
 
85
79
  expected_output = build_expected_output(
86
80
  color_enabled: color_enabled,
87
81
  snippet: "expect(actual).to eq(expected)",
88
82
  expectation: proc {
89
83
  line do
90
- plain "Expected "
91
- beta %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
84
+ plain %|Expected |
85
+ actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
92
86
  end
93
87
 
94
88
  line do
95
- plain " to eq "
96
- alpha %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
89
+ plain %| to eq |
90
+ expected %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
97
91
  end
98
92
  },
99
93
  diff: proc {
100
- plain_line %| #<HashWithIndifferentAccess {|
101
- alpha_line %|- "line_1" => "123 Main St.",|
102
- beta_line %|+ "line_1" => "456 Ponderosa Ct.",|
103
- alpha_line %|- "city" => "Hill Valley",|
104
- beta_line %|+ "city" => "Oakland",|
105
- plain_line %| "state" => "CA",|
106
- alpha_line %|- "zip" => "90382"|
107
- beta_line %|+ "zip" => "91234"|
108
- plain_line %| }>|
94
+ plain_line %| #<HashWithIndifferentAccess {|
95
+ expected_line %|- "line_1" => "123 Main St.",|
96
+ actual_line %|+ "line_1" => "456 Ponderosa Ct.",|
97
+ expected_line %|- "city" => "Hill Valley",|
98
+ actual_line %|+ "city" => "Oakland",|
99
+ plain_line %| "state" => "CA",|
100
+ expected_line %|- "zip" => "90382"|
101
+ actual_line %|+ "zip" => "91234"|
102
+ plain_line %| }>|
109
103
  },
110
104
  )
111
105
 
@@ -130,7 +124,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
130
124
  state: "CA",
131
125
  zip: "91234",
132
126
  })
133
- actual = {
127
+ actual = {
134
128
  line_1: "123 Main St.",
135
129
  city: "Hill Valley",
136
130
  state: "CA",
@@ -138,35 +132,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
138
132
  }
139
133
  expect(actual).to eq(expected)
140
134
  TEST
141
- program = make_rspec_rails_test_program(
142
- snippet,
143
- color_enabled: color_enabled,
144
- )
135
+ program = make_program(snippet, color_enabled: color_enabled)
145
136
 
146
137
  expected_output = build_expected_output(
147
138
  color_enabled: color_enabled,
148
139
  snippet: "expect(actual).to eq(expected)",
149
140
  expectation: proc {
150
141
  line do
151
- plain "Expected "
152
- beta %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
142
+ plain %|Expected |
143
+ actual %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
153
144
  end
154
145
 
155
146
  line do
156
- plain " to eq "
157
- alpha %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
147
+ plain %| to eq |
148
+ expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
158
149
  end
159
150
  },
160
151
  diff: proc {
161
- plain_line %| #<HashWithIndifferentAccess {|
162
- alpha_line %|- "line_1" => "456 Ponderosa Ct.",|
163
- beta_line %|+ "line_1" => "123 Main St.",|
164
- alpha_line %|- "city" => "Oakland",|
165
- beta_line %|+ "city" => "Hill Valley",|
166
- plain_line %| "state" => "CA",|
167
- alpha_line %|- "zip" => "91234"|
168
- beta_line %|+ "zip" => "90382"|
169
- plain_line %| }>|
152
+ plain_line %| #<HashWithIndifferentAccess {|
153
+ expected_line %|- "line_1" => "456 Ponderosa Ct.",|
154
+ actual_line %|+ "line_1" => "123 Main St.",|
155
+ expected_line %|- "city" => "Oakland",|
156
+ actual_line %|+ "city" => "Hill Valley",|
157
+ plain_line %| "state" => "CA",|
158
+ expected_line %|- "zip" => "91234"|
159
+ actual_line %|+ "zip" => "90382"|
160
+ plain_line %| }>|
170
161
  },
171
162
  )
172
163
 
@@ -177,7 +168,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
177
168
  end
178
169
  end
179
170
 
180
- context "and the actual hash contains string keys" do
171
+ context "and the actual hash contains string keys" do
181
172
  it "produces the correct output" do
182
173
  as_both_colored_and_uncolored do |color_enabled|
183
174
  snippet = <<~TEST.strip
@@ -187,7 +178,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
187
178
  state: "CA",
188
179
  zip: "91234",
189
180
  })
190
- actual = {
181
+ actual = {
191
182
  "line_1" => "123 Main St.",
192
183
  "city" => "Hill Valley",
193
184
  "state" => "CA",
@@ -195,35 +186,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
195
186
  }
196
187
  expect(actual).to eq(expected)
197
188
  TEST
198
- program = make_rspec_rails_test_program(
199
- snippet,
200
- color_enabled: color_enabled,
201
- )
189
+ program = make_program(snippet, color_enabled: color_enabled)
202
190
 
203
191
  expected_output = build_expected_output(
204
192
  color_enabled: color_enabled,
205
193
  snippet: "expect(actual).to eq(expected)",
206
194
  expectation: proc {
207
195
  line do
208
- plain "Expected "
209
- beta %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
196
+ plain %|Expected |
197
+ actual %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
210
198
  end
211
199
 
212
200
  line do
213
- plain " to eq "
214
- alpha %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
201
+ plain %| to eq |
202
+ expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
215
203
  end
216
204
  },
217
205
  diff: proc {
218
- plain_line %| #<HashWithIndifferentAccess {|
219
- alpha_line %|- "line_1" => "456 Ponderosa Ct.",|
220
- beta_line %|+ "line_1" => "123 Main St.",|
221
- alpha_line %|- "city" => "Oakland",|
222
- beta_line %|+ "city" => "Hill Valley",|
223
- plain_line %| "state" => "CA",|
224
- alpha_line %|- "zip" => "91234"|
225
- beta_line %|+ "zip" => "90382"|
226
- plain_line %| }>|
206
+ plain_line %| #<HashWithIndifferentAccess {|
207
+ expected_line %|- "line_1" => "456 Ponderosa Ct.",|
208
+ actual_line %|+ "line_1" => "123 Main St.",|
209
+ expected_line %|- "city" => "Oakland",|
210
+ actual_line %|+ "city" => "Hill Valley",|
211
+ plain_line %| "state" => "CA",|
212
+ expected_line %|- "zip" => "91234"|
213
+ actual_line %|+ "zip" => "90382"|
214
+ plain_line %| }>|
227
215
  },
228
216
  )
229
217
 
@@ -250,7 +238,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
250
238
  })
251
239
  ]
252
240
  })
253
- actual = {
241
+ actual = {
254
242
  shipments: [
255
243
  {
256
244
  estimated_delivery: {
@@ -262,37 +250,34 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
262
250
  }
263
251
  expect(actual).to eq(expected)
264
252
  TEST
265
- program = make_rspec_rails_test_program(
266
- snippet,
267
- color_enabled: color_enabled,
268
- )
253
+ program = make_program(snippet, color_enabled: color_enabled)
269
254
 
270
255
  expected_output = build_expected_output(
271
256
  color_enabled: color_enabled,
272
257
  snippet: "expect(actual).to eq(expected)",
273
258
  expectation: proc {
274
259
  line do
275
- plain "Expected "
276
- beta %|{ shipments: [{ estimated_delivery: { from: "2019-05-06", to: "2019-05-09" } }] }|
260
+ plain %|Expected |
261
+ actual %|{ shipments: [{ estimated_delivery: { from: "2019-05-06", to: "2019-05-09" } }] }|
277
262
  end
278
263
 
279
264
  line do
280
- plain " to eq "
281
- alpha %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
265
+ plain %| to eq |
266
+ expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
282
267
  end
283
268
  },
284
269
  diff: proc {
285
- plain_line %| #<HashWithIndifferentAccess {|
286
- plain_line %| "shipments" => [|
287
- plain_line %| {|
288
- plain_line %| "estimated_delivery" => {|
289
- plain_line %| "from" => "2019-05-06",|
290
- alpha_line %|- "to" => "2019-05-06"|
291
- beta_line %|+ "to" => "2019-05-09"|
292
- plain_line %| }|
293
- plain_line %| }|
294
- plain_line %| ]|
295
- plain_line %| }>|
270
+ plain_line %| #<HashWithIndifferentAccess {|
271
+ plain_line %| "shipments" => [|
272
+ plain_line %| {|
273
+ plain_line %| "estimated_delivery" => {|
274
+ plain_line %| "from" => "2019-05-06",|
275
+ expected_line %|- "to" => "2019-05-06"|
276
+ actual_line %|+ "to" => "2019-05-09"|
277
+ plain_line %| }|
278
+ plain_line %| }|
279
+ plain_line %| ]|
280
+ plain_line %| }>|
296
281
  },
297
282
  )
298
283
 
@@ -303,7 +288,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
303
288
  end
304
289
  end
305
290
 
306
- context "and the actual hash contains string keys" do
291
+ context "and the actual hash contains string keys" do
307
292
  it "produces the correct output" do
308
293
  as_both_colored_and_uncolored do |color_enabled|
309
294
  snippet = <<~TEST.strip
@@ -317,7 +302,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
317
302
  })
318
303
  ]
319
304
  })
320
- actual = {
305
+ actual = {
321
306
  'shipments' => [
322
307
  {
323
308
  'estimated_delivery' => {
@@ -329,37 +314,34 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
329
314
  }
330
315
  expect(actual).to eq(expected)
331
316
  TEST
332
- program = make_rspec_rails_test_program(
333
- snippet,
334
- color_enabled: color_enabled,
335
- )
317
+ program = make_program(snippet, color_enabled: color_enabled)
336
318
 
337
319
  expected_output = build_expected_output(
338
320
  color_enabled: color_enabled,
339
321
  snippet: "expect(actual).to eq(expected)",
340
322
  expectation: proc {
341
323
  line do
342
- plain "Expected "
343
- beta %|{ "shipments" => [{ "estimated_delivery" => { "from" => "2019-05-06", "to" => "2019-05-09" } }] }|
324
+ plain %|Expected |
325
+ actual %|{ "shipments" => [{ "estimated_delivery" => { "from" => "2019-05-06", "to" => "2019-05-09" } }] }|
344
326
  end
345
327
 
346
328
  line do
347
- plain " to eq "
348
- alpha %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
329
+ plain %| to eq |
330
+ expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
349
331
  end
350
332
  },
351
333
  diff: proc {
352
- plain_line %| #<HashWithIndifferentAccess {|
353
- plain_line %| "shipments" => [|
354
- plain_line %| {|
355
- plain_line %| "estimated_delivery" => {|
356
- plain_line %| "from" => "2019-05-06",|
357
- alpha_line %|- "to" => "2019-05-06"|
358
- beta_line %|+ "to" => "2019-05-09"|
359
- plain_line %| }|
360
- plain_line %| }|
361
- plain_line %| ]|
362
- plain_line %| }>|
334
+ plain_line %| #<HashWithIndifferentAccess {|
335
+ plain_line %| "shipments" => [|
336
+ plain_line %| {|
337
+ plain_line %| "estimated_delivery" => {|
338
+ plain_line %| "from" => "2019-05-06",|
339
+ expected_line %|- "to" => "2019-05-06"|
340
+ actual_line %|+ "to" => "2019-05-09"|
341
+ plain_line %| }|
342
+ plain_line %| }|
343
+ plain_line %| ]|
344
+ plain_line %| }>|
363
345
  },
364
346
  )
365
347
 
@@ -374,7 +356,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
374
356
  end
375
357
 
376
358
  describe "and RSpec's #match matcher" do
377
- context "when the actual value is a HashWithIndifferentAccess" do
359
+ context "when the actual value is a HashWithIndifferentAccess" do
378
360
  context "and both hashes are one-dimensional" do
379
361
  context "and the expected hash contains symbol keys" do
380
362
  it "produces the correct output" do
@@ -386,7 +368,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
386
368
  state: "CA",
387
369
  zip: "90382",
388
370
  }
389
- actual = HashWithIndifferentAccess.new({
371
+ actual = HashWithIndifferentAccess.new({
390
372
  line_1: "456 Ponderosa Ct.",
391
373
  city: "Oakland",
392
374
  state: "CA",
@@ -394,35 +376,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
394
376
  })
395
377
  expect(actual).to match(expected)
396
378
  TEST
397
- program = make_rspec_rails_test_program(
398
- snippet,
399
- color_enabled: color_enabled,
400
- )
379
+ program = make_program(snippet, color_enabled: color_enabled)
401
380
 
402
381
  expected_output = build_expected_output(
403
382
  color_enabled: color_enabled,
404
383
  snippet: "expect(actual).to match(expected)",
405
384
  expectation: proc {
406
385
  line do
407
- plain "Expected "
408
- beta %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
386
+ plain %|Expected |
387
+ actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
409
388
  end
410
389
 
411
390
  line do
412
- plain "to match "
413
- alpha %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
391
+ plain %|to match |
392
+ expected %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
414
393
  end
415
394
  },
416
395
  diff: proc {
417
- plain_line %| #<HashWithIndifferentAccess {|
418
- alpha_line %|- "line_1" => "123 Main St.",|
419
- beta_line %|+ "line_1" => "456 Ponderosa Ct.",|
420
- alpha_line %|- "city" => "Hill Valley",|
421
- beta_line %|+ "city" => "Oakland",|
422
- plain_line %| "state" => "CA",|
423
- alpha_line %|- "zip" => "90382"|
424
- beta_line %|+ "zip" => "91234"|
425
- plain_line %| }>|
396
+ plain_line %| #<HashWithIndifferentAccess {|
397
+ expected_line %|- "line_1" => "123 Main St.",|
398
+ actual_line %|+ "line_1" => "456 Ponderosa Ct.",|
399
+ expected_line %|- "city" => "Hill Valley",|
400
+ actual_line %|+ "city" => "Oakland",|
401
+ plain_line %| "state" => "CA",|
402
+ expected_line %|- "zip" => "90382"|
403
+ actual_line %|+ "zip" => "91234"|
404
+ plain_line %| }>|
426
405
  },
427
406
  )
428
407
 
@@ -443,7 +422,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
443
422
  "state" => "CA",
444
423
  "zip" => "90382",
445
424
  }
446
- actual = HashWithIndifferentAccess.new({
425
+ actual = HashWithIndifferentAccess.new({
447
426
  line_1: "456 Ponderosa Ct.",
448
427
  city: "Oakland",
449
428
  state: "CA",
@@ -451,35 +430,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
451
430
  })
452
431
  expect(actual).to match(expected)
453
432
  TEST
454
- program = make_rspec_rails_test_program(
455
- snippet,
456
- color_enabled: color_enabled,
457
- )
433
+ program = make_program(snippet, color_enabled: color_enabled)
458
434
 
459
435
  expected_output = build_expected_output(
460
436
  color_enabled: color_enabled,
461
437
  snippet: "expect(actual).to match(expected)",
462
438
  expectation: proc {
463
439
  line do
464
- plain "Expected "
465
- beta %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
440
+ plain %|Expected |
441
+ actual %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
466
442
  end
467
443
 
468
444
  line do
469
- plain "to match "
470
- alpha %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
445
+ plain %|to match |
446
+ expected %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
471
447
  end
472
448
  },
473
449
  diff: proc {
474
- plain_line %| #<HashWithIndifferentAccess {|
475
- alpha_line %|- "line_1" => "123 Main St.",|
476
- beta_line %|+ "line_1" => "456 Ponderosa Ct.",|
477
- alpha_line %|- "city" => "Hill Valley",|
478
- beta_line %|+ "city" => "Oakland",|
479
- plain_line %| "state" => "CA",|
480
- alpha_line %|- "zip" => "90382"|
481
- beta_line %|+ "zip" => "91234"|
482
- plain_line %| }>|
450
+ plain_line %| #<HashWithIndifferentAccess {|
451
+ expected_line %|- "line_1" => "123 Main St.",|
452
+ actual_line %|+ "line_1" => "456 Ponderosa Ct.",|
453
+ expected_line %|- "city" => "Hill Valley",|
454
+ actual_line %|+ "city" => "Oakland",|
455
+ plain_line %| "state" => "CA",|
456
+ expected_line %|- "zip" => "90382"|
457
+ actual_line %|+ "zip" => "91234"|
458
+ plain_line %| }>|
483
459
  },
484
460
  )
485
461
 
@@ -494,7 +470,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
494
470
 
495
471
  context "when the expected value is a HashWithIndifferentAccess" do
496
472
  context "and both hashes are one-dimensional" do
497
- context "and the actual hash contains symbol keys" do
473
+ context "and the actual hash contains symbol keys" do
498
474
  it "produces the correct output" do
499
475
  as_both_colored_and_uncolored do |color_enabled|
500
476
  snippet = <<~TEST.strip
@@ -504,7 +480,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
504
480
  state: "CA",
505
481
  zip: "91234",
506
482
  })
507
- actual = {
483
+ actual = {
508
484
  line_1: "123 Main St.",
509
485
  city: "Hill Valley",
510
486
  state: "CA",
@@ -512,35 +488,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
512
488
  }
513
489
  expect(actual).to match(expected)
514
490
  TEST
515
- program = make_rspec_rails_test_program(
516
- snippet,
517
- color_enabled: color_enabled,
518
- )
491
+ program = make_program(snippet, color_enabled: color_enabled)
519
492
 
520
493
  expected_output = build_expected_output(
521
494
  color_enabled: color_enabled,
522
495
  snippet: "expect(actual).to match(expected)",
523
496
  expectation: proc {
524
497
  line do
525
- plain "Expected "
526
- beta %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
498
+ plain %|Expected |
499
+ actual %|{ line_1: "123 Main St.", city: "Hill Valley", state: "CA", zip: "90382" }|
527
500
  end
528
501
 
529
502
  line do
530
- plain "to match "
531
- alpha %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
503
+ plain %|to match |
504
+ expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
532
505
  end
533
506
  },
534
507
  diff: proc {
535
- plain_line %| #<HashWithIndifferentAccess {|
536
- alpha_line %|- "line_1" => "456 Ponderosa Ct.",|
537
- beta_line %|+ "line_1" => "123 Main St.",|
538
- alpha_line %|- "city" => "Oakland",|
539
- beta_line %|+ "city" => "Hill Valley",|
540
- plain_line %| "state" => "CA",|
541
- alpha_line %|- "zip" => "91234"|
542
- beta_line %|+ "zip" => "90382"|
543
- plain_line %| }>|
508
+ plain_line %| #<HashWithIndifferentAccess {|
509
+ expected_line %|- "line_1" => "456 Ponderosa Ct.",|
510
+ actual_line %|+ "line_1" => "123 Main St.",|
511
+ expected_line %|- "city" => "Oakland",|
512
+ actual_line %|+ "city" => "Hill Valley",|
513
+ plain_line %| "state" => "CA",|
514
+ expected_line %|- "zip" => "91234"|
515
+ actual_line %|+ "zip" => "90382"|
516
+ plain_line %| }>|
544
517
  },
545
518
  )
546
519
 
@@ -551,7 +524,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
551
524
  end
552
525
  end
553
526
 
554
- context "and the actual hash contains string keys" do
527
+ context "and the actual hash contains string keys" do
555
528
  it "produces the correct output" do
556
529
  as_both_colored_and_uncolored do |color_enabled|
557
530
  snippet = <<~TEST.strip
@@ -561,7 +534,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
561
534
  state: "CA",
562
535
  zip: "91234",
563
536
  })
564
- actual = {
537
+ actual = {
565
538
  "line_1" => "123 Main St.",
566
539
  "city" => "Hill Valley",
567
540
  "state" => "CA",
@@ -569,35 +542,32 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
569
542
  }
570
543
  expect(actual).to match(expected)
571
544
  TEST
572
- program = make_rspec_rails_test_program(
573
- snippet,
574
- color_enabled: color_enabled,
575
- )
545
+ program = make_program(snippet, color_enabled: color_enabled)
576
546
 
577
547
  expected_output = build_expected_output(
578
548
  color_enabled: color_enabled,
579
549
  snippet: "expect(actual).to match(expected)",
580
550
  expectation: proc {
581
551
  line do
582
- plain "Expected "
583
- beta %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
552
+ plain %|Expected |
553
+ actual %|{ "line_1" => "123 Main St.", "city" => "Hill Valley", "state" => "CA", "zip" => "90382" }|
584
554
  end
585
555
 
586
556
  line do
587
- plain "to match "
588
- alpha %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
557
+ plain %|to match |
558
+ expected %|#<HashWithIndifferentAccess { "line_1" => "456 Ponderosa Ct.", "city" => "Oakland", "state" => "CA", "zip" => "91234" }>|
589
559
  end
590
560
  },
591
561
  diff: proc {
592
- plain_line %| #<HashWithIndifferentAccess {|
593
- alpha_line %|- "line_1" => "456 Ponderosa Ct.",|
594
- beta_line %|+ "line_1" => "123 Main St.",|
595
- alpha_line %|- "city" => "Oakland",|
596
- beta_line %|+ "city" => "Hill Valley",|
597
- plain_line %| "state" => "CA",|
598
- alpha_line %|- "zip" => "91234"|
599
- beta_line %|+ "zip" => "90382"|
600
- plain_line %| }>|
562
+ plain_line %| #<HashWithIndifferentAccess {|
563
+ expected_line %|- "line_1" => "456 Ponderosa Ct.",|
564
+ actual_line %|+ "line_1" => "123 Main St.",|
565
+ expected_line %|- "city" => "Oakland",|
566
+ actual_line %|+ "city" => "Hill Valley",|
567
+ plain_line %| "state" => "CA",|
568
+ expected_line %|- "zip" => "91234"|
569
+ actual_line %|+ "zip" => "90382"|
570
+ plain_line %| }>|
601
571
  },
602
572
  )
603
573
 
@@ -610,7 +580,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
610
580
  end
611
581
 
612
582
  context "and both hashes are multi-dimensional" do
613
- context "and the actual hash contains symbol keys" do
583
+ context "and the actual hash contains symbol keys" do
614
584
  it "produces the correct output" do
615
585
  as_both_colored_and_uncolored do |color_enabled|
616
586
  snippet = <<~TEST.strip
@@ -624,7 +594,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
624
594
  })
625
595
  ]
626
596
  })
627
- actual = {
597
+ actual = {
628
598
  shipments: [
629
599
  {
630
600
  estimated_delivery: {
@@ -636,37 +606,34 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
636
606
  }
637
607
  expect(actual).to match(expected)
638
608
  TEST
639
- program = make_rspec_rails_test_program(
640
- snippet,
641
- color_enabled: color_enabled,
642
- )
609
+ program = make_program(snippet, color_enabled: color_enabled)
643
610
 
644
611
  expected_output = build_expected_output(
645
612
  color_enabled: color_enabled,
646
613
  snippet: "expect(actual).to match(expected)",
647
614
  expectation: proc {
648
615
  line do
649
- plain "Expected "
650
- beta %|{ shipments: [{ estimated_delivery: { from: "2019-05-06", to: "2019-05-09" } }] }|
616
+ plain %|Expected |
617
+ actual %|{ shipments: [{ estimated_delivery: { from: "2019-05-06", to: "2019-05-09" } }] }|
651
618
  end
652
619
 
653
620
  line do
654
- plain "to match "
655
- alpha %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
621
+ plain %|to match |
622
+ expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
656
623
  end
657
624
  },
658
625
  diff: proc {
659
- plain_line %| #<HashWithIndifferentAccess {|
660
- plain_line %| "shipments" => [|
661
- plain_line %| {|
662
- plain_line %| "estimated_delivery" => {|
663
- plain_line %| "from" => "2019-05-06",|
664
- alpha_line %|- "to" => "2019-05-06"|
665
- beta_line %|+ "to" => "2019-05-09"|
666
- plain_line %| }|
667
- plain_line %| }|
668
- plain_line %| ]|
669
- plain_line %| }>|
626
+ plain_line %| #<HashWithIndifferentAccess {|
627
+ plain_line %| "shipments" => [|
628
+ plain_line %| {|
629
+ plain_line %| "estimated_delivery" => {|
630
+ plain_line %| "from" => "2019-05-06",|
631
+ expected_line %|- "to" => "2019-05-06"|
632
+ actual_line %|+ "to" => "2019-05-09"|
633
+ plain_line %| }|
634
+ plain_line %| }|
635
+ plain_line %| ]|
636
+ plain_line %| }>|
670
637
  },
671
638
  )
672
639
 
@@ -677,7 +644,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
677
644
  end
678
645
  end
679
646
 
680
- context "and the actual hash contains string keys" do
647
+ context "and the actual hash contains string keys" do
681
648
  it "produces the correct output" do
682
649
  as_both_colored_and_uncolored do |color_enabled|
683
650
  snippet = <<~TEST.strip
@@ -691,7 +658,7 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
691
658
  })
692
659
  ]
693
660
  })
694
- actual = {
661
+ actual = {
695
662
  'shipments' => [
696
663
  {
697
664
  'estimated_delivery' => {
@@ -703,37 +670,34 @@ shared_examples_for "integration with HashWithIndifferentAccess" do
703
670
  }
704
671
  expect(actual).to match(expected)
705
672
  TEST
706
- program = make_rspec_rails_test_program(
707
- snippet,
708
- color_enabled: color_enabled,
709
- )
673
+ program = make_program(snippet, color_enabled: color_enabled)
710
674
 
711
675
  expected_output = build_expected_output(
712
676
  color_enabled: color_enabled,
713
677
  snippet: "expect(actual).to match(expected)",
714
678
  expectation: proc {
715
679
  line do
716
- plain "Expected "
717
- beta %|{ "shipments" => [{ "estimated_delivery" => { "from" => "2019-05-06", "to" => "2019-05-09" } }] }|
680
+ plain %|Expected |
681
+ actual %|{ "shipments" => [{ "estimated_delivery" => { "from" => "2019-05-06", "to" => "2019-05-09" } }] }|
718
682
  end
719
683
 
720
684
  line do
721
- plain "to match "
722
- alpha %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
685
+ plain %|to match |
686
+ expected %|#<HashWithIndifferentAccess { "shipments" => [#<HashWithIndifferentAccess { "estimated_delivery" => #<HashWithIndifferentAccess { "from" => "2019-05-06", "to" => "2019-05-06" }> }>] }>|
723
687
  end
724
688
  },
725
689
  diff: proc {
726
- plain_line %| #<HashWithIndifferentAccess {|
727
- plain_line %| "shipments" => [|
728
- plain_line %| {|
729
- plain_line %| "estimated_delivery" => {|
730
- plain_line %| "from" => "2019-05-06",|
731
- alpha_line %|- "to" => "2019-05-06"|
732
- beta_line %|+ "to" => "2019-05-09"|
733
- plain_line %| }|
734
- plain_line %| }|
735
- plain_line %| ]|
736
- plain_line %| }>|
690
+ plain_line %| #<HashWithIndifferentAccess {|
691
+ plain_line %| "shipments" => [|
692
+ plain_line %| {|
693
+ plain_line %| "estimated_delivery" => {|
694
+ plain_line %| "from" => "2019-05-06",|
695
+ expected_line %|- "to" => "2019-05-06"|
696
+ actual_line %|+ "to" => "2019-05-09"|
697
+ plain_line %| }|
698
+ plain_line %| }|
699
+ plain_line %| ]|
700
+ plain_line %| }>|
737
701
  },
738
702
  )
739
703