abstract class Spectator::Mocks::Stub

Overview

Stand-in behavior for a method.

Included Modules

Direct Known Subclasses

Defined in:

spectator/mocks/stub.cr

Constructors

Instance Method Summary

Instance methods inherited from module Spectator::Mocks::StubModifiers

and_raise(exception : Exception)
and_raise(message : String | Nil = nil)
and_raise(exception_type : Exception.class, *args, **kwargs)
and_raise
, and_return(value) and_return, with(*args, **kwargs)
with(*args, **kwargs, &block : -> _)
with

Constructor Detail

def self.new(method_name : Symbol, arguments : AbstractArgumentsPattern | Nil = nil) #

Creates the stub.


[View source]

Instance Method Detail

def ===(call : Call) : Bool #

Checks if the stub can be used for a method call.


[View source]
def arguments : AbstractArgumentsPattern | Nil #

Arguments necessary to trigger the stub. If nil, any arguments will trigger the stub.


[View source]
abstract def call(args : Arguments, return_type : U.class = U, & : -> U) forall U #

Invokes the stub. args are the arguments passed to the method call. The return_type indicates the type expected to be returned by the stub. A block must be passed that invokes the original method or fallback behavior. The type returned by the block must match return_type.


[View source]
def method_name : Symbol #

Name of the method being applied to.


[View source]
def to_s(io : IO) : Nil #

Constructs the string representation of the stub.


[View source]