Skip to content

Commit

Permalink
Specs for logging changes
Browse files Browse the repository at this point in the history
Better late than never
  • Loading branch information
raykrueger committed Jun 23, 2011
1 parent e6ab90c commit 58033b6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'statsd'
require 'logger'

class FakeUDPSocket
def initialize
Expand Down
22 changes: 22 additions & 0 deletions spec/statsd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,28 @@ def socket; @socket ||= FakeUDPSocket.new end
@statsd.socket.recv.must_equal ['service.foobar:500|ms']
end
end

describe "with logging" do
require 'stringio'
before { Statsd.logger = Logger.new(@log = StringIO.new)}

it "should write to the log in debug" do
Statsd.logger.level = Logger::DEBUG

@statsd.increment('foobar')

@log.string.must_match "Statsd: foobar:1|c"
end

it "should not write to the log unless debug" do
Statsd.logger.level = Logger::INFO

@statsd.increment('foobar')

@log.string.must_be_empty
end

end
end

describe Statsd do
Expand Down

0 comments on commit 58033b6

Please sign in to comment.