require 'master.rb' require 'network_lookup.rb' describe "Master Server" do it "should timeout clients after seconds" do TestBed::testbeds.should == [] m=MasterApp.new(nil,{}) m.run sleep 0.3 m.valid.should be_true n=NetworkLookupApp.new(nil,{}) n.register(:client) m.clients.should == [:client] sleep 1 n2=NetworkLookupApp.new(nil,{}) n.register(:client2) m.clients.length.should <= 2 (m.clients.sort).should == [:client,:client2] class MasterApp EXPIRE_SECONDS=1 end m.clients.should == [:client2] sleep 1 m.clients.should == [] m.stop n.stop n2.stop TestBed::testbeds.should == [] end end