diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb index f9ee142bfd..74a33d45ab 100644 --- a/activemodel/lib/active_model/observing.rb +++ b/activemodel/lib/active_model/observing.rb @@ -52,6 +52,10 @@ module ActiveModel end end + def count_observers + @observer_instances.size + end + protected def instantiate_observer(observer) #:nodoc: # string/symbol diff --git a/activemodel/test/cases/observing_test.rb b/activemodel/test/cases/observing_test.rb index e23bda0528..63686843b6 100644 --- a/activemodel/test/cases/observing_test.rb +++ b/activemodel/test/cases/observing_test.rb @@ -121,13 +121,11 @@ class ObserverTest < ActiveModel::TestCase foo = Foo.new FooObserver.instance.stub = stub FooObserver.instance.stub.expects(:event_with).with(foo) - Foo.send(:changed) Foo.send(:notify_observers, :on_spec, foo) end test "skips nonexistent observer event" do foo = Foo.new - Foo.send(:changed) Foo.send(:notify_observers, :whatever, foo) end end