diff options
Diffstat (limited to 'spec/ruby/core/tracepoint/defined_class_spec.rb')
| -rw-r--r-- | spec/ruby/core/tracepoint/defined_class_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/ruby/core/tracepoint/defined_class_spec.rb b/spec/ruby/core/tracepoint/defined_class_spec.rb new file mode 100644 index 0000000000..53c86a8210 --- /dev/null +++ b/spec/ruby/core/tracepoint/defined_class_spec.rb @@ -0,0 +1,27 @@ +require_relative '../../spec_helper' +require_relative 'fixtures/classes' + +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| + next unless TracePointSpec.target_thread? + 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 |
