Sha256: 70bae22401fdca258edd6cf1650439b68c321ee67570a0389c6a09b043a7c832

Contents?: true

Size: 1.2 KB

Versions: 14

Compression:

Stored size: 1.2 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.

class SinatraErrorTracingTestApp < Sinatra::Base
  configure do
    set :show_exceptions, false
  end

  get '/will_boom' do
    raise 'Boom!'
  end

  error do
    'We are sorry'
  end
end

class SinatraErrorTracingTest < Test::Unit::TestCase
  include Rack::Test::Methods
  include ::NewRelic::Agent::Instrumentation::Sinatra

  def app
    SinatraErrorTracingTestApp
  end

  def setup
    ::NewRelic::Agent.manual_start
    @error_collector = ::NewRelic::Agent.instance.error_collector

    @error_collector.errors.clear
    assert(@error_collector.enabled?,
           'error collector should be enabled')
  end

  def test_traps_errors
    get '/will_boom'
    assert_equal 500, last_response.status
    assert_equal 'We are sorry', last_response.body

    assert_equal(1, @error_collector.errors.size)
  end

  def test_ignores_notfound_errors_by_default
    get '/ignored_boom'
    assert_equal 404, last_response.status
    assert_match %r{Sinatra doesn&rsquo;t know this ditty\.}, last_response.body
    assert_equal(0, @error_collector.errors.size)
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
newrelic_rpm-3.6.5.130 test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb
newrelic_rpm-3.6.4.122 test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb
newrelic_rpm-3.6.4.113.beta test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb
newrelic_rpm-3.6.3.111 test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb
newrelic_rpm-3.6.3.106 test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb
newrelic_rpm-3.6.3.105.beta test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb
newrelic_rpm-3.6.3.104 test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb
newrelic_rpm-3.6.3.103.beta test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb
newrelic_rpm-3.6.2.96 test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb
newrelic_rpm-3.6.2.90.beta test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb
newrelic_rpm-3.6.1.88 test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb
newrelic_rpm-3.6.1.87 test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb
newrelic_rpm-3.6.1.86.beta test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb
newrelic_rpm-3.6.1.85.beta test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb