Sha256: cfa49ffcb1fae94353090518d38a53ece5e7f7c35300a43906e8de91ab628cb2

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

require 'test/unit'
require 'mocha/setup'
require 'newrelic-rake'

class TestNewRelicRake < Test::Unit::TestCase
  include NewRelic::Agent::Instrumentation::ControllerInstrumentation

  def setup
    NewRelic::Agent.manual_start
    @engine = NewRelic::Agent.instance.stats_engine
    @engine.clear_stats

    @sampler = NewRelic::Agent.instance.transaction_sampler
    @sampler.reset!
    @sampler.start_builder
  end

  def teardown
    @sampler.clear_builder
  end

  def test_ignore_delayed_job
    Rake::Task.define_task('jobs:work')
    Rake::Task['jobs:work'].invoke
    assert !@engine.metrics.include?('OtherTransaction/Rake/Rake::Task/jobs:work'), 'jobs:work task is in metrics'
  end

  def test_metrics
    Rake::Task.define_task('foo')
    Rake::Task['foo'].invoke
    assert @engine.metrics.include?('OtherTransaction/Rake/Rake::Task/foo'), 'rake task is not in metrics'
  end

  def test_dispatcher
    NewRelic::Agent.expects(:manual_start)
    Rake::Task.define_task('bar')
    Rake::Task['bar'].invoke
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
newrelic-rake-1.4.1 test/newrelic_rake_test.rb
newrelic-rake-1.4.0 test/newrelic_rake_test.rb