blob: c5a93c6e04876e3e4a2597e95fcf2e72179ff503 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe 'TracePoint#defined_class' do
it 'returns class or module of the method being called' do
last_class_name = nil
TracePoint.new(:call) do |tp|
last_class_name = tp.defined_class
end.enable do
TracePointSpec::B.new.foo
last_class_name.should equal(TracePointSpec::B)
TracePointSpec::B.new.bar
last_class_name.should equal(TracePointSpec::A)
c = TracePointSpec::C.new
last_class_name.should equal(TracePointSpec::C)
c.foo
last_class_name.should equal(TracePointSpec::B)
c.bar
last_class_name.should equal(TracePointSpec::A)
end
end
end
|