Rails 5 introduced some deprecation messages in my tests
DEPRECATION WARNING: Using positional arguments in functional tests has been deprecated,
in favor of keyword arguments, and will be removed in Rails 5.1.
Deprecated style:
get :show, { id: 1 }, nil, { notice: "This is a flash message" }
New keyword style:
get :show, params: { id: 1 }, flash: { notice: "This is a flash message" },
session: nil # Can safely be omitted.
For this most part, these have been easy to resolve. The instructions are pretty clear in the message.
But I'm still getting these warnings for controller specs that test strong params.
How should the following be rewritten to prepare for Rails 5.1?
let(:user) { create :user }
it { is_expected.to permit( :name, :email ).for(:update, params: { id: user.to_param, user: valid_attributes } ).on(:user) }
Try:
for(:update, params: { params: { id: user.to_param, user: valid_attributes } })
It's ugly, but that worked for me.
Update: found my workaround and fix number here https://github.com/thoughtbot/shoulda-matchers/issues/867
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With