1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00
thoughtbot--shoulda-matchers/lib/shoulda/matchers/doublespeak
Elliot Winkler 0259d15711 Improve architecture for permit matcher
Why:

* There were architectural issues with how the permit matcher kept track
  of params instances on which doubles had been placed. Previously we
  were starting off by taking the ActionController::Parameters class and
  stubbing the #permit and #require instance method on it -- in other
  words, we were stubbing #require for all instances of
  ActionController::Parameters -- then we would stub #permit on a
  particular instance of ActionController::Parameters that #require
  returned. What this means is that if for some reason the #permit stub
  on an individual instance isn't working properly, then the #permit
  stub on ActionController::Parameters will respond to the invocation.
  This is exactly what happened for the issue we recently fixed --
  if the stubbing were done a different way we wouldn't have run into
  that issue.
* Also, there's no reason to have both ParametersDoubles and
  SliceOfParametersDoubles classes around. While it's nice that we have
  a simpler option to use if we don't need the more complex one, we
  actually don't need a distinction here, and we can afford one class
  that does both.

To satisfy the above:

* When stubbing #permit or #require, always do so on an instance of
  ActionController::Parameters and not the whole class. This way we know
  exactly which methods are being doubled and it's easier to debug things
  in the future.
* This means that we now stub ActionController::Parameters.new and then
  place stubs on the returned instance.
* Refactor ParametersDoubles and SliceOfParametersDoubles: combine them
  into a ParametersDoubleRegistry class, but extract the code that stubs
  ActionController::Parameters.new into
  a CompositeParametersDoubleRegistry class.
* Since this broke one of the tests, modify DoubleCollection so that a
  method cannot be doubled more than once -- if the method is already
  doubled then `register_stub` or `register_proxy` does nothing and
  returns the original Double.
2015-09-29 18:42:08 -06: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 Add debugging helps to Doublespeak 2015-09-29 18:42:08 -06: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