我正在使用扫地机观看模型并使用 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
如何禁用扫描器进行单元测试?谢谢!