加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 如何等待ES索引在Rspec和Capybara完成?

发布时间:2020-12-17 04:29:30 所属栏目:百科 来源:网络整理
导读:如何避免在该示例中使用sleep 1等待ES索引完成? describe Question do before do create :question,content: "Some test question",app: @app create :question,content: "Some other question",app: @app sleep 1 end it_behaves_like "search results fou
如何避免在该示例中使用sleep 1等待ES索引完成?
describe Question do
  before do
    create :question,content: "Some test question",app: @app
    create :question,content: "Some other question",app: @app
    sleep 1
  end

  it_behaves_like "search results found" do
    let(:query) { "Some" }
    let(:results) { ["Some test question","Some other question"] }
  end
end

解决方法

调用’refresh’API端点.如果您正在使用Tire和ActiveModel集成功能,那么它将是:
Question.tire.index.refresh

或者,您可以使用curl直接命中端点.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读