Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
namespace method exists method so it does not conflict with mocha
Browse files Browse the repository at this point in the history
  • Loading branch information
jaggederest committed May 9, 2011
1 parent de4d075 commit 3246e82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/new_relic/agent/method_tracer.rb
Expand Up @@ -314,7 +314,7 @@ def default_metric_name_code(method_name)
"Custom/#{self.name}/#{method_name.to_s}"
end

def method_exists?(method_name)
def newrelic_method_exists?(method_name)
exists = method_defined?(method_name) || private_method_defined?(method_name)
NewRelic::Control.instance.log.warn("Did not trace #{self.name}##{method_name} because that method does not exist") unless exists
exists
Expand Down Expand Up @@ -378,7 +378,7 @@ def code_to_eval(method_name, metric_name_code, options)
include AddMethodTracer

def add_method_tracer(method_name, metric_name_code=nil, options = {})
return unless method_exists?(method_name)
return unless newrelic_method_exists?(method_name)
metric_name_code ||= default_metric_name_code(method_name)
return if traced_method_exists?(method_name, metric_name_code)

Expand Down
Expand Up @@ -38,19 +38,19 @@ def test_default_metric_name_code
assert_equal "Custom/#{name}/test_method", default_metric_name_code('test_method')
end

def test_method_exists_positive
def test_newrelic_method_exists_positive
self.expects(:method_defined?).returns(true)
assert method_exists?('test_method')
assert newrelic_method_exists?('test_method')
end

def test_method_exists_negative
def test_newrelic_method_exists_negative
self.expects(:method_defined?).returns(false)
self.expects(:private_method_defined?).returns(false)

fake_log = mock('log')
NewRelic::Control.instance.expects(:log).returns(fake_log)
fake_log.expects(:warn).with("Did not trace #{name}#test_method because that method does not exist")
assert !method_exists?('test_method')
assert !newrelic_method_exists?('test_method')
end

def test_set_deduct_call_time_based_on_metric_positive
Expand Down

0 comments on commit 3246e82

Please sign in to comment.