-
-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hash include with composable matcher gives misleading diff #1120
Comments
Hello
You can try: # frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rspec"
end
require 'rspec/autorun'
RSpec.describe 'includes' do
it do
expect(
{
a: '123',
b: 'foo',
}
).to match(a: /2/, b: 'foo')
end
end |
Sorry to close the issue. My answer is not the one you expect. Let me have a further look. |
The issue here is that the differ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expecting a hash to include another when using composable matchers gives a misleading diff for the subset of the hash that did match:
Notice that
is in the diff, despite
"123"
being matched by/2/
- this can make it harder to determine what the problem is, with a larger hash.N.b. that the
expected {:a => "123", :b => "foo"} to include {:b => "bar"}
part of the failure message is good, and does indicate the problem - this issue is only about the "Diff:" part.Your environment
Steps to reproduce
Expected behavior
The diff does not highlight matched entries as different:
Actual behavior
The diff does highlight matched entries as different:
The text was updated successfully, but these errors were encountered: