【发布时间】:2014-02-16 17:05:41
【问题描述】:
我想在我的实践管理应用中创建用于搜索患者的功能规范。
到目前为止,我已经在网上搜索并遵循了以下建议的解决方案:
http://bitsandbit.es/post/11295134047/unit-testing-with-tire-and-elastic-search#disqus_thread
和
https://github.com/karmi/tire/wiki/Integration-Testing-Rails-Models-with-Tire
这两篇文章都建议在 spec_helper.rb 中配置 ElasticSearch 和 Tire。由于 Searchkick 是基于轮胎的,因此我将解决方案应用于 Patient 类,这是我使用 Searchkick 的唯一模型。
但是,对于每个配置,我都会收到“NoMEthodError”。 例如,使用以下代码:
spec_helper.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 上使用轮胎解决方案。因此,非常感谢任何帮助!
【问题讨论】:
标签: ruby-on-rails rspec