Sha256: 98b30176622b20e4e25cef013bbe4bb96ed848ec70821b061c090981812a940c

Contents?: true

Size: 1.49 KB

Versions: 21

Compression:

Stored size: 1.49 KB

Contents

# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2016

require 'test_helper'
require 'rack/test'

class CubaTest < Minitest::Test
  include Rack::Test::Methods

  # rack < 3.0.0 returns a two long array `app, options`
  # rack >= 3.0.0 returns only the app
  APP, *  = Rack::Builder.parse_file('test/support/apps/cuba/config.ru')

  def app
    APP
  end

  def test_basic_get
    clear_all!

    r = get '/hello'
    assert last_response.ok?

    assert r.headers.key?("X-Instana-T")
    assert r.headers.key?("X-Instana-S")

    spans = ::Instana.processor.queued_spans
    assert_equal 1, spans.count

    first_span = spans.first
    assert_equal :rack, first_span[:n]
    assert first_span.key?(:data)
    assert first_span[:data].key?(:http)

    assert first_span[:data][:http].key?(:method)
    assert_equal "GET", first_span[:data][:http][:method]

    assert first_span[:data][:http].key?(:url)
    assert_equal "/hello", first_span[:data][:http][:url]

    assert first_span[:data][:http].key?(:status)
    assert_equal 200, first_span[:data][:http][:status]

    assert first_span[:data][:http].key?(:host)
    assert_equal "example.org", first_span[:data][:http][:host]
  end

  def test_path_template
    clear_all!

    r = get '/greet/instana'
    assert last_response.ok?

    spans = ::Instana.processor.queued_spans
    assert_equal 1, spans.count

    first_span = spans.first
    assert_equal :rack, first_span[:n]
    assert_equal '/greet/{name}', first_span[:data][:http][:path_tpl]
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
instana-1.217.1 test/frameworks/cuba_test.rb
instana-1.217.0 test/frameworks/cuba_test.rb
instana-1.216.0 test/frameworks/cuba_test.rb
instana-1.215.1 test/frameworks/cuba_test.rb
instana-1.215.0 test/frameworks/cuba_test.rb
instana-1.214.4 test/frameworks/cuba_test.rb
instana-1.214.3 test/frameworks/cuba_test.rb
instana-1.214.2 test/frameworks/cuba_test.rb
instana-1.214.1 test/frameworks/cuba_test.rb
instana-1.214.0 test/frameworks/cuba_test.rb
instana-1.213.3 test/frameworks/cuba_test.rb
instana-1.213.2 test/frameworks/cuba_test.rb
instana-1.213.1 test/frameworks/cuba_test.rb
instana-1.213.0 test/frameworks/cuba_test.rb
instana-1.212.0 test/frameworks/cuba_test.rb
instana-1.211.0 test/frameworks/cuba_test.rb
instana-1.210.1 test/frameworks/cuba_test.rb
instana-1.210.0 test/frameworks/cuba_test.rb
instana-1.209.8 test/frameworks/cuba_test.rb
instana-1.209.7 test/frameworks/cuba_test.rb