Sha256: 6725e7ff380d474a4c6aecb87322899b3ccef742086901e6cd9d6ff9e8908b9f
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
# frozen_string_literal: true RSpec.describe Yardcheck::MethodTracer do it 'traces method calls and returns for a namespace' do stub_const('Foo', Class.new) stub_const('Qux', Class.new) class Foo def self.singleton_method_example(baz) baz.upcase end def instance_method_example(baz) Foo.singleton_method_example(baz) end end # Foo class Qux def self.singleton_method_example(baz) baz.upcase end def instance_method_example(baz) Qux.singleton_method_example(baz) end end # Qux tracer = described_class.new(Foo) foo = Foo.new # Capture the activity for this object qux = Qux.new # Ignore this one str = 'Hello' tracer.trace do foo.instance_method_example(str) qux.instance_method_example(str) end expect(tracer.events).to eq([ Yardcheck::MethodCall::Return.process( scope: :class, selector: :singleton_method_example, namespace: Foo.singleton_class, params: { baz: 'Hello' }, return_value: 'HELLO', example_metadata: { location: RSpec.current_example.location, id: RSpec.current_example.id } ), Yardcheck::MethodCall::Return.process( scope: :instance, selector: :instance_method_example, namespace: Foo, params: { baz: 'Hello' }, return_value: 'HELLO', example_metadata: { location: RSpec.current_example.location, id: RSpec.current_example.id } ) ]) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yardcheck-0.0.3 | spec/unit/yardcheck/method_tracer_spec.rb |