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.9.1 test/integration/instrumentation_test.rb
harness-0.9.0 test/integration/instrumentation_test.rb
harness-0.8.1 test/integration/instrumentation_test.rb
harness-0.8.0 test/integration/instrumentation_test.rb
harness-0.7.0 test/integration/instrumentation_test.rb
harness-0.6.0 test/integration/instrumentation_test.rb
harness-0.5.0 test/integration/instrumentation_test.rb
harness-0.4.0 test/integration/instrumentation_test.rb
harness-0.3.0 test/integration/instrumentation_test.rb
harness-0.2.16 test/integration/instrumentation_test.rb
harness-0.2.15 test/integration/instrumentation_test.rb
harness-0.2.14 test/integration/instrumentation_test.rb
harness-0.2.13 test/integration/instrumentation_test.rb
harness-0.2.12 test/integration/instrumentation_test.rb
harness-0.2.11 test/integration/instrumentation_test.rb
harness-0.2.10 test/integration/instrumentation_test.rb
harness-0.2.9 test/integration/instrumentation_test.rb
harness-0.2.8 test/integration/instrumentation_test.rb
harness-0.2.7 test/integration/instrumentation_test.rb
harness-0.2.6 test/integration/instrumentation_test.rb