Sha256: 3b9fb4e08fd91cd010d37b9c1b3b642435880df5d1de1a4769e2439da618ba0e
Contents?: true
Size: 1.99 KB
Versions: 5
Compression:
Stored size: 1.99 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')) class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase def self.teardown # To remove mock server instances from ObjectSpace ObjectSpace.garbage_collect super end class MockOptions def fetch (*args) 1000 end end MOCK_OPTIONS = MockOptions.new def test_passenger class << self module ::PhusionPassenger end end NewRelic::Agent.reset_config e = NewRelic::LocalEnvironment.new assert_equal :passenger, e.discovered_dispatcher assert_equal :passenger, NewRelic::Agent.config[:dispatcher] with_config(:app_name => 'myapp') do e = NewRelic::LocalEnvironment.new assert_equal :passenger, e.discovered_dispatcher end ensure Object.send(:remove_const, :PhusionPassenger) end # LocalEnvironment won't talk to ObjectSpace on JRuby, and these tests are # around that interaction, so we don't run them on JRuby. unless defined?(JRuby) def test_mongrel_only_checks_once define_mongrel # One call from LocalEnvironment's initialize, second from first #mongrel call. # All the rest shouldn't call into ObjectSpace ObjectSpace.expects(:each_object).with(::Mongrel::HttpServer).twice e = NewRelic::LocalEnvironment.new 5.times { e.mongrel } assert_nil e.mongrel ensure Object.send(:remove_const, :Mongrel) end def test_check_for_mongrel_allows_one_more_check define_mongrel ObjectSpace.expects(:each_object).with(::Mongrel::HttpServer).at_least(2) e = NewRelic::LocalEnvironment.new e.send(:check_for_mongrel) ensure Object.send(:remove_const, :Mongrel) end end def define_mongrel class << self module ::Mongrel class HttpServer end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems