thoughtbot--shoulda-matchers/lib/shoulda/matchers/doublespeak
Elliot Winkler 7cc91f9b4a Doublespeak: Define #respond_to_missing? on ObjectDouble
The `delegate_method` matcher uses Doublespeak internally to do its job.
The delegate object is completely stubbed using an ObjectDouble,
available from Doublespeak, which is shoulda-matchers's own test double
library. ObjectDouble is a class that responds to every
method by implementing `method_missing`.

Say you are using Ruby 2.4 and you are testing a class that uses the
Forwardable module to do some delegation, and you are using
`delegate_method` in your test. When you run your test you will a
warning that looks something like:

    Courier#deliver at ~/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/forwardable.rb:156 forwarding to private method #deliver

Why is this happening? When the code in your class gets exercised,
Forwardable will delegate the delegate method in question to
ObjectDouble, and the method will get intercepted by its
`method_missing` method. The fact that this is actually a private method
is what Forwardable is complaining about.

To fix this, all we need to do is add `respond_to_missing?` in addition
to `method_missing?`. This is explained here:

    https://bugs.ruby-lang.org/issues/13326
2017-09-17 17:46:06 -05:00
..
double.rb Add debugging helps to Doublespeak 2015-09-29 18:42:08 -06:00
double_collection.rb Improve architecture for permit matcher 2015-09-29 18:42:08 -06:00
double_implementation_registry.rb Extract examples in README to inline documentation 2014-06-20 16:41:27 -06:00
method_call.rb Add debugging helps to Doublespeak 2015-09-29 18:42:08 -06:00
object_double.rb Doublespeak: Define #respond_to_missing? on ObjectDouble 2017-09-17 17:46:06 -05:00
proxy_implementation.rb Doublespeak: Proxies store return value in MethodCall 2015-03-01 00:39:51 -07:00
stub_implementation.rb Doublespeak: Introduce a better MethodCall 2015-03-01 00:39:50 -07:00
world.rb Fix #permit so #on works and is properly tested 2015-09-29 10:29:46 -06:00