Sha256: 61eba08595d8e935a32db146a00928da2fe53dd69901730d25603b22e54c4c09

Contents?: true

Size: 1.51 KB

Versions: 40

Compression:

Stored size: 1.51 KB

Contents

# Copyright (c) 2015 AppNeta, Inc.
# All rights reserved.

require 'minitest_helper'
require 'rack/test'
require 'rack/lobster'
require 'traceview/inst/rack'

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

  def app
    @app = Rack::Builder.new {
      use Rack::CommonLogger
      use Rack::ShowExceptions
      use TraceView::Rack
      map "/lobster" do
        use Rack::Lint
        run Rack::Lobster.new
      end
    }
  end

  def test_custom_do_not_trace
    clear_all_traces

    dnt_original = TraceView::Config[:dnt_regexp]
    TraceView::Config[:dnt_regexp] = "lobster$"

    get "/lobster"

    traces = get_all_traces
    assert traces.empty?

    TraceView::Config[:dnt_regexp] = dnt_original
  end

  def test_do_not_trace_static_assets
    clear_all_traces

    get "/assets/static_asset.png"

    traces = get_all_traces
    assert traces.empty?

    assert last_response.status == 404
  end

  def test_complex_do_not_trace
    skip "not supported" if RUBY_VERSION < '1.9'

    clear_all_traces

    dnt_original = TraceView::Config[:dnt_regexp]

    # Do not trace .js files _except for_ show.js
    TraceView::Config[:dnt_regexp] = "(\.js$)(?<!show.js)"

    # First: We shouldn't trace general .js files
    get "/javascripts/application.js"

    traces = get_all_traces
    assert traces.empty?

    # Second: We should trace show.js
    clear_all_traces

    get "/javascripts/show.js"

    traces = get_all_traces
    assert !traces.empty?

    TraceView::Config[:dnt_regexp] = dnt_original
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
traceview-3.8.3-java test/support/dnt_test.rb
traceview-3.8.3 test/support/dnt_test.rb
traceview-3.8.2-java test/support/dnt_test.rb
traceview-3.8.2 test/support/dnt_test.rb
traceview-3.8.1-java test/support/dnt_test.rb
traceview-3.8.1 test/support/dnt_test.rb
traceview-3.8.0-java test/support/dnt_test.rb
traceview-3.8.0 test/support/dnt_test.rb
traceview-3.7.1-java test/support/dnt_test.rb
traceview-3.7.1 test/support/dnt_test.rb
traceview-3.7.0-java test/support/dnt_test.rb
traceview-3.7.0 test/support/dnt_test.rb
traceview-3.6.0-java test/support/dnt_test.rb
traceview-3.6.0 test/support/dnt_test.rb
traceview-3.5.1-java test/support/dnt_test.rb
traceview-3.5.1 test/support/dnt_test.rb
traceview-3.5.0-java test/support/dnt_test.rb
traceview-3.5.0 test/support/dnt_test.rb
traceview-3.4.2-java test/support/dnt_test.rb
traceview-3.4.2 test/support/dnt_test.rb