Backport of keyword parameters for controller tests for Rails 4?

193 views
Skip to first unread message

Victor Costan

unread,
Jun 11, 2015, 10:10:33 PM6/11/15
to rubyonra...@googlegroups.com
I'm trying to add Rails 5 support to an engine which (among other things) has a generator for controller tests.

I've ran into the keyword arguments deprecation warning at the bottom of this e-mail, and I'm in a bind now. If I use keyword arguments to get rid of the warnings, I lose Rails 4 compatibility.

So far, I've managed to write tests that work in current Rails and previous Rails, and I hope I'll be able to do that in the future. Is there any chance that the keyword arguments will be backported to Rails 4 via a gem, like strong_parameters were backported to Rails 3?

Thank you,
    Victor



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 }

Markus D.

unread,
Jan 7, 2016, 12:01:43 PM1/7/16
to Ruby on Rails: Core
+1 Would really ease transition to Rails 5 if I could write my tests the new way already in Rails 4.

Prem Sichanugrist

unread,
Jan 7, 2016, 1:33:02 PM1/7/16
to rubyonra...@googlegroups.com
I think that might be a good idea. 

Do you mind creating an issue and ping @sikachu on it? Or, do you want to take a crack at it? I might be able to look at this tomorrow.

-Prem

-- 
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Rafael Mendonça França

unread,
Jan 7, 2016, 1:34:39 PM1/7/16
to rubyonra...@googlegroups.com
I don't think it is necessary. You can still use the same syntax with Rails 4 and Rails 5, you will only see deprecations warnings, and I believe it is acceptable in this case.

Prem Sichanugrist

unread,
Jan 7, 2016, 1:41:11 PM1/7/16
to rubyonra...@googlegroups.com
Alternatively, you can wrap the `process` call with ActiveSupport::Deprecation.silence for now?


I still feel like having a gem that give support for 4.2 would be nice though, as it would suck when Rails 5.1 comes out ... but again, it's possible that you'll switch to kwargs syntax by that point and only support 5.0 and 5.1 :)

-Prem

Justin Coyne

unread,
Jun 29, 2016, 2:42:24 PM6/29/16
to Ruby on Rails: Core
I've created a module to mix into my tests when using Rails 4 that backports the new API.  Feel free to grab it: https://github.com/projectblacklight/blacklight/pull/1419/commits/59436b48828c96a013a207fab079d82d4bc2c793#diff-33612259a5fa283a3bc7ee0a2d0fc653R2

-Justin
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsub...@googlegroups.com.

To post to this group, send email to rubyonra...@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages