Sha256: 516452fe83178409d0ff2e14db6e46bd39a2b505329d3e5bb0df825670c42694

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

require_relative 'test_helper'

class InstrumentationTest < MiniTest::Unit::TestCase
  class Worker
    include Harness::Instrumentation
  end

  attr_reader :worker

  def setup
    @worker = Worker.new
  end

  def test_can_use_increments
    worker.increment 'foo', 0.5
    assert_increment 'foo'
  end

  def test_can_use_decrements
    worker.decrement 'foo', 0.5
    assert_decrement 'foo'
  end

  def test_can_use_count
    worker.count 'foo', 1, 0.5
    assert_counter 'foo'
  end

  def test_can_use_gauges
    worker.gauge 'foo', 5, 0.5
    assert_gauge 'foo'
  end

  def test_can_use_timings
    worker.timing 'foo', 5, 0.5
    assert_timer 'foo'
  end

  def test_can_be_timed
    result = worker.time 'foo', 0.5 do
      'bar'
    end

    assert_equal 'bar', result, "#time did not return block's value"
    assert_timer 'foo'
  end

  def test_also_works_with_extend
    extended = Class.new do
      extend Harness::Instrumentation
    end

    assert_respond_to extended, :increment
    assert_respond_to extended, :decrement
    assert_respond_to extended, :count
    assert_respond_to extended, :time
    assert_respond_to extended, :timing
    assert_respond_to extended, :gauge
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
harness-2.0.0 test/instrumentation_test.rb
harness-1.0.2 test/instrumentation_test.rb
harness-1.0.1 test/instrumentation_test.rb