The hyperlink to `object_double` in the Markdown source makes the line longer than it is when rendered on Relish, and the line break after "work if you" thus makes the line look too short compared to others on Relish.
Any method call may mutate an object, so we can't safely call anything on a passed argument. This reverts the following PRs and commits: * #871: * 8a0962a ("Reword comment to not use “external” twice.") * 52c69f1 ("Just use `Array#hash`.") * #868: * ed3fb3b ("Provide a clear error when received message args are mutated.") * fc9e9a5 ("Ignore arg mutations for method calls we are not concerned with.") This adds notes to the docs about using mutated args with `have_received(…).with(…)`. Fixes #892.
The unimplemented error message gives no indication of whether the object is a class or instance double. This change passes that object to the error generator so that it can create a more specific message depending on whether it is an instance or class double. It defaults to the original "<object> does not implement <method>" for anything else. #838
This also makes `extend RSpec::Mocks::ExampleMethods` work properly. Fixes #845.
Behaviour is already covered by specs.
Specifically adds: * spy - responds and spies all methods * instance_spy - responds and spies all methods to which a specified class responds. * object_spy - responds and spies all methods to which a specific instance responds * class_spy - responds and spies all class methods to which a specific class responds I added test coverage for the expected behaviours and added some YARD docs to the new methods.
The old cukes were a mess: - Lots of duplication and inconsistencies. - Functioned poorly as documentation. - Didn't highlight the new syntax well. - Didn't really cover all of rspec-mocks' features. The new ones were structurd specifically with documentation in mind. The specs are meant more for regression coverage. We've limited the cukes to just things people may actually want to read as part of docs. I've also reworked the test unit cuke as a minitest cuke. For reference, here's the before/after from cucumber: Before: 77 scenarios (77 passed) 276 steps (276 passed) 0m48.014s After: 89 scenarios (89 passed) 328 steps (328 passed) 0m57.844s Fixes #591.
Arity is just the number of arguments but we check more than that now, so it's good to reflect that.