DEPRECATION WARNING: ActionDispatch::IntegrationTest
Closed this issue · 7 comments
When the test suite is run under Rails 5:
DEPRECATION WARNING: ActionDispatch::IntegrationTest HTTP request methods will accept only
the following keyword arguments in future Rails versions:
params, headers, env, xhr, as
Examples:
get '/profile',
params: { id: 1 },
headers: { 'X-Extra-Header' => '123' },
env: { 'action_dispatch.custom' => 'custom' },
xhr: true,
as: :json
(called from block (3 levels) in <top (required)> at /home/adamsunday/workspace/tiddle/spec/strategy_spec.rb:131)
The tricky part here is that the solution has to work both with Rails 4.2 and Rails 5.0.
I ran into this too, from railstutorial chapter 13 in the microposts_interface_test. It comes from the each line:
post microposts_path, micropost: { parameters in here }
I changed that to:
post microposts_path, params: { micropost: { parameters in here } }
and this made the test work without any warnings
@KenLast Thank you for reporting your findings. That's exactly the way how it should be solved! However, we need to test both under Rails 4.2 and Rails 5.0 and the new version is not available in Rails 4.2. This creates an interesting problem how to support both versions of Rails at the same time.
Adam,
What are you working on? I am quite new to both Rails and Ruby, as my only
experience with either is working through Michael Hartl's railstutorial.
However, it seems that Ruby is quite open to redefinitions. Is it possible
to redefine the HTTP request parameter format conditionally based on Ruby
version?
Ken
On Mon, Sep 26, 2016 at 10:31 AM, Adam Niedzielski <notifications@github.com
wrote:
@KenLast https://github.com/KenLast Thank you for reporting your
findings. That's exactly the way how it should be solved! However, we need
to test both under Rails 4.2 and Rails 5.0 and the new version is not
available in Rails 4.2. This creates an interesting problem how to support
both versions of Rails at the same time.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#30 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AVZzCAstPC-GByLoT5jDIth80If__X8-ks5quAGPgaJpZM4JDYYD
.
I'm not working on this issue at this moment, because it's not super critical. I left it here for anyone willing to contribute to the gem.
Yes, it may be tempting to redefine the method, because it's so easy in Ruby. However, from my experience, it is usually confusing to other developers and makes the codebase more difficult to understand. What I would prefer in this case is to define a test helper (spec/support
) which checks for Rails version and invokes the method with the correct way of passing arguments.
I can help you a bit if you want to submit a PR.
What gem is this from? I thought it was just from Rails.
On Mon, Sep 26, 2016 at 1:39 PM, Adam Niedzielski notifications@github.com
wrote:
I'm not working on this issue at this moment, because it's not super
critical. I left it here for anyone willing to contribute to the gem.Yes, it may be tempting to redefine the method, because it's so easy in
Ruby. However, from my experience, it is usually confusing to other
developers and makes the codebase more difficult to understand. What I
would prefer in this case is to define a test helper (spec/support) which
checks for Rails version and invokes the method with the correct way of
passing arguments.I can help you a bit if you want to submit a PR.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#30 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AVZzCOFg7kftTkcedWTEAYnifQ1rIdFtks5quC2dgaJpZM4JDYYD
.
Was getting close to the same error in the railstutorial: test > integration > users_login_test.rb and changed from
post login_path, session: { email: @user.email, password: 'password' }
to
post login_path, params: {session: { email: @user.email, password: 'password' }}
worked like a charm.
thanks
@KenLast yes, it's from Rails, but we have to solve this problem in this gem (Tiddle) to be compatible with both Rails 4.2 and Rails 5.0
@jessedo81 Thank you for your contribution and good luck starting with Rails!