splitwise/super_diff

Exclude more un-diffable objects

Closed this issue · 0 comments

Background

We currently don't attempt to produce a diff when the expected value is a symbol, integer, boolean, nil:

expected.is_a?(Symbol) || expected.is_a?(Integer) ||
[true, false, nil].include?(expected)

(We also don't attempt to produce a diff when both the expected and actual are single-line strings.)

Problem

We still attempt to produce diffs for types that are fundamentally difficult to diff, such as:

  • Other Numerics (e.g. floats, BigDecimals)
  • Regexps
  • Classes
  • Modules
  • Ranges (see #267)
  • Procs (which RSpec's built-in differ already specifically avoids)

For these types, the "diff" adds no information to the inspection above the diff. For example:

     Failure/Error: expect(p1).to eq(p2)

       Expected #<Proc:0x00000001061a7b68> to eq #<Proc:0x00000001061a7af0>.

       Diff:

       ┌ (Key) ──────────────────────────┐
       │ ‹-› in expected, not in actual  │
       │ ‹+› in actual, not in expected  │
       │ ‹ › in both expected and actual │
       └─────────────────────────────────┘

         #<Proc:0x00000001061a7b68 {
         }>

Solution

Mark more object types as not worth_diffing?.