test/statsd_test.rb in statsd-client-0.0.4 vs test/statsd_test.rb in statsd-client-0.0.5

- old
+ new

@@ -24,10 +24,17 @@ should "not log when not sampled" do fake_rand(0.11) expect_nothing Statsd.timing('test.stat', 23, 0.1) end + + should "work with a block" do + expected_send(/^test.stat:2[234]\|ms$/) + Statsd.timing('test.stat') do + sleep 0.023 + end + end end context "increment" do @@ -108,17 +115,18 @@ def fake_rand(v) Statsd.stubs(:rand).returns(v) end def expected_send(buf) - UDPSocket.any_instance.expects(:send).with(buf, 0, Statsd.host_ip_addr, Statsd.port).once + buf_re = Regexp.new(buf) + UDPSocket.any_instance.expects(:send).with(regexp_matches(buf_re), 0, Statsd.host_ip_addr, Statsd.port).once end def expect_nothing UDPSocket.any_instance.expects(:send).never end def loopback?(ip) ['::1', '127.0.0.1'].include?(ip) end -end \ No newline at end of file +end