Sha256: 2f51bab9f86cf3d8f8ed3522cd90eaf7c6d39c7697e8ac9468b50caaba058200

Contents?: true

Size: 1.9 KB

Versions: 25

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

          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

25 entries across 25 versions & 1 rubygems

Version Path
newrelic_rpm-3.14.1.311 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.14.0.305 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.13.2.302 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.13.1.300 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.13.0.299 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.12.1.298 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.12.0.288 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.11.2.286 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.11.1.284 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.11.0.283 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.10.0.279 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.9.9.275 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.9.8.273 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.9.7.266 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.9.6.257 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.9.5.251 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.9.4.245 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.9.3.241 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.9.2.239 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb
newrelic_rpm-3.9.1.236 test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb