DEPRECATION WARNING: ActionController::TestCase HTTP request methods will accept only
keyword arguments in future Rails versions.
examples:
get :show, params: { id: 1 }, session: { user_id: 1 }
process :update, method: :post, params: { id: 1 }
I'm using Rails 5 alpha.
Instead of:
post :create, my_model: { some_attribute: 'some attribute' }
Rails 5 will accept only:
post :create, params: { my_model: { some_attribute: 'some attribute' } }
Warning called from:
shoulda-matchers-3.0.1/lib/shoulda/matchers/action_controller/permit_matcher.rb:250)
My spec:
it "permit only whitelisted params" do
params = { my_model: valid_attributes }
is_expected.to permit(
:name,
:release_date,
:description
).for(:create, params: params).on(:my_model)
end
My "solution" for now is
change:
.for(:create, params: params )
to:
.for(:create, params: { params: params } )
Okay! Thanks for the report. I've got a backlog right now of stuff to work through right now, but hopefully I can get to this before Rails 5 ships. PR appreciated. :)
So I don't need to make any changes to my RSpec, I can wait for the patch and it will fix all these deprecation warnings and save myself a bunch of trouble?
If you're still using Rails 4, yeah -- I know the warnings are annoying, but it's okay for right now. If you're using Rails 5 then there isn't a fix for this yet, unfortunately.
No worries. Is there going to be eventually? I'll keep an eye on this and leave it be if it will be fixed eventually, it's not actually causing a failed case yet.
This will be fixed by #964, so I'm going to go ahead and close this to clean things up.
Most helpful comment
No worries. Is there going to be eventually? I'll keep an eye on this and leave it be if it will be fixed eventually, it's not actually causing a failed case yet.