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
Using .to match with a complex expectation that mixes pure values with "fuzzy" matchers like anything produces false positives in Diff, obfuscating which key actually differs from the expectation.
I don't know whether this is a problem with match or anything/*_including.
Your environment
Ruby version: 2.7.5 (also on 2.7.6)
rspec-expectations version: 3.11.0
Steps to reproduce
# frozen_string_literal: truebeginrequire"bundler/inline"rescueLoadError=>e
$stderr.puts"Bundler version 1.10 or later is required. Please update your Bundler"raiseeendgemfile(true)dosource"https://rubygems.org"gem"rspec","3.11.0"gem"rspec-expectations","3.11.0"gem"rspec-mocks","3.11.1"endputs"Ruby version is: #{RUBY_VERSION}"require'rspec/autorun'RSpec.describe'false positive in #match diff'doit'reports excess rows as mismatching'doexpect(a: :a,b: [:b,:bb],c: :c,d: :d,).tomatch(a: anything,b: array_including(:b),c: :c,d: :actual_mismatch,)endend
JonRowe
changed the title
.to match Diff reports false positives when used with "fuzzy" matchers like anything
Diff reports confusing output when used with "fuzzy" matchers like anythingOct 25, 2022
👋 Hi, this is a known limitation of our differ which essentially only uses strings to produce diffs, so its unaware that the two sides did match it just sees the difference in the output used, theres not much we can do about it without a complete rewrite of the differ which is something we are interested in but has yet to find someone with enough time to finish it, I've transferred the issue to rspec-support which provides this functionality and renamed it slightly to better keep track of it, it related to #365 and #518.
Subject of the issue
Using
.to match
with a complex expectation that mixes pure values with "fuzzy" matchers likeanything
produces false positives in Diff, obfuscating which key actually differs from the expectation.I don't know whether this is a problem with
match
oranything
/*_including
.Your environment
Steps to reproduce
Output:
Expected behavior
I'm expecting that Diff part will highlight only the key(s) actually failing their asserts, which is only
:d
.Actual behavior
Unfortunately, keys
:a
and:b
are also highlighted, likely due to them using "fuzzy" matchers.The text was updated successfully, but these errors were encountered: