spy
spy copied to clipboard
Spy failing due to KWARGS handling with ::ActionController::Parameters without setting up strong parameter permitting
I'm trying to spy on a method that is expecting to receive an ::ActionController::Parameters object. While hash-like, it's not a hash anymore in Rails, and hasn't been for a while
However, the spy code here: and related
https://github.com/ryanong/spy/blob/master/lib/spy/subroutine.rb#L246-L248
is calling ** on the last parameter, trying to un-double-splat it. That fails, since ::ActionController::Parameters doesn't let you convert to a hash unless you first called permit (you get an error of):
ActionController::UnfilteredParameters: ActionController::UnfilteredParameters: unable to convert unpermitted parameters to hash
Normally, requiring permitted parameters is 100% the right and secure thing to do, but I am trying to pass the parameter object explicitly to this sub method (and spy on it for testing) for logging purposes, and I want to get the original values, so don't want to permit the parameters in my higher-level code.
Is there a workaround? This worked in Spy 1.3, but failing in Spy 1.4 and 1.5