mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Restructure stub modifiers
This commit is contained in:
parent
318e4f3707
commit
519836147e
4 changed files with 16 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
5
src/spectator/mocks/stub_modifiers.cr
Normal file
5
src/spectator/mocks/stub_modifiers.cr
Normal file
|
@ -0,0 +1,5 @@
|
|||
module Spectator
|
||||
# Mixin intended for `Stub` to return new, modified stubs.
|
||||
module StubModifiers
|
||||
end
|
||||
end
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue