Sha256: f4984568665ec63c7579ea2ef088384f6a377db2697dbed1d29e8376792d39e3

Contents?: true

Size: 1.25 KB

Versions: 21

Compression:

Stored size: 1.25 KB

Contents

require 'test_helper'

class ActiveSupportTestCase < IntegrationTest
  def test_a_gauge_is_logged
    ActiveSupport::Notifications.instrument "gauge_test.harness", :gauge => true do |args|
      # do nothing
    end

    assert_gauge_logged "gauge_test.harness"
  end

  def test_a_counter_is_logged
    ActiveSupport::Notifications.instrument "counter_test.harness", :counter => { :value => 5 } do |args|
      # do nothing
    end

    assert_counter_logged "counter_test.harness"
  end

  def test_can_log_both
    ActiveSupport::Notifications.instrument "test.harness", :gauge => { :id => "test-gauge" }, :counter => {:id => 'test-counter', :value => 5 } do |args|
      # do nothing
    end

    assert_counter_logged "test-counter"
    assert_gauge_logged "test-gauge"
  end

  def test_does_not_log_counter_on_exception
    begin
      ActiveSupport::Notifications.instrument "counter_test.harness", :counter => true do |args|
        raise
      end
    rescue
    end

    refute_counter_logged "counter_test.harness"
  end

  def test_does_not_log_gauge_on_exception
    begin
      ActiveSupport::Notifications.instrument "gauge_test.harness", :gauge => true do |args|
        raise
      end
    rescue
    end

    refute_gauge_logged "gauge_test.harness"
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
harness-0.2.5 test/integration/instrumentation_test.rb