Permalink
Browse files

Remove sleeps from #time specs to try to prevent failures

This method is coupled to Time.now and it is difficult to see how to
remove this coupling to make it easier to test. This change will
hopefully prevent the test from failing when run on slower systems but
it is still far from ideal.
  • Loading branch information...
1 parent 4a028fa commit 8ec7c3d4da164383dafab77f3f109eb37c3891e9 @reinh committed Sep 7, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 spec/statsd_spec.rb
View
@@ -113,21 +113,21 @@ class Statsd
describe "#time" do
it "should format the message according to the statsd spec" do
- @statsd.time('foobar') { sleep(0.001); 'test' }
- @socket.recv.must_equal ['foobar:1|ms']
+ @statsd.time('foobar') { 'test' }
+ @socket.recv.must_equal ['foobar:0|ms']
end
it "should return the result of the block" do
- result = @statsd.time('foobar') { sleep(0.001); 'test' }
+ result = @statsd.time('foobar') { 'test' }
result.must_equal 'test'
end
describe "with a sample rate" do
before { class << @statsd; def rand; 0; end; end } # ensure delivery
it "should format the message according to the statsd spec" do
- result = @statsd.time('foobar', 0.5) { sleep(0.001); 'test' }
- @socket.recv.must_equal ['foobar:1|ms|@0.5']
+ result = @statsd.time('foobar', 0.5) { 'test' }
+ @socket.recv.must_equal ['foobar:0|ms|@0.5']
end
end
end

0 comments on commit 8ec7c3d

Please sign in to comment.