Sha256: 9fa8f88b4495865d24882c4ef7bda53b82985155c3e36b1edfa258e7f972c018

Contents?: true

Size: 1.12 KB

Versions: 12

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 < Test::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

12 entries across 12 versions & 1 rubygems

Version Path
newrelic_rpm-3.7.1.188 test/new_relic/rack/agent_hooks_test.rb
newrelic_rpm-3.7.1.182 test/new_relic/rack/agent_hooks_test.rb
newrelic_rpm-3.7.1.180 test/new_relic/rack/agent_hooks_test.rb
newrelic_rpm-3.7.0.177 test/new_relic/rack/agent_hooks_test.rb
newrelic_rpm-3.7.0.174.beta test/new_relic/rack/agent_hooks_test.rb
newrelic_rpm-3.6.9.171 test/new_relic/rack/agent_hooks_test.rb
newrelic_rpm-3.6.8.168 test/new_relic/rack/agent_hooks_test.rb
newrelic_rpm-3.6.8.164 test/new_relic/rack/agent_hooks_test.rb
newrelic_rpm-3.6.7.159 test/new_relic/rack/agent_hooks_test.rb
newrelic_rpm-3.6.7.159.beta test/new_relic/rack/agent_hooks_test.rb
newrelic_rpm-3.6.7.152 test/new_relic/rack/agent_hooks_test.rb
newrelic_rpm-3.6.6.147 test/new_relic/rack/agent_hooks_test.rb