test/test_helper.rb in newrelic_rpm-3.5.1.14 vs test/test_helper.rb in newrelic_rpm-3.5.2.17
- old
+ new
@@ -1,15 +1,17 @@
module NewRelic; TEST = true; end unless defined? NewRelic::TEST
ENV['RAILS_ENV'] = 'test'
NEWRELIC_PLUGIN_DIR = File.expand_path(File.join(File.dirname(__FILE__),".."))
$LOAD_PATH << '.'
$LOAD_PATH << '../../..'
+$LOAD_PATH << File.join(NEWRELIC_PLUGIN_DIR,"lib")
$LOAD_PATH << File.join(NEWRELIC_PLUGIN_DIR,"test")
$LOAD_PATH << File.join(NEWRELIC_PLUGIN_DIR,"ui/helpers")
$LOAD_PATH.uniq!
require 'rubygems'
+require 'rake'
# We can speed things up in tests that don't need to load rails.
# You can also run the tests in a mode without rails. Many tests
# will be skipped.
begin
@@ -18,32 +20,39 @@
begin
require 'test_help'
rescue LoadError
# ignore load problems on test help - it doesn't exist in rails 3
end
+ require 'newrelic_rpm'
+rescue LoadError => e
+ puts "Running tests in standalone mode."
+ require 'bundler'
+ Bundler.require
+ require 'rails/all'
+ require 'newrelic_rpm'
-rescue LoadError
- # To run the tests against a standalone agent build, you need to
- # add a rails app to the load path. It can be 2.* to 3.*. It should
- # referenc newrelic_rpm in the Gemfile with a :path option pointing
- # to this work directory.
- guess = File.expand_path("../../../rpm", __FILE__)
- if $LOAD_PATH.include? guess
- puts "Unable to load Rails for New Relic tests. See note in test_helper.rb"
- raise
- else
- $LOAD_PATH << guess
- retry
+ # Bootstrap a basic rails environment for the agent to run in.
+ class MyApp < Rails::Application
+ config.active_support.deprecation = :log
+ config.secret_token = "49837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk"
+ config.after_initialize do
+ NewRelic::Agent.manual_start
+ end
end
+ MyApp.initialize!
+
end
-require 'newrelic_rpm'
require 'test/unit'
require 'shoulda'
require 'test_contexts'
require 'mocha'
-require 'mocha/integration/test_unit'
-require 'mocha/integration/test_unit/assertion_counter'
+
+begin # 1.8.6
+ require 'mocha/integration/test_unit'
+ require 'mocha/integration/test_unit/assertion_counter'
+rescue LoadError
+end
require 'new_relic/fake_service'
class Test::Unit::TestCase
include Mocha::API