You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require"bundler/inline"gemfiledosource"https://rubygems.org"gem"rspec","3.13.0"gem"super_diff","0.12.1"endrequire"rspec/autorun"require"super_diff/rspec"ifENV["SUPERDIFF"]Point=Data.define(:x,:y)RSpec.describe"Comparing data class instances"doit"fails as expected"doexpect(Point.new(1,2)).toeq(Point.new(1,3))endend
Here's the output I get without supediff:
$ ruby superdiff_worse_output.rb
F
Failures:
1) Comparing data class instances fails as expected
Failure/Error: expect(Point.new(1, 2)).to eq(Point.new(1, 3))
expected: #<data Point x=1, y=3>
got: #<data Point x=1, y=2>
(compared using ==)
Diff:
@@ -1 +1 @@
-#<data Point x=1, y=3>
+#<data Point x=1, y=2>
# superdiff_worse_output.rb:16:in `block (2 levels) in <main>'
Finished in 0.00721 seconds (files took 0.06477 seconds to load)
1 example, 1 failure
Failed examples:
rspec superdiff_worse_output.rb:15 # Comparing data class instances fails as expected
In contrast, when superdiff is loaded:
$ SUPERDIFF=1 ruby superdiff_worse_output.rb
F
Failures:
1) Comparing data class instances fails as expected
Failure/Error: expect(Point.new(1, 2)).to eq(Point.new(1, 3))
Expected #<Point:0x0000000112bf3e08> to eq #<Point:0x0000000112bf3bd8>.
Diff:
#<Point:0x0000000112bf3e08 {
}>
# /Users/myron/.rvm/gems/ruby-3.2.3/gems/super_diff-0.12.1/lib/super_diff/rspec/monkey_patches.rb:43:in `handle_failure'
# superdiff_worse_output.rb:16:in `block (2 levels) in <main>'
Finished in 0.00988 seconds (files took 0.06686 seconds to load)
1 example, 1 failure
Failed examples:
rspec superdiff_worse_output.rb:15 # Comparing data class instances fails as expected
The RSpec output without superdiff is better, IMO--I can easily tell that the y values differed! But with superdiff loaded I can't tell anymore.
The text was updated successfully, but these errors were encountered:
Thanks for the repro @myronmarston. Looks like we're falling back on the DefaultObject inspection + operation tree builders, which look for object instance variables instead of the Data object's #members. This should just be a matter of implementing inspection + operation tree builders that are aware of the Data class – I've started working on a PR.
Closes#252.
Ruby 3.2.0 introduced the
[Data](https://bugs.ruby-lang.org/issues/16122) construct, which looks a
lot like an object to this project, but uses `#members` instead of
instance variables.
The solution is to introduce an object inspection tree builder and
operation tree builder that are essentially the same as the
corresponding builders for default objects, but know to read the members
of the Data class instead of instance variables.
Given
superdiff_worse_output.rb
:Here's the output I get without supediff:
In contrast, when superdiff is loaded:
The RSpec output without superdiff is better, IMO--I can easily tell that the
y
values differed! But with superdiff loaded I can't tell anymore.The text was updated successfully, but these errors were encountered: