Restructure stub modifiers

This commit is contained in:
Michael Miller 2022-04-02 10:50:27 -06:00
parent 318e4f3707
commit 519836147e
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF
4 changed files with 16 additions and 4 deletions

View file

@ -7,9 +7,5 @@ module Spectator
# Invokes the stubbed implementation.
def call(_call : MethodCall) : Nil
end
def and_return(value)
ValueStub.new(method, value, constraint)
end
end
end

View file

@ -1,10 +1,13 @@
require "./abstract_arguments"
require "./arguments"
require "./method_call"
require "./stub_modifiers"
module Spectator
# Untyped response to a method call (message).
abstract class Stub
include StubModifiers
# Name of the method this stub is for.
getter method : Symbol

View file

@ -0,0 +1,5 @@
module Spectator
# Mixin intended for `Stub` to return new, modified stubs.
module StubModifiers
end
end

View file

@ -1,5 +1,6 @@
require "../location"
require "./arguments"
require "./stub_modifiers"
require "./typed_stub"
module Spectator
@ -15,4 +16,11 @@ module Spectator
super(method, constraint, location)
end
end
module StubModifiers
# Returns a new stub that returns a static value.
def and_return(value)
ValueStub.new(method, value, constraint, location)
end
end
end