提醒:Enabling/disabling observers for testing 2011年04月14日

来自: kinderman.net
订阅:martin
演示:以MSN订阅提醒为例 订阅到哪吒,有更新提醒我
哪吒机器人提醒:
提醒:kinderman.net
【标题】Enabling/disabling observers for testing
【摘要】If you use ActiveRecord observers in your application and are concerned about the isolation of your model unit tests, you probably want some way to disable/enable observers. Unfortunately, Rails doesn't provide an easy way to do this. So, here's some code I threw together a while ago to do just that.module ObserverTestHelperMethods def observer_instances ActiveRecord::Base.observers.collect do |observer| observer_klass = \ if observer.respond_to?(:to_sym) observer.to_s.camelize.constantize... (04-14 22:19)
收藏 |  评论 |  推荐给好友  | 
本文共有 0 次分享
评论
共有 - 条评论


我要反馈