Skip to content

Commit

Permalink
enforce code covereage on every run and with low overhead
Browse files Browse the repository at this point in the history
had to remove gemspec from Gemfile or the file would be uncovereage since it is loaded before
coverage starts
  • Loading branch information
grosser committed Feb 3, 2018
1 parent ebe159b commit 26695e3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
source 'https://rubygems.org'
gemspec

gem 'rake', '10.1.0'
gem 'rack', '~> 1.6'
gem 'minitest'
gem "yard", "~> 0.8.7.3"
gem 'jeweler', '~> 1.8'
gem 'simplecov'
gem 'single_cov'

group :development do
gem "faker", "~> 1.2.0"
Expand Down
2 changes: 1 addition & 1 deletion dogstatsd-ruby.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$:.unshift File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require "datadog/statsd"

Gem::Specification.new do |s|
Expand Down
8 changes: 4 additions & 4 deletions lib/datadog/statsd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ class Statsd
class << self
# Set to a standard logger instance to enable debug logging.
attr_accessor :logger
end

# Return the current version of the library.
def self.VERSION
"3.2.0"
# Return the current version of the library.
def VERSION
"3.2.0"
end
end

# @param [String] host your statsd host
Expand Down
7 changes: 4 additions & 3 deletions spec/helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
require 'bundler/setup'

require 'single_cov'
SingleCov.setup :minitest

require 'minitest/autorun'
require 'faker'

$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)

require 'simplecov'
SimpleCov.start

require 'datadog/statsd'
require 'logger'

Expand Down
15 changes: 15 additions & 0 deletions spec/statsd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require 'stringio'
require 'mocha/mini_test'

SingleCov.covered! file: 'lib/datadog/statsd.rb'

describe Datadog::Statsd do
class Datadog::Statsd
# we need to stub this
Expand All @@ -14,6 +16,12 @@ class Datadog::Statsd
@statsd.socket = FakeUDPSocket.new
end

describe ".VERSION" do
it "has a version" do
Datadog::Statsd.VERSION.must_match /^\d+\.\d+\.\d+/
end
end

describe "#initialize" do
it "should set the host and port" do
@statsd.host.must_equal 'localhost'
Expand Down Expand Up @@ -363,6 +371,13 @@ def helper_time_return
end
end

describe "#distribution" do
it "send a message with d type" do
@statsd.distribution('begrutten-suffusion', 536)
@statsd.socket.recv.must_equal ['begrutten-suffusion:536|d']
end
end

describe "with namespace" do
before { @statsd.namespace = 'service' }

Expand Down

0 comments on commit 26695e3

Please sign in to comment.