ruby-on-rails - Rails 5 升级 - 控制器测试失败
问题描述
我对 Rails 相当陌生,并且刚刚开始从事一个需要从 Rails 4.2 更新到 Rails 5 的大型项目。我以前从未使用过很多 RSpec,并且在尝试升级时遇到了一些失败的测试。
测试的代码是:
describe "#index " do
it 'should return all plots associated to a purchaser' do
sign_in @user
get purchaser_plots_path(format: :json), params: {}, flash: {'Accept' => Mime::JSON}
_(response.status).must_equal 200
json = JSON.parse(response.body)
_(json.count).must_equal 2
_(json.first['id']).must_equal @plot_2.id
_(json.second['id']).must_equal @plot_1.id
end
it 'should paginate' do
sign_in @user
get purchaser_plots_path(format: :json), params: {page: 1, per_page: 1}, flash: {'Accept' => Mime::JSON}
_(response.status).must_equal 200
json = JSON.parse(response.body)
_(json.count).must_equal 1
_(json.first['id']).must_equal @plot_2.id
get purchaser_plots_path(format: :json), params: {page: 2, per_page: 1}, flash: {'Accept' => Mime::JSON}
_(response.status).must_equal 200
json = JSON.parse(response.body)
_(json.count).must_equal 1
_(json.first['id']).must_equal @plot_1.id
end
end
这给了我以下错误:
Error:
PurchaserPlotControllerTest::#index #test_0001_should return all plots associated to a purchaser:
ArgumentError: unknown keyword: flash
test/controllers/purchaser/plots_controller_test.rb:21:in `block (2 levels) in <class:PurchaserPlotControllerTest>'
我在网上找到的所有帮助似乎都表明“flash”是一个允许的关键字参数,所以我不确定我做错了什么!
任何帮助将不胜感激。
解决方案
推荐阅读
- svn - Teamforge 从数据库迁移到 Gforge 存储库
- angular - 将 swagger UI 调用与 Angular 前端调用区分开来
- angular - 如何防止从角度 6 中的日期字符串中删除零
- java - 在完全创建实例之前(在同一个构造函数内)JAVA 使用“this”关键字来引用同一个实例时,java 如何解析引用
- c - 如何在 epoll 中使用环回设备(或类似设备)?
- c - 如何使用 switch case 更新值
- c# - C#粘贴文本通过验证
- javascript - 如果复选框也未选中,则始终获得相同的值
- node.js - Nodejs-如何在登录功能中获取用户详细信息
- css - 在图像上制作正方形?