Sha256: 82f84621d3f218601cddd5e6a6437cc5d3cd86a32955a8890d3450d6217d599f

Contents?: true

Size: 1.9 KB

Versions: 20

Compression:

Stored size: 1.9 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/agent/instrumentation/sinatra/transaction_namer'

module NewRelic
  module Agent
    module Instrumentation
      module Sinatra

        class TransactionNamerTest < Test::Unit::TestCase

          def test_transaction_name_for_route
            env = { "newrelic.last_route" => /^\/the_route$/}
            request = stub(:request_method => "GET")
            result = TransactionNamer.transaction_name_for_route(env, request)
            assert_equal "GET the_route", result
          end

          def test_transaction_name_for_route_padrino
            env = {}
            route = stub(:original_path => "/path/:id")
            request = stub(:route_obj => route, :request_method => "GET")
            result = TransactionNamer.transaction_name_for_route(env, request)

            assert_equal "GET path/:id", result
          end

          def test_transaction_name_for_route_without_routes
            assert_nil TransactionNamer.transaction_name_for_route({}, nil)
          end

          def test_basic_sinatra_naming
            assert_transaction_name "(unknown)", "(unknown)"

            # Sinatra < 1.4 style regexes
            assert_transaction_name "will_boom", "^/will_boom$"
            assert_transaction_name "hello/([^/?#]+)", "^/hello/([^/?#]+)$"

            # Sinatra 1.4 style regexs
            assert_transaction_name "will_boom", "\A/will_boom\z"
            assert_transaction_name "hello/([^/?#]+)", "\A/hello/([^/?#]+)\z"
          end

          def assert_transaction_name(expected, original)
            assert_equal expected, TransactionNamer.transaction_name(original, nil)
          end

        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
newrelic_rpm-3.7.1.188 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.7.1.182 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.7.1.180 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.7.0.177 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.7.0.174.beta test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.9.171 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.8.168 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.8.164 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.7.159 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.7.159.beta test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.7.152 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.6.147 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.5.130 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.4.122 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.4.113.beta test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.3.111 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.3.106 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.3.105.beta test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.3.104 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.6.3.103.beta test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb