Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove ParametersMatcher from Invocation#call_description
This is a somewhat odd usage of `ParametersMatcher` which unnecessarily couples it to `Invocation#call_description`. The `mocha_inspect` logic is duplicated in `Invocation#argument_description` for now because it ought to be possible for them to work differently, specifically because an `Invocation` should never contain matchers. The main motivation behind this change is that it allows `Invocation` and `ParametersMatcher` to have different APIs - currently `ParametersMatcher#initialize` needs an array of args or matchers, which `Invocation#arguments` can fit into. The hope is that `Invocation` can have separate `#positional_arguments` and `#keyword_arguments` (see #544), and we don't want to expose a public `#arguments` method just to fit into `ParametersMatcher`'s API. We might even be able to build the descriptions completely from `#positional_arguments` and `#keyword_arguments`, which would change the logic here and make it no longer duplicated. It's also worth mentioning that duplication notwithstanding, the changes in this commit remove a fair amount of indirection: - `Invocation#arguments` passes an Array of objects into `ParametersMatcher#initialize`. - `ParametersMatcher#mocha_inspect` will first convert that Array into an Array of `ParameterMatchers::Equals` with the original object as the underlying value (the assumption here is that `Invocation#arguments` would not include any matchers instances, so all elements would be converted to `ParameterMatchers::Equals`). - `Array#mocha_inspect` will then call `ParameterMatchers::Equals#mocha_inspect`, which then calls `mocha_inspect` on the underlying value. The changes in this commit mean that `mocha_inspect` is called on the original objects immediately instead. Closes #543.
- Loading branch information