class Spectator::ProcStub(T)

Overview

Stub that responds with a value returned by calling a proc.

Defined in:

spectator/mocks/proc_stub.cr

Constructors

Instance Method Summary

Instance methods inherited from class Spectator::TypedStub(T)

call(call : MethodCall) : T call, to_s(io : IO) : Nil to_s

Constructor methods inherited from class Spectator::TypedStub(T)

new(method : Symbol, constraint : AbstractArguments | Nil = nil, location : Location | Nil = nil) new

Instance methods inherited from class Spectator::Stub

===(call : MethodCall) ===, constraint : AbstractArguments | Nil constraint, location : Location | Nil location, message(io : IO) : Nil
message
message
, method : Symbol method, to_s(io : IO) : Nil to_s

Constructor methods inherited from class Spectator::Stub

new(method : Symbol, constraint : AbstractArguments | Nil = nil, location : Location | Nil = nil) new

Instance methods inherited from module Spectator::StubModifiers

and_raise(exception_class : Exception.class, message)
and_raise(exception : Exception)
and_raise(message : String | Nil = nil)
and_raise(exception_class : Exception.class)
and_raise
, and_return(value)
and_return(value, *values)
and_return
, with(constraint : AbstractArguments | Nil)
with(*args, **kwargs)
with(*args, **kwargs, &block : AbstractArguments -> T) forall T
with
, with_constraint(constraint : AbstractArguments | Nil) with_constraint

Instance methods inherited from class Object

should(matcher : Spectator::Matchers::TypeMatcher(U), message = nil, *, _file = __FILE__, _line = __LINE__) forall U
should(matcher, message = nil, *, _file = __FILE__, _line = __LINE__)
should
, should_eventually(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_eventually, should_never(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_never, should_not(matcher : Spectator::Matchers::TypeMatcher(U), message = nil, *, _file = __FILE__, _line = __LINE__) forall U
should_not(matcher : Spectator::Matchers::NilMatcher, message = nil, *, _file = __FILE__, _line = __LINE__)
should_not(matcher, message = nil, *, _file = __FILE__, _line = __LINE__)
should_not

Constructor Detail

def self.new(method : Symbol, proc : Proc(AbstractArguments, T), constraint : AbstractArguments | Nil = nil, location : Location | Nil = nil) #

Creates the stub.


[View source]
def self.new(method : Symbol, constraint : AbstractArguments | Nil = nil, location : Location | Nil = nil, &block : Proc(AbstractArguments, T)) #

Creates the stub.


[View source]

Instance Method Detail

def call(call : MethodCall) : T #

Invokes the stubbed implementation.


[View source]
def with_constraint(constraint : AbstractArguments | Nil) #

Returns a new stub with constrained arguments.


[View source]