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.
|
# Invokes the stubbed implementation.
|
||||||
def call(_call : MethodCall) : Nil
|
def call(_call : MethodCall) : Nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def and_return(value)
|
|
||||||
ValueStub.new(method, value, constraint)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
require "./abstract_arguments"
|
require "./abstract_arguments"
|
||||||
require "./arguments"
|
require "./arguments"
|
||||||
require "./method_call"
|
require "./method_call"
|
||||||
|
require "./stub_modifiers"
|
||||||
|
|
||||||
module Spectator
|
module Spectator
|
||||||
# Untyped response to a method call (message).
|
# Untyped response to a method call (message).
|
||||||
abstract class Stub
|
abstract class Stub
|
||||||
|
include StubModifiers
|
||||||
|
|
||||||
# Name of the method this stub is for.
|
# Name of the method this stub is for.
|
||||||
getter method : Symbol
|
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 "../location"
|
||||||
require "./arguments"
|
require "./arguments"
|
||||||
|
require "./stub_modifiers"
|
||||||
require "./typed_stub"
|
require "./typed_stub"
|
||||||
|
|
||||||
module Spectator
|
module Spectator
|
||||||
|
@ -15,4 +16,11 @@ module Spectator
|
||||||
super(method, constraint, location)
|
super(method, constraint, location)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue