abstract class Spectator::NullDouble
Overview
Stands in for an object for testing that a SUT calls expected methods.
Handles all messages (method calls), but only responds to those configured.
Methods called that were not configured will return self.
Doubles should be defined with the #define
macro.
Use #_spectator_define_stub
to override behavior of a method in the double.
Only methods defined in the double's type can have stubs.
New methods are not defines when a stub is added that doesn't have a matching method name.
Defined in:
spectator/mocks/null_double.crMacro Summary
-
method_missing(call)
Handles all undefined messages.
Instance methods inherited from class Spectator::Double
!=(other)
!=,
!~(other)
!~,
==(other : self)==(other : JSON::Any)
==(other) ==, ===(other : JSON::Any)
===(other) ===, =~(other) =~, _spectator_calls : Array(Spectator::MethodCall) _spectator_calls, _spectator_clear_calls : Nil _spectator_clear_calls, _spectator_record_call(call : MethodCall) : Nil _spectator_record_call, _spectator_stub_for_method?(method : Symbol) : Bool _spectator_stub_for_method?, colorize(r : UInt8, g : UInt8, b : UInt8)
colorize(fore : UInt8)
colorize(fore : Symbol)
colorize(fore : Color)
colorize : Colorize::Object colorize, crystal_type_id : Int32 crystal_type_id, dup dup, hash(hasher)
hash hash, in?(collection : Object) : Bool
in?(*values : Object) : Bool in?, inspect(io : IO) : Nil
inspect : String inspect, itself itself, not_nil!(message)
not_nil! not_nil!, object_id : UInt64 object_id, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil
pretty_print(pp) : Nil pretty_print, same?(other : Reference) : Bool
same?(other : Nil)
same?(other) : Bool same?, 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, tap(&) tap, to_json(io : IO) : Nil
to_json : String to_json, to_pretty_json(indent : String = " ") : String
to_pretty_json(io : IO, indent : String = " ") : Nil to_pretty_json, to_s(io : IO) : Nil
to_s : String to_s, try(&) try, unsafe_as(type : T.class) forall T unsafe_as
Constructor methods inherited from class Spectator::Double
new(stubs : Array(Spectator::Stub) = [] of ::Spectator::Stub)new(**value_methods) new, unsafe_construct(address : Pointer, *args, **opts) : self unsafe_construct
Class methods inherited from class Spectator::Double
_spectator_calls : Array(MethodCall)
_spectator_calls,
from_json(string_or_io, root : String)from_json(string_or_io) from_json, pre_initialize(address : Pointer) pre_initialize
Macros inherited from class Spectator::Double
define(type_name, name = nil, **value_methods, &block)
define,
method_missing(call)
method_missing
Instance methods inherited from module Spectator::Stubbable
_spectator_abstract_stub_fallback(call : MethodCall, type)_spectator_abstract_stub_fallback(call : MethodCall) _spectator_abstract_stub_fallback, _spectator_calls _spectator_calls, _spectator_clear_calls : Nil _spectator_clear_calls, _spectator_clear_stubs : Nil _spectator_clear_stubs, _spectator_define_stub(stub : Stub) : Nil _spectator_define_stub, _spectator_find_stub(call : MethodCall) : Stub | Nil _spectator_find_stub, _spectator_record_call(call : MethodCall) : Nil _spectator_record_call, _spectator_remove_stub(stub : Stub) : Nil _spectator_remove_stub, _spectator_reset : Nil _spectator_reset, _spectator_stub_fallback(call : MethodCall, type, &)
_spectator_stub_fallback(call : MethodCall, &) _spectator_stub_fallback, _spectator_stub_for_method?(method : Symbol) : Bool _spectator_stub_for_method?, _spectator_stubbed_name : String _spectator_stubbed_name
Macros inherited from module Spectator::Stubbable
stub(method)
stub
Instance methods inherited from class Object
should(matcher : Spectator::Matchers::TypeMatcher(U), message = nil, *, _file = __FILE__, _line = __LINE__) forall Ushould(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
Macro Detail
macro method_missing(call)
#
Handles all undefined messages.
Returns stubbed values if available, otherwise delegates to #_spectator_abstract_stub_fallback
.