spec/support/event_catcher.rb in zk-1.2.0 vs spec/support/event_catcher.rb in zk-1.3.0

- old
+ new

@@ -27,19 +27,30 @@ synchronize do @events.values.each(&:clear) end end - def add(sym,obj) + def add(*args) synchronize do + case args.length + when 2 + sym, obj = args + when 1 + obj = args.first + sym = obj.interest_key + else + raise ArgumentError, "Dunno how to handle args: #{args.inspect}" + end + logger.debug { "adding #{sym.inspect} #{obj.inspect}" } events[sym] << obj cond(sym).broadcast events[:all] << obj cond(:all).broadcast end end + alias << add def wait_for(ev_name, timeout=5) cond(ev_name).wait(timeout) end