2
我得到了我的测试的弃用警告,但我不明白我应该如何重构我的测试以符合未来的rails版本。我从多个测试中得到这个结果,所以附加了最简单的示例hight_voltage静态页面存在的示例。DEPRECATION警告:ActionController :: TestCase HTTP请求方法将在未来的Rails版本中只接受关键字参数
这里是我的测试>
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.
http://blog.bigbinary.com /2016/04/19/changes-to-test-controllers-in-rails-5.html – max
一个好方法是开始使用请求规格而不是控制器规格。不幸的是,rspec-rails还没有完全赶上现有技术,并且仍然生成控制器规格。 – max
谢谢@max我认为我需要为我的所有测试做一些重构 –