Sunspot and RSpec fail. The commit doesn't seem to be working

夙愿已清 提交于 2019-12-05 13:28:32

It was my fault for not reading the manual properly.

https://github.com/collectiveidea/sunspot_test/issues/9

It's necessary to add a magic bit to the description to make sure that Solr is started.

describe "my nice test", :search => true do
  thing = Factory.create(:thing)
  Sunspot.commit
  # do my search and test
  # now it works!
end

It's the :search => true that's important.

Just to add a little something to the response above; if using FactoryGirl:

FactoryGirl.define do
    after(:create) { Sunspot.commit } 
...
end

then you won't have to add the commit call on each test file...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!