Sha256: 72446715b30c1c56926e827cf80fd675053a22962d9581c8c6ba1897c8ff461f

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
require 'new_relic/rack/agent_hooks'

class AgentHooksTest < MiniTest::Unit::TestCase

  def setup
    @app = stub_everything
    @hooks = NewRelic::Rack::AgentHooks.new(@app)
    @env = {:env => "env"}
  end

  def test_before_call
    NewRelic::Agent.instance.events.expects(:notify).with(:before_call, @env)
    NewRelic::Agent.instance.events.stubs(:notify).with(:after_call, anything, anything)

    @hooks.call(@env)
  end

  def test_after_call
    result = stub
    @app.stubs(:call).returns(result)

    NewRelic::Agent.instance.events.stubs(:notify).with(:before_call, anything)
    NewRelic::Agent.instance.events.expects(:notify).with(:after_call, @env, result)

    @hooks.call(@env)
  end

  def test_nested_agent_hooks_still_fire_only_once
    nested = NewRelic::Rack::AgentHooks.new(@hooks)

    NewRelic::Agent.instance.events.expects(:notify).times(2)
    nested.call(@env)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
newrelic_rpm-3.7.2.195 test/new_relic/rack/agent_hooks_test.rb
newrelic_rpm-3.7.2.192 test/new_relic/rack/agent_hooks_test.rb
newrelic_rpm-3.7.2.190.beta test/new_relic/rack/agent_hooks_test.rb