diff --git a/spec/lib/container_registry/gitlab_api_client_spec.rb b/spec/lib/container_registry/gitlab_api_client_spec.rb
index 8cb1700e6440576aa2c42cfeb750533d3c8b3a62..f19bedbda0e36b041b41f8a77950299b0fe01c6c 100644
--- a/spec/lib/container_registry/gitlab_api_client_spec.rb
+++ b/spec/lib/container_registry/gitlab_api_client_spec.rb
@@ -421,7 +421,9 @@
 
       before do
         expect(Auth::ContainerRegistryAuthenticationService).to receive(:pull_nested_repositories_access_token).with(path.downcase).and_return(token)
-        stub_repository_details(path.downcase, sizing: :self_with_descendants, status_code: 200, respond_with: response)
+        expect_next_instance_of(described_class) do |client|
+          expect(client).to receive(:repository_details).with(path.downcase, sizing: :self_with_descendants).and_return(response.with_indifferent_access).once
+        end
       end
 
       it { is_expected.to eq(555) }