Skip to content

Commit

Permalink
Use stub_const instead of stubbing any instance
Browse files Browse the repository at this point in the history
In the GarbageCollectionProfiler spec refactor the code to stub the
constant directly rather than mock a private method on the
GarbageCollectionProfiler class.

This makes it more resilient to change and mocks the to be mocked object
directly.
  • Loading branch information
tombruijn committed Aug 5, 2022
1 parent 0ad88b3 commit 66821df
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions spec/lib/appsignal/garbage_collection_profiler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
let(:profiler) { described_class.new }

before do
allow_any_instance_of(described_class)
.to receive(:internal_profiler)
.and_return(internal_profiler)
stub_const("GC::Profiler", internal_profiler)
end

context "on initialization" do
Expand Down

0 comments on commit 66821df

Please sign in to comment.