Ruby on rails 如何测试太阳黑子搜索结果或命中率
我在测试使用太阳黑子搜索的索引页时出错Ruby on rails 如何测试太阳黑子搜索结果或命中率,ruby-on-rails,sunspot,kaminari,Ruby On Rails,Sunspot,Kaminari,我在测试使用太阳黑子搜索的索引页时出错 *** NoMethodError Exception: undefined method `[]' for nil:NilClass 我写的代码是 @object.hits 此错误也发生在 @object.results 我试过@object.present@object.blank@object.nil 我使用kaminari对结果进行分页 = paginate(@object.hits) 通过在我的测试用例之前添加Model.reindex解
*** NoMethodError Exception: undefined method `[]' for nil:NilClass
我写的代码是
@object.hits
此错误也发生在
@object.results
我试过@object.present@object.blank@object.nil
我使用kaminari对结果进行分页
= paginate(@object.hits)
通过在我的测试用例之前添加Model.reindex解决了这个问题
setup do
Model.reindex
end