rspec / rspec-mocks

RSpec's 'test double' framework, with support for stubbing and mocking
https://rspec.info
MIT License
1.16k stars 357 forks source link

Improve error generator #1506

Closed JonRowe closed 1 year ago

JonRowe commented 1 year ago

The previous implementation of our keyword vs hash highlight only added the difference when arguments matched, this leads to confusion because the argument matcher check this in reverse (e.g. if the keywords / vs hash doesn't match it fast fails) meaning that RSpec can be ambiguous about whats failing to be more consitent we can show the extra diff information all the time if they mis match.

As an aside this PR also fixes an inconsitency with our empty diff "trim" logic where colourisation would produce an empty:

Diff:

As well as this the PR improves the specs by adding partial double checks as well (as given the keyword semantics these can exhibit different behaviour).

Fixes #1504