Skip to content

Commit

Permalink
di tests
Browse files Browse the repository at this point in the history
  • Loading branch information
p committed Jul 15, 2024
1 parent f994396 commit b571e13
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion spec/datadog/di/hook_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,30 @@ def hook_test_method_with_kwarg(kwarg:)
RSpec.describe Datadog::DI::HookManager do
let(:observed_calls) { [] }

let(:definition_trace_point) do
double('definition trace point').tap do |tp|
expect(tp).to receive(:enable)
end
end

let(:manager) do
described_class.new
RSpec::Mocks.with_temporary_scope do
# TODO consider splitting HookManager into a class that hooks and
# a class that maintains registry of probes
expect(TracePoint).to receive(:new).with(:end).and_return(definition_trace_point)

described_class.new
end.tap do |manager|
# Since we are skipping definition trace point setup, we also
# need to skip its teardown otherwise .close would try to disable
# the double that is no longer in scope.
allow(manager).to receive(:close).and_return(nil)
end
end

after do
manager.clear_hooks
#manager.close
end

let(:call_keys) do
Expand Down

0 comments on commit b571e13

Please sign in to comment.