我想在我的练习管理应用程序中创建用于搜索患者的功能规范.
到目前为止,我已经搜索了网络,并遵循以下建议的解决方案:
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
这两篇文章都建议为ElasticSearch和Tire配置spec_helper.rb.由于Searchkick基于Tire,我将解决方案应用于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
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Failure/Error: Unable to find matching line from backtrace
NoMethodError:
undefined method `index_name'
Run Code Online (Sandbox Code Playgroud)
方法'index'和'create_elasticsearch_index'也是如此
我对RoR很新,老实说我不确定我在这里做错了什么,除了假设我可以在Searchkick上使用Tire解决方案.所以任何帮助都非常感谢!