Use absolute path for inject_mock

This is necessary to override the original type instead of creating a new one within the spec.
This commit is contained in:
Michael Miller 2022-07-13 11:29:19 -06:00
parent da3fbc9607
commit ac3b322900
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF
2 changed files with 2 additions and 2 deletions

View file

@ -420,7 +420,7 @@ module Spectator::DSL
# This isn't required, but new_mock() should still find this type.
::Spectator::DSL::Mocks::TYPES << {type.id.symbolize, @type.name(generic_args: false).symbolize, resolved.name.symbolize} %}
::Spectator::Mock.inject({{base}}, {{type.id}}, {{**value_methods}}) {{block}}
::Spectator::Mock.inject({{base}}, ::{{resolved.name}}, {{**value_methods}}) {{block}}
end
# Targets a stubbable object (such as a mock or double) for operations.

View file

@ -115,7 +115,7 @@ module Spectator
macro inject(base, type_name, name = nil, **value_methods, &block)
{% begin %}
{% if name %}@[::Spectator::StubbedName({{name}})]{% end %}
{{base.id}} {{type_name.id}}
{{base.id}} ::{{type_name.id}}
include ::Spectator::Mocked
extend ::Spectator::StubbedType