-
Notifications
You must be signed in to change notification settings - Fork 61
Closed
Labels
Description
When an expectation that two Range objects are equal is violated, the super_diff output hides the values within the Ranges:
Failure/Error: expect(actual).to eq(expected)
Expected #<Range:0x00007ff9338559b0> to eq #<Range:0x00007ff933855988>.
Diff:
┌ (Key) ──────────────────────────┐
│ ‹-› in expected, not in actual │
│ ‹+› in actual, not in expected │
│ ‹ › in both expected and actual │
└─────────────────────────────────┘
#<Range:0x00007ff9338559b0 {
}>
# repro.rb:20:in `block (2 levels) in <main>'
which makes it hard to diagnose the cause as you can't see the values within. The default RSpec formatter makes it clear:
Failure/Error: expect(actual).to eq(expected)
expected: 1..20
got: 1..10
(compared using ==)
Diff:
@@ -1 +1 @@
-1..20
+1..10
# repro.rb:20:in `block (2 levels) in <main>'
would it be possible to change the super_diff output to show the values within the Ranges?
A standalone reproduction script:
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'rspec', "= 3.11.0"
gem 'super_diff', "= 0.9.0", require: false
end
require "rspec/autorun"
# Uncomment the next line to see less-useful output
# require "super_diff/rspec"
RSpec.describe "Range comparisons" do
it do
actual = (1..10)
expected = (1..20)
expect(actual).to eq(expected)
end
end
Thanks,
Owen.
paul110 and iainbeeston