-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected error : unable to convert unpermitted parameters to hash #159
Comments
If don't use my custom matcher (which is just a wrapper) and use directly the "original" rspec helper, it works |
found why customer matcher has an not sure how to solve that |
also lets say I override to_h in my action controller params to not raise params and return actual hash, super diff continue and deep_inspect the whole actual Takes literally minutes |
Also for the record: my matcher was not constructed properly and the matching was failing, hence super_diff triggering (when the custom matcher runs successfully, the issue is not here) |
@ngouy You say you're using a custom matcher and that a controller instance ends up being inspected when the matcher fails. Out of curiosity what is the test look like itself? |
💯 that's exactly that |
Test is a swagger test and it goes something like post "/whatever" do
response "200", "it does something" do
run_test! do
expect(response["created_at"]).to be_within_last(3.seconds) # my custom matcher call
end
end
end |
@ngouy @mcmire we're having the same issue when testing using rails controller functional test like
We can probably leverage custom diffing object (https://github.com/mcmire/super_diff#diffing-custom-objects) but not sure how complex it is? For now the poor man solution is to disable super diff for this controller specs
Is there any options to disable super diff for a given test? |
When I run a specific spec without supper diff, spec is passing
When I run it with it, it is failing
The spec is using a custom matcher, that is itself a wrapp of a regular matcher:
I have absolutely no clue on how it's working behind the scene. But here is what i can observe with debug breakpoints
It is failing in
object_inspection/inspection_tree_builders/default_object.rb:46
In this context
object
is an instance a spec:RSpec::ExampleGroups::SurveysSubmissions::SurveysSubmissions::Post::<etc...> "does something"
One of the object instance_variable is
@controller
(which carries an instance of a controller)So it runs
add_inspection_of(@controller)
Which latter on, recursively, goes to the exact same code where
object
is the actual@controller
In this context,
object
is now instance of one of a controllerbecause one of the
object.instance_variable
is@_params = ActionController::Parameters <instance>
And it runs
add_inspection_of(@_params)
, which triggers:actionpack-7.0.4/lib/action_controller/metal/strong_parameters.rb:309 ActionController::Parameters#to_h:
The text was updated successfully, but these errors were encountered: