super_diff 0.15.0 → 0.16.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ac91e4432f7f0811776000b7a7153addd51ae073428eb03c8ae46218a5fe63d
4
- data.tar.gz: 81e25a8e85f13ecb77c6da4a8a923a4958d4f6695104841573bc80f0dec028b3
3
+ metadata.gz: a7da584c29393f807295a740d893c8890b5d33f9507f4c0ddd914b672b5e9b71
4
+ data.tar.gz: 89e8cb0b6bd46b7f109b91421636acb21356e14c1e75e0acbd6a45d22b086172
5
5
  SHA512:
6
- metadata.gz: f9dd989b77d595b455c73ca7daf7191a9bb5f45f28dedeef4a1729b31f4933935b006beb2c640f063a6041fddb5596f46d876585f995526ed60de5c552ec3b68
7
- data.tar.gz: 3f50f8e32f20a2bccdb9b5ca18f39ae9e8b9ebffbe601ce91ecfe0b742d7fffd6ca44fe78a65a5c6fc93598630d37c0d8bd06c27aff352afa27780d103b1413b
6
+ metadata.gz: 573603b3933aa21c388973e295565199e0c15660a28f7204d1a9d281f0ca320cf28e80bbaf0b9074df13c1e0ea324a5654844985a3f0db9011eb2bb5ff3b7c6c
7
+ data.tar.gz: 8daa4e73a589b67ac571ea101d7080a1487daf13dc42ce0ce7ee224b9801fd8ed3399e8380c9611cec4d2e93dc5611af3c9bbd5da02c434245d9fda5f127de19
data/README.md CHANGED
@@ -28,7 +28,7 @@ Since [RSpec merely runs your `expected` and `actual` values through Ruby's Pret
28
28
  and then performs a diff of these strings,
29
29
  the output it produces leaves much to be desired.
30
30
 
31
- [rspec-differ-fail]: https://github.com/rspec/rspec-support/blob/c69a231d7369dd165ad7ce4742e1a2e21e3462b5/lib/rspec/support/differ.rb#L178
31
+ [rspec-differ-fail]: https://github.com/rspec/rspec/blob/rspec-support-v3.13.2/rspec-support/lib/rspec/support/differ.rb#L180-L192
32
32
 
33
33
  For instance, let's say you wanted to compare these two hashes:
34
34
 
@@ -111,9 +111,9 @@ for more on how to do that.
111
111
  ## Compatibility
112
112
 
113
113
  `super_diff` is [tested][gh-actions] to work with
114
- Ruby >= 3.x,
114
+ Ruby >= 3.1,
115
115
  RSpec 3.x,
116
- and Rails >= 6.x.
116
+ and Rails >= 6.1.
117
117
 
118
118
  [gh-actions]: https://github.com/splitwise/super_diff/actions?query=workflow%3ASuperDiff
119
119
 
@@ -27,7 +27,11 @@ module SuperDiff
27
27
 
28
28
  t1.nested do |t2|
29
29
  t2.insert_separated_list(
30
- [id] + (object.attributes.keys.sort - [id])
30
+ if id.nil?
31
+ object.attributes.keys.sort
32
+ else
33
+ [id] + (object.attributes.keys.sort - [id])
34
+ end
31
35
  ) do |t3, name|
32
36
  t3.as_prefix_when_rendering_to_lines do |t4|
33
37
  t4.add_text "#{name}: "
@@ -7,7 +7,7 @@ class ActiveRecord::Base
7
7
  id_attr = self.class.primary_key
8
8
 
9
9
  (attributes.keys.sort - [id_attr]).reduce(
10
- { id_attr.to_sym => id }
10
+ id_attr.nil? ? {} : { id_attr.to_sym => id }
11
11
  ) { |hash, key| hash.merge(key.to_sym => attributes[key]) }
12
12
  end
13
13
  end
@@ -16,6 +16,8 @@ module SuperDiff
16
16
  end
17
17
 
18
18
  def attribute_names
19
+ return expected.attributes.keys.sort if id.nil?
20
+
19
21
  [id] + (expected.attributes.keys.sort - [id])
20
22
  end
21
23
  end
@@ -352,6 +352,26 @@ module RSpec
352
352
  new([[expected, text]])
353
353
  end
354
354
 
355
+ def for_many_matchers(matchers)
356
+ # Look for expected_for_diff and actual_for_diff if possible
357
+ diff_tuples = matchers.map do |m|
358
+ expected = if m.respond_to?(:expected_for_diff)
359
+ m.expected_for_diff
360
+ else
361
+ m.expected
362
+ end
363
+
364
+ actual = if m.respond_to?(:actual_for_diff)
365
+ m.actual_for_diff
366
+ else
367
+ m.actual
368
+ end
369
+ [expected, diff_label_for(m), actual]
370
+ end
371
+
372
+ new(diff_tuples)
373
+ end
374
+
355
375
  def colorizer
356
376
  RSpec::Core::Formatters::ConsoleCodes
357
377
  end
@@ -423,6 +443,26 @@ module RSpec
423
443
  new([[expected, text, actual]])
424
444
  end
425
445
 
446
+ def for_many_matchers(matchers)
447
+ # Look for expected_for_diff and actual_for_diff if possible
448
+ diff_tuples = matchers.map do |m|
449
+ expected = if m.respond_to?(:expected_for_diff)
450
+ m.expected_for_diff
451
+ else
452
+ m.expected
453
+ end
454
+
455
+ actual = if m.respond_to?(:actual_for_diff)
456
+ m.actual_for_diff
457
+ else
458
+ m.actual
459
+ end
460
+ [expected, diff_label_for(m), actual]
461
+ end
462
+
463
+ new(diff_tuples)
464
+ end
465
+
426
466
  def colorizer
427
467
  RSpec::Core::Formatters::ConsoleCodes
428
468
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SuperDiff
4
- VERSION = '0.15.0'
4
+ VERSION = '0.16.0'
5
5
  end
data/super_diff.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  'rubygems_mfa_required' => 'true',
23
23
  'source_code_uri' => 'https://github.com/splitwise/super_diff'
24
24
  }
25
- s.required_ruby_version = '>= 3.0'
25
+ s.required_ruby_version = '>= 3.1'
26
26
 
27
27
  s.files = %w[README.md super_diff.gemspec] + Dir['lib/**/*']
28
28
  s.executables = Dir['exe/**/*'].map { |f| File.basename(f) }
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.15.0
4
+ version: 0.16.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: 2025-01-06 00:00:00.000000000 Z
12
+ date: 2025-06-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: attr_extras
@@ -262,14 +262,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
262
262
  requirements:
263
263
  - - ">="
264
264
  - !ruby/object:Gem::Version
265
- version: '3.0'
265
+ version: '3.1'
266
266
  required_rubygems_version: !ruby/object:Gem::Requirement
267
267
  requirements:
268
268
  - - ">="
269
269
  - !ruby/object:Gem::Version
270
270
  version: '0'
271
271
  requirements: []
272
- rubygems_version: 3.5.20
272
+ rubygems_version: 3.4.19
273
273
  signing_key:
274
274
  specification_version: 4
275
275
  summary: A better way to view differences between complex data structures in RSpec.