We have a custom matcher that matches "as_json-able" objects.
RSpec::Matchers.define :as_json do |expected|
def actual = super.as_json
match { |actual| values_match? expected, actual }
diffable
end
For diffing, it redefines the actual.
This matcher correctly emits diffs when used "directly" but when used as an argument matcher within a mock, the diff output no longer respects the redefined actual.
Subject of the issue
We have a custom matcher that matches "
as_json
-able" objects.For diffing, it redefines the
actual
.This matcher correctly emits diffs when used "directly" but when used as an argument matcher within a mock, the diff output no longer respects the redefined actual.
I suspect this may be related to https://github.com/rspec/rspec-expectations/issues/1317
Your environment
Steps to reproduce
https://gist.github.com/jasonkarns/7ac8c418dc155ef3d3555c3a0d9ecc64
Expected behavior
Given the tests in linked gist above, I would expect the failure output to print the diffable values comparing the overridden
actual
:something like:
Actual behavior
The argument matcher failure message ignores the overridden
actual
value of the nested matcher and instead diffs against the originalactual
: