super_diff 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 573a4d219dcad689aca11cffe1beaa7e3c4974958231b1cacd92c32ef0542d74
4
- data.tar.gz: dfb59c966c00ec59df137eb45289c056f1dd58ec461d36913b49527294c99da9
3
+ metadata.gz: 3ac91e4432f7f0811776000b7a7153addd51ae073428eb03c8ae46218a5fe63d
4
+ data.tar.gz: 81e25a8e85f13ecb77c6da4a8a923a4958d4f6695104841573bc80f0dec028b3
5
5
  SHA512:
6
- metadata.gz: 333c9c71197fa48a68e0328ae1eed9703e96838e6afcef4bc33dcc68f34761ad8b694a8e768bffe86d11372d14c34704634176d35bab5d6584e042fb3eb99627
7
- data.tar.gz: '09136f70b82bef9591e709fffb12023da3beb59d69a55d52f89171649e7df1e6bf618ba00bf6ad08ad404369da7b505cd5027a18917701e41737e07a48faa0c7'
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
- class ExpectedsForMultipleDiffs
313
- SuperDiff.insert_singleton_overrides(self) do
314
- # Add a key for different sides
315
- def from(expected)
316
- return expected if self === expected
317
-
318
- text = colorizer.wrap("Diff:", SuperDiff.configuration.header_color)
319
-
320
- if SuperDiff.configuration.key_enabled?
321
- text +=
322
- "\n\n" +
323
- colorizer.wrap(
324
- "┌ (Key) ──────────────────────────┐",
325
- SuperDiff.configuration.border_color
326
- ) + "\n" +
327
- colorizer.wrap("│ ", SuperDiff.configuration.border_color) +
328
- colorizer.wrap(
329
- "‹-› in expected, not in actual",
330
- SuperDiff.configuration.expected_color
331
- ) +
332
- colorizer.wrap(" │", SuperDiff.configuration.border_color) +
333
- "\n" +
334
- colorizer.wrap("", SuperDiff.configuration.border_color) +
335
- colorizer.wrap(
336
- "‹+› in actual, not in expected",
337
- SuperDiff.configuration.actual_color
338
- ) +
339
- colorizer.wrap(" │", SuperDiff.configuration.border_color) +
340
- "\n" +
341
- colorizer.wrap("", SuperDiff.configuration.border_color) +
342
- " in both expected and actual" +
343
- colorizer.wrap(" ", SuperDiff.configuration.border_color) +
344
- "\n" +
345
- colorizer.wrap(
346
- "└─────────────────────────────────┘",
347
- SuperDiff.configuration.border_color
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
- new([[expected, text]])
355
+ def colorizer
356
+ RSpec::Core::Formatters::ConsoleCodes
357
+ end
352
358
  end
353
359
 
354
- def colorizer
355
- RSpec::Core::Formatters::ConsoleCodes
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
- SuperDiff.insert_overrides(self) do
360
- # Add an extra line break
361
- def message_with_diff(message, differ, actual)
362
- diff = diffs(differ, actual)
423
+ new([[expected, text, actual]])
424
+ end
363
425
 
364
- diff.empty? ? message : "#{message.rstrip}\n\n#{diff}"
426
+ def colorizer
427
+ RSpec::Core::Formatters::ConsoleCodes
428
+ end
365
429
  end
366
430
 
367
- private
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
- # Add extra line breaks in between diffs, and colorize the word "Diff"
370
- def diffs(differ, actual)
371
- @expected_list
372
- .map do |(expected, diff_label)|
373
- diff = differ.diff(actual, expected)
374
- next if diff.strip.empty?
375
- diff_label + diff
376
- end
377
- .compact
378
- .join("\n\n")
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
@@ -81,7 +81,16 @@ module SuperDiff
81
81
  end
82
82
 
83
83
  def self.aliased_matcher?(value)
84
- value.is_a?(::RSpec::Matchers::AliasedMatcher)
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')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SuperDiff
4
- VERSION = '0.14.0'
4
+ VERSION = '0.15.0'
5
5
  end
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.14.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: 2024-11-15 00:00:00.000000000 Z
12
+ date: 2025-01-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: attr_extras