太阳黑子和RSpec失败。 提交似乎没有起作用
我有一些测试用RSpec运行Rails站点,但是尽管遵循了说明,事情本身并不是很好。
我通过工厂创建一篇文章,运行Sunspot.commit,然后检查结果。 我似乎总是画一个空白。 当我通过控制台或通过网站手动测试时,所有工作都可以找到。
有任何想法吗? 如何输出太阳黑子日志以查看发生了什么?
我的Gemfile有以下内容,我正在运行Rails 3.1.1
gem 'sunspot', '1.2.1' gem 'sunspot_rails' gem 'sunspot_test'
非常感谢,格雷姆
不正确阅读本手册是我的错。
https://github.com/collectiveidea/sunspot_test/issues/9
有必要在描述中添加一个魔术位以确保启动Solr。
describe "my nice test", :search => true do thing = Factory.create(:thing) Sunspot.commit # do my search and test # now it works! end
它是:search => true ,这很重要。
只是为上面的回应添加一些内容; 如果使用FactoryGirl:
FactoryGirl.define do after(:create) { Sunspot.commit } ... end
那么你就不必在每个测试文件上添加提交调用了……