哪吒机器人提醒:

提醒: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)