簡體   English   中英

太陽黑子和RSpec失敗。 提交似乎沒有起作用

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

我有一些測試用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

那么你就不必在每個測試文件上添加提交調用了......

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM