Sha256: add8e95a70fd1589c6b2582ff32d63898070f9616276c800945c34f9c64055b9

Contents?: true

Size: 1.61 KB

Versions: 6

Compression:

Stored size: 1.61 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe SystemMetrics::Instrument::Base do
  include NotificationsSupport

  describe '#handle?' do
    it 'should handle any event whose name matches the pattern passed to the constructor' do
      instrument = SystemMetrics::Instrument::Base.new(/action_mailer$/)
      instrument.handles?(event(:name => 'recieve.action_mailer')).should be_true
      instrument = SystemMetrics::Instrument::Base.new(/action_controller$/)
      instrument.handles?(event(:name => 'process_action.action_controller')).should be_true
    end

    it 'should not handle an event whose name does not match the pattern passed to the constructor' do
      instrument = SystemMetrics::Instrument::Base.new(/action_mailer$/)
      instrument.handles?(event(:name => 'action_mailer.receive')).should be_false
      instrument = SystemMetrics::Instrument::Base.new(/action_controller$/)
      instrument.handles?(event(:name => 'action_controller.go')).should be_false
    end
  end

  describe '#ignore?' do
    it 'should always return false' do
      instrument = SystemMetrics::Instrument::Base.new(/action_mailer$/)
      instrument.ignore?(event(:name => 'process_action.action_mailer')).should be_false
      instrument.ignore?(event(:name => 'start_processing.action_controller')).should be_false
    end
  end

  describe '#prune_path' do
    it 'should allow path elements to be replaced' do
      instrument = SystemMetrics::Instrument::Base.new(/action_mailer$/)
      instrument.mapped_paths['/abc123'] = 'A'
      instrument.prune_path('/abc123/more/path').should == 'A/more/path'
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
system-metrics-0.2.5 spec/system_metrics/instrument/base_spec.rb
system-metrics-0.2.4 spec/system_metrics/instrument/base_spec.rb
system-metrics-0.2.3 spec/system_metrics/instrument/base_spec.rb
system-metrics-0.2.2 spec/system_metrics/instrument/base_spec.rb
system-metrics-0.2.1 spec/system_metrics/instrument/base_spec.rb
system-metrics-0.2.0 spec/system_metrics/instrument/base_spec.rb