Skip to content

Add support for choosing differs #76

@dchelimsky

Description

@dchelimsky

We've had a few issues and pull requests dealing with diffing, but I think we need a more holistic solution. There are a growing number of diffing solutions out there now, each of which are going to appeal more to some people than others, so I think we should have a reasonable default behavior, but then expose an API for choosing your own differ. Something like:

RSpec.configure do |c|
  c.diff {|actual,expected| MyPreferredDefaultDiffer.diff(actual, expected)} # default
  c.diff(Hash)   {|expected,actual| MyPreferredHashDiffer.diff(expected, actual)}
  c.diff(Array)  {|expected,actual| MyPreferredArrayDiffer.diff(expected, actual)}
  c.diff(String) {|expected,actual| MyPreferredStringDiffer.diff(expected, actual)}
  # etc
end

The form with a single argument would invoke the supplied block if both expected and actual values match the argument, otherwise the default would be used.

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