弃用警告:ActionController::TestCase HTTP 请求方法在未来的 Rails 版本中将仅接受关键字参数
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}
您可以为 headers 和请求的其他配置传递更多关键字
编辑:请注意,您复制粘贴的实际错误已经告诉您这样做
"示例:
get :show, 参数: { id: 1 }, session: { user_id: 1 }
进程:更新,方法::post,参数:{id:1}"
我的测试收到弃用警告,但我不明白我应该如何重构我的测试以符合未来的 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}
您可以为 headers 和请求的其他配置传递更多关键字
编辑:请注意,您复制粘贴的实际错误已经告诉您这样做
"示例:
get :show, 参数: { id: 1 }, session: { user_id: 1 }
进程:更新,方法::post,参数:{id:1}"