Skip to content

What should happen when you use an anything fuzzy matcher inside a Hash on your specs? #241

Open
@KarlHeitmann

Description

@KarlHeitmann

Hi!

I've opened a PR in rspec-support with a hacky fix to the problem you get when you compare an actual hash with a expected hash and they differ, but the expected hash includes some values whose values correspond to the anything matcher.

My PR contains some tests showing the failure and the fix. But the code changes I've made on the rspec differ engine is trivial:

  1. Navigate the expected hash and retrieve all keys you must dig in that hash in order to find values that are anything fuzzy matcher.
  2. Use these keys to fetch the data on the actual hash, and replace the anything values on your expected hash by the values you fetched on the actual hash.
  3. Later, when the diff string is generated, with the morph you made on the expected var on step (2), the diff string will NOT calculate the diff on the key-value pairs you had before the anything fuzzy matcher. The result is you will have a clean diff showing you only the right values that differ and you are interested in.

I'd like to implement this behavior on super_diff, but I know my proposal may be hacky. What are your thoughts about it? Any feedback is appreciated.

I am reading your specs and the source code of super_differ, I'm looking forward to collaborate here or in rspec-support, because diffs is a topic that I found very interesting.

Best.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions