Ruby on rails Rspec-Elasticsearch自动回调在(:all)之前运行,但不在(:each)之前运行
当我在rspec中的before(:all)中创建记录时,也会创建索引,但它在before(:each)中不起作用。为什么会这样 例如: 我使用elasticsearch模型gem触发自动回调 如果我这样做Ruby on rails Rspec-Elasticsearch自动回调在(:all)之前运行,但不在(:each)之前运行,ruby-on-rails,elasticsearch,rspec,Ruby On Rails,elasticsearch,Rspec,当我在rspec中的before(:all)中创建记录时,也会创建索引,但它在before(:each)中不起作用。为什么会这样 例如: 我使用elasticsearch模型gem触发自动回调 如果我这样做 describe "#update_company_indexes" do before(:all) do Company.__elasticsearch__.create_index! force: true FactoryGirl.create(:company)
describe "#update_company_indexes" do
before(:all) do
Company.__elasticsearch__.create_index! force: true
FactoryGirl.create(:company)
end
end
只要执行了FactoryGirl.create(:company),就会创建公司索引
但是相同的代码以前不起作用(:each)。您能提供一些代码吗?嗨,伊利亚,对问题进行了更改。您能提供一些代码吗?嗨,伊利亚,对问题进行了更改