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
Why when using have_attributes with multiple kind_of matchers and only one is a fails, it reports all of them as failures.
My understanding is when it's time compare the expected with the actual results the differ is given kind of String and that is why is reporting it as a failure.
Since we use the RSpec::Mocks::ArgumentMatchers::KindOf, ObjectFormatter is matching it with RSpec::Support::ObjectFormatter::DescribableMatcherInspector and then we get the kind of String from the KindOf description.
Your environment
Ruby version: 3.0.2p107
rspec-support version: 3.12
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.12"gem"rspec-support","3.12"endputs"Ruby version is: #{RUBY_VERSION}"require'rspec/autorun'Customer=Struct.new(:id,:name)RSpec.describe'fail'dosubject{Customer.new(123,'Some Name')}it'has an id and a name'doexpect(subject).tohave_attributes(id: kind_of(String),name: kind_of(String))endend
Expected behavior
expected#<struct Customer id=123, name="Some Name"> to have attributes {:id => kind of String, :name => kind of String} but had attributes {:id => 123, :name => "Some Name"}Diff:
@@ -1,3 +1,3 @@
-:id=>kindofString,
+:id=>123,:name=>"Some Name",
Actual behavior
expected#<struct Customer id=123, name="Some Name"> to have attributes {:id => kind of String, :name => kind of String} but had attributes {:id => 123, :name => "Some Name"}Diff:
@@ -1,3 +1,3 @@
-:id=>kindofString,
-:name=>kindofString,
+:id=>123,
+:name=>"Some Name",
The text was updated successfully, but these errors were encountered:
👋 Sadly this is a known limitation of the current differ, it compares strings so even if they match it produces a diff between the description and the expected, there is some work to change the differ and it may be improved at one point, but as it stands this is a "can't fix" for the current differ,
Subject of the issue
Why when using
have_attributes
with multiplekind_of
matchers and only one is a fails, it reports all of them as failures.My understanding is when it's time compare the expected with the actual results the differ is given
kind of String
and that is why is reporting it as a failure.Since we use the
RSpec::Mocks::ArgumentMatchers::KindOf
,ObjectFormatter
is matching it withRSpec::Support::ObjectFormatter::DescribableMatcherInspector
and then we get thekind of String
from theKindOf
description.Your environment
Steps to reproduce
Expected behavior
Actual behavior
The text was updated successfully, but these errors were encountered: