2011-11-02 41 views
4

我已经有一些测试运行RSpec Rails站点,但尽管 遵循指示事情并不完全表现自己。太阳黑子和RSpec失败。提交似乎没有工作

我通过工厂创建一篇文章,运行Sunspot.commit,然后检查 的结果。我似乎总是画一个空白。当我通过控制台或通过网站手动测试 时,它的所有工作发现 虽然。

任何想法?如何输出太阳黑子日志以查看发生了什么?

我Gemfile中有以下内容,我跑的Rails 3.1.1

gem 'sunspot', '1.2.1' 
gem 'sunspot_rails' 
gem 'sunspot_test' 

非常感谢, 格雷姆

回答

9

这是我的不正确读取的手动故障。

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 

这是:搜索=>真这很重要。

+1

感谢。它解决了我的问题。 –

0

只是为上面的回复添加一些内容;如果使用FactoryGirl:

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

,那么你就不必添加提交调用每个测试文件...