test/test_helper.rb in ghazel-newrelic_rpm-3.1.0.1 vs test/test_helper.rb in ghazel-newrelic_rpm-3.4.0.2

- old
+ new

@@ -12,33 +12,46 @@ # You can also run the tests in a mode without rails. Many tests # will be skipped. begin require 'config/environment' + # require File.join(File.dirname(__FILE__),'..','..','rpm_test_app','config','environment') begin require 'test_help' rescue LoadError # ignore load problems on test help - it doesn't exist in rails 3 end rescue LoadError - puts "Unable to load Rails for New Relic tests" - raise + # 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 + end 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' +require 'new_relic/fake_service' + class Test::Unit::TestCase include Mocha::API - # FIXME delete this trick when we stop supporting rails2.0.x + # we can delete this trick when we stop supporting rails2.0.x if ENV['BRANCH'] != 'rails20' # a hack because rails2.0.2 does not like double teardowns def teardown mocha_teardown end @@ -99,11 +112,11 @@ assert_not_equal first_metrics, last_metrics, "should have changed these metrics" end def compare_metrics(expected, actual) - actual.delete('GC/cumulative') # in case we are in REE + actual.delete_if {|a| a.include?('GC/cumulative') } # in case we are in REE assert_equal(expected.to_a.sort, actual.to_a.sort, "extra: #{(actual - expected).to_a.inspect}; missing: #{(expected - actual).to_a.inspect}") end module TransactionSampleTestHelper def make_sql_transaction(*sql) @@ -138,7 +151,7 @@ sampler.notice_pop_scope "lew" sampler.notice_pop_scope "Controller/sandwiches/index" sampler.notice_scope_empty sampler.samples[0] end - + module_function :run_sample_trace_on end