super_diff 0.14.0 → 0.15.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/rspec/monkey_patches.rb +129 -56
- data/lib/super_diff/rspec.rb +12 -1
- data/lib/super_diff/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ac91e4432f7f0811776000b7a7153addd51ae073428eb03c8ae46218a5fe63d
|
4
|
+
data.tar.gz: 81e25a8e85f13ecb77c6da4a8a923a4958d4f6695104841573bc80f0dec028b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9dd989b77d595b455c73ca7daf7191a9bb5f45f28dedeef4a1729b31f4933935b006beb2c640f063a6041fddb5596f46d876585f995526ed60de5c552ec3b68
|
7
|
+
data.tar.gz: 3f50f8e32f20a2bccdb9b5ca18f39ae9e8b9ebffbe601ce91ecfe0b742d7fffd6ca44fe78a65a5c6fc93598630d37c0d8bd06c27aff352afa27780d103b1413b
|
@@ -309,73 +309,146 @@ module RSpec
|
|
309
309
|
end
|
310
310
|
|
311
311
|
module Matchers
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
312
|
+
if SuperDiff::RSpec.rspec_version < "3.13.0"
|
313
|
+
class ExpectedsForMultipleDiffs
|
314
|
+
SuperDiff.insert_singleton_overrides(self) do
|
315
|
+
# Add a key for different sides
|
316
|
+
def from(expected)
|
317
|
+
return expected if self === expected
|
318
|
+
|
319
|
+
text = colorizer.wrap("Diff:", SuperDiff.configuration.header_color)
|
320
|
+
|
321
|
+
if SuperDiff.configuration.key_enabled?
|
322
|
+
text +=
|
323
|
+
"\n\n" +
|
324
|
+
colorizer.wrap(
|
325
|
+
"┌ (Key) ──────────────────────────┐",
|
326
|
+
SuperDiff.configuration.border_color
|
327
|
+
) + "\n" +
|
328
|
+
colorizer.wrap("│ ", SuperDiff.configuration.border_color) +
|
329
|
+
colorizer.wrap(
|
330
|
+
"‹-› in expected, not in actual",
|
331
|
+
SuperDiff.configuration.expected_color
|
332
|
+
) +
|
333
|
+
colorizer.wrap(" │", SuperDiff.configuration.border_color) +
|
334
|
+
"\n" +
|
335
|
+
colorizer.wrap("│ ", SuperDiff.configuration.border_color) +
|
336
|
+
colorizer.wrap(
|
337
|
+
"‹+› in actual, not in expected",
|
338
|
+
SuperDiff.configuration.actual_color
|
339
|
+
) +
|
340
|
+
colorizer.wrap(" │", SuperDiff.configuration.border_color) +
|
341
|
+
"\n" +
|
342
|
+
colorizer.wrap("│ ", SuperDiff.configuration.border_color) +
|
343
|
+
"‹ › in both expected and actual" +
|
344
|
+
colorizer.wrap(" │", SuperDiff.configuration.border_color) +
|
345
|
+
"\n" +
|
346
|
+
colorizer.wrap(
|
347
|
+
"└─────────────────────────────────┘",
|
348
|
+
SuperDiff.configuration.border_color
|
349
|
+
)
|
350
|
+
end
|
351
|
+
|
352
|
+
new([[expected, text]])
|
349
353
|
end
|
350
354
|
|
351
|
-
|
355
|
+
def colorizer
|
356
|
+
RSpec::Core::Formatters::ConsoleCodes
|
357
|
+
end
|
352
358
|
end
|
353
359
|
|
354
|
-
|
355
|
-
|
360
|
+
SuperDiff.insert_overrides(self) do
|
361
|
+
# Add an extra line break
|
362
|
+
def message_with_diff(message, differ, actual)
|
363
|
+
diff = diffs(differ, actual)
|
364
|
+
|
365
|
+
diff.empty? ? message : "#{message.rstrip}\n\n#{diff}"
|
366
|
+
end
|
367
|
+
|
368
|
+
private
|
369
|
+
|
370
|
+
# Add extra line breaks in between diffs, and colorize the word "Diff"
|
371
|
+
def diffs(differ, actual)
|
372
|
+
@expected_list
|
373
|
+
.map do |(expected, diff_label)|
|
374
|
+
diff = differ.diff(actual, expected)
|
375
|
+
next if diff.strip.empty?
|
376
|
+
diff_label + diff
|
377
|
+
end
|
378
|
+
.compact
|
379
|
+
.join("\n\n")
|
380
|
+
end
|
356
381
|
end
|
357
382
|
end
|
383
|
+
else
|
384
|
+
class MultiMatcherDiff
|
385
|
+
SuperDiff.insert_singleton_overrides(self) do
|
386
|
+
# Add a key for different sides
|
387
|
+
def from(expected, actual)
|
388
|
+
return expected if self === expected
|
389
|
+
|
390
|
+
text = colorizer.wrap("Diff:", SuperDiff.configuration.header_color)
|
391
|
+
|
392
|
+
if SuperDiff.configuration.key_enabled?
|
393
|
+
text +=
|
394
|
+
"\n\n" +
|
395
|
+
colorizer.wrap(
|
396
|
+
"┌ (Key) ──────────────────────────┐",
|
397
|
+
SuperDiff.configuration.border_color
|
398
|
+
) + "\n" +
|
399
|
+
colorizer.wrap("│ ", SuperDiff.configuration.border_color) +
|
400
|
+
colorizer.wrap(
|
401
|
+
"‹-› in expected, not in actual",
|
402
|
+
SuperDiff.configuration.expected_color
|
403
|
+
) +
|
404
|
+
colorizer.wrap(" │", SuperDiff.configuration.border_color) +
|
405
|
+
"\n" +
|
406
|
+
colorizer.wrap("│ ", SuperDiff.configuration.border_color) +
|
407
|
+
colorizer.wrap(
|
408
|
+
"‹+› in actual, not in expected",
|
409
|
+
SuperDiff.configuration.actual_color
|
410
|
+
) +
|
411
|
+
colorizer.wrap(" │", SuperDiff.configuration.border_color) +
|
412
|
+
"\n" +
|
413
|
+
colorizer.wrap("│ ", SuperDiff.configuration.border_color) +
|
414
|
+
"‹ › in both expected and actual" +
|
415
|
+
colorizer.wrap(" │", SuperDiff.configuration.border_color) +
|
416
|
+
"\n" +
|
417
|
+
colorizer.wrap(
|
418
|
+
"└─────────────────────────────────┘",
|
419
|
+
SuperDiff.configuration.border_color
|
420
|
+
)
|
421
|
+
end
|
358
422
|
|
359
|
-
|
360
|
-
|
361
|
-
def message_with_diff(message, differ, actual)
|
362
|
-
diff = diffs(differ, actual)
|
423
|
+
new([[expected, text, actual]])
|
424
|
+
end
|
363
425
|
|
364
|
-
|
426
|
+
def colorizer
|
427
|
+
RSpec::Core::Formatters::ConsoleCodes
|
428
|
+
end
|
365
429
|
end
|
366
430
|
|
367
|
-
|
431
|
+
SuperDiff.insert_overrides(self) do
|
432
|
+
# Add an extra line break
|
433
|
+
def message_with_diff(message, differ)
|
434
|
+
diff = diffs(differ)
|
435
|
+
|
436
|
+
diff.empty? ? message : "#{message.rstrip}\n\n#{diff}"
|
437
|
+
end
|
368
438
|
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
439
|
+
private
|
440
|
+
|
441
|
+
# Add extra line breaks in between diffs, and colorize the word "Diff"
|
442
|
+
def diffs(differ)
|
443
|
+
@expected_list
|
444
|
+
.map do |(expected, diff_label, actual)|
|
445
|
+
diff = differ.diff(actual, expected)
|
446
|
+
next if diff.strip.empty?
|
447
|
+
diff_label + diff
|
448
|
+
end
|
449
|
+
.compact
|
450
|
+
.join("\n\n")
|
451
|
+
end
|
379
452
|
end
|
380
453
|
end
|
381
454
|
end
|
data/lib/super_diff/rspec.rb
CHANGED
@@ -81,7 +81,16 @@ module SuperDiff
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def self.aliased_matcher?(value)
|
84
|
-
|
84
|
+
if SuperDiff::RSpec.rspec_version < '3.13.0'
|
85
|
+
value.is_a?(::RSpec::Matchers::AliasedMatcher)
|
86
|
+
else # See Github issue #250.
|
87
|
+
!ordered_options?(value) && value.respond_to?(:base_matcher)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.ordered_options?(value)
|
92
|
+
defined?(::ActiveSupport::OrderedOptions) &&
|
93
|
+
value.is_a?(::ActiveSupport::OrderedOptions)
|
85
94
|
end
|
86
95
|
|
87
96
|
def self.rspec_version
|
@@ -124,3 +133,5 @@ module SuperDiff
|
|
124
133
|
end
|
125
134
|
|
126
135
|
require_relative 'rspec/monkey_patches'
|
136
|
+
|
137
|
+
RSpec.configuration.filter_gems_from_backtrace('super_diff')
|
data/lib/super_diff/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: super_diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elliot Winkler
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-01-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: attr_extras
|