1

我使用的是清掃觀看模型,並做一些記錄與snogmetrics:如何禁用緩存清掃器測試目的

class UserSweeper < ActionController::Caching::Sweeper 
    observe User 

    def after_create(user) 
    km.identify(user.email) 
    end 
end 

我與清道夫,而不是一個觀察者,因爲snogmetrics這樣做需要會話才能正常工作。

然而,雖然測試,snogmetrics完全失敗

NoMethodError: undefined method `identify' for nil:NilClass 

我如何可以禁用單元測試的清掃?謝謝!

+0

'km'定義在哪裏? – jdl

+0

它由snogmetrics定義。 https://github.com/iconara/snogmetrics – TLK

回答

0

我能夠在測試過程中使用no-peeping-toms gem來阻止觀察者。

注意:這也適用於rake任務。我在移植過程中遇到過觀察員被問到的問題,並解決了這個問題。

0

km定義在哪裏?從我看到的情況來看,它並沒有在你的user_sweeper中定義,所以無論你身處何處,它都會失敗。