我想创建用于在我的实践管理应用程序中搜索患者的功能规范。
到目前为止,我已经在网上搜索并遵循了以下建议的解决方案:
http://bitsandbit.es/post/11295134047/unit-testing-with-tire-and-elastic-search#disqus_thread http://bitsandbit.es/post/11295134047/unit-testing-with-tire-and-elastic-search#disqus_thread
and
https://github.com/karmi/tire/wiki/Integration-Testing-Rails-Models-with-Tire https://github.com/karmi/tire/wiki/Integration-Testing-Rails-Models-with-Tire
这两篇文章都建议为 ElasticSearch 和 Tire 配置spec_helper.rb。由于 Searchkick 基于 Tire,因此我将解决方案应用于 Patient 类,这是我使用 Searchkick 的唯一模型。
但是,我的每个配置都收到“NoMethodError”。
例如,使用以下代码:
规格助手.rb
RSpec.configure do |config| do
.
.
.
config.before :each do
Patient.index.delete
Patient.create_elasticsearch_index
end
config.before :all do
Patient.index_name('test' + Patient.model_name.plural)
end
end
我收到以下错误:
Failure/Error: Unable to find matching line from backtrace
NoMethodError:
undefined method `index_name'
方法“index”和“create_elasticsearch_index”也会发生同样的情况
我对 RoR 相当陌生,老实说,我不确定我在这里可能做错了什么,除非假设我可以在 Searchkick 上使用 Tire 解决方案。因此,非常感谢任何帮助!