Don't automatically extend StubbedType

Mocked module includes StubbedType, which doesn't pass along functionality to mocks.
This commit is contained in:
Michael Miller 2022-07-04 16:43:37 -06:00
parent aa87d124e4
commit 22a37d38f9
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF
3 changed files with 7 additions and 11 deletions

View file

@ -3,6 +3,7 @@ require "./method_call"
require "./stub"
require "./stubbable"
require "./stubbed_name"
require "./stubbed_type"
require "./unexpected_message"
require "./value_stub"
@ -18,6 +19,7 @@ module Spectator
# New methods are not defines when a stub is added that doesn't have a matching method name.
abstract class Double
include Stubbable
extend StubbedType
Log = Spectator::Log.for(self)
@ -65,6 +67,10 @@ module Spectator
@calls = [] of MethodCall
private class_getter _spectator_stubs : Array(Stub) = [] of Stub
class_getter _spectator_calls : Array(MethodCall) = [] of MethodCall
# Creates the double.
#
# An initial set of *stubs* can be provided.

View file

@ -2,7 +2,6 @@ require "../dsl/reserved"
require "./arguments"
require "./method_call"
require "./stub"
require "./stubbed_type"
require "./typed_stub"
module Spectator
@ -384,14 +383,5 @@ module Spectator
end
end
end
# Automatically extend `StubbedType` when a type is made stubbable.
macro included
extend StubbedType
private class_getter _spectator_stubs : Array(::Spectator::Stub) = [] of ::Spectator::Stub
class_getter _spectator_calls : Array(::Spectator::MethodCall) = [] of ::Spectator::MethodCall
end
end
end

View file

@ -4,7 +4,7 @@ require "./stub"
module Spectator
# Defines stubbing functionality at the type level (classes and structs).
#
# This module is intended to be extended from when a type includes `Stubbable`.
# This module is intended to be extended when a type includes `Stubbable`.
module StubbedType
private abstract def _spectator_stubs : Array(Stub)