Sha256: 58d3f5d6b93ac5a2989565daaba2e9080246a6a454e7ffc5167717df0fa669f3
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 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.process( scope: :class, selector: :singleton_method_example, namespace: Foo.singleton_class, params: { baz: 'Hello' }, return_value: 'HELLO', example_location: RSpec.current_example.location, error_raised: false ), Yardcheck::MethodCall.process( scope: :instance, selector: :instance_method_example, namespace: Foo, params: { baz: 'Hello' }, return_value: 'HELLO', example_location: RSpec.current_example.location, error_raised: false ) ]) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yardcheck-0.0.1 | spec/unit/yardcheck/method_tracer_spec.rb |