Fix Active Model observer tests
This commit is contained in:
parent
2161b8745a
commit
1924cff934
|
@ -52,6 +52,10 @@ module ActiveModel
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def count_observers
|
||||||
|
@observer_instances.size
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def instantiate_observer(observer) #:nodoc:
|
def instantiate_observer(observer) #:nodoc:
|
||||||
# string/symbol
|
# string/symbol
|
||||||
|
|
|
@ -121,13 +121,11 @@ class ObserverTest < ActiveModel::TestCase
|
||||||
foo = Foo.new
|
foo = Foo.new
|
||||||
FooObserver.instance.stub = stub
|
FooObserver.instance.stub = stub
|
||||||
FooObserver.instance.stub.expects(:event_with).with(foo)
|
FooObserver.instance.stub.expects(:event_with).with(foo)
|
||||||
Foo.send(:changed)
|
|
||||||
Foo.send(:notify_observers, :on_spec, foo)
|
Foo.send(:notify_observers, :on_spec, foo)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "skips nonexistent observer event" do
|
test "skips nonexistent observer event" do
|
||||||
foo = Foo.new
|
foo = Foo.new
|
||||||
Foo.send(:changed)
|
|
||||||
Foo.send(:notify_observers, :whatever, foo)
|
Foo.send(:notify_observers, :whatever, foo)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue