![](/img/trans.png)
[英]DEPRECATION WARNING: ActionController::TestCase HTTP request methods will accept only keyword arguments
[英]DEPRECATION WARNING: ActionController::TestCase HTTP request methods will accept only keyword arguments in future Rails versions
我的测试收到过时警告,但我不明白如何重构测试才能与将来的Rails版本兼容。 我是从多个测试中得到的,因此附上了最简单的示例测试,即存在hight_voltage静态页面。
这是我的测试>
describe HighVoltage::PagesController, '#show' do
%w(about conditions).each do |page|
context "on GET to /pages/#{page}" do
before do
get :show, id: page
end
it { should respond_with(:success) }
it { should render_template(page) }
end
end
end
这是弃用警告。
*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 }
(called from block (4 levels) in <top (required)> at /Users/kimmo/Documents/care-city/spec/controllers/pages_controller_spec.rb:5)
DEPRECATION WARNING: ActionController::TestCase HTTP request methods will accept only
keyword arguments in future Rails versions.
您必须为参数添加“ params:”
get :show, params: {id: page}
您可以为标题传递更多关键字,并为请求传递其他配置
编辑:请注意,您复制粘贴的实际错误已经告诉您执行此操作
“例子:
获取:show,参数:{id:1},会话:{user_id:1}
进程:update,方法::post,参数:{id:1}“
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.