spec/lib/fozzie/interface_spec.rb in fozzie-0.0.20 vs spec/lib/fozzie/interface_spec.rb in fozzie-0.0.21

- old
+ new

@@ -35,13 +35,13 @@ subject.increment([:foo, 1, nil, "@", "BAR"]) end it "times a given block" do - subject.expects(:timing).with() {|b, val, timing| b == 'data.bin' && (1000..1200).include?(val) }.twice - subject.time_for('data.bin') { sleep 1 } - subject.time_to_do('data.bin') { sleep 1 } + subject.expects(:timing).with() {|b, val, timing| b == 'data.bin' && (1..11).include?(val) }.twice + subject.time_for('data.bin') { sleep 0.01 } + subject.time_to_do('data.bin') { sleep 0.01 } end it "registers a commit" do subject.expects(:timing).with(['event', 'commit', nil], anything).twice subject.commit @@ -60,12 +60,12 @@ subject.deployed end it "ensures block is called on socket error" do UDPSocket.any_instance.stubs(:send).raises(SocketError) - proc { subject.time_for('data.bin') { sleep 1 } }.should_not raise_error - proc { subject.time_to_do('data.bin') { sleep 1 } }.should_not raise_error + proc { subject.time_for('data.bin') { sleep 0.01 } }.should_not raise_error + proc { subject.time_to_do('data.bin') { sleep 0.01 } }.should_not raise_error end it "raises exception if natural exception from block" do proc { subject.time_for('data.bin') { raise ArgumentError, "testing" } }.should raise_error(ArgumentError) end @@ -77,10 +77,11 @@ val = subject.time_for('data.bin') { i+= p.call(i) } val.should == 1 end it "raises Timeout on slow lookup" do - UDPSocket.any_instance.stubs(:send).with(any_parameters) { sleep 0.6 } + Fozzie.c.timeout = 0.01 + UDPSocket.any_instance.stubs(:send).with(any_parameters) { sleep 0.4 } subject.increment('data.bin').should eq false end describe "#increment_on" do \ No newline at end of file