abstract class SpectatorContext

Overview

Base class that all test cases run in. This type is used to store all test case contexts as a single type. The instance must be downcast to the correct type before calling a context method. This type is intentionally outside the Spectator module. The reason for this is to prevent name collision when using the DSL to define a spec.

Direct Known Subclasses

Defined in:

spectator/context.cr

Instance Method Summary

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

Instance Method Detail

def eval(&) #

Evaluates the contents of a block within the scope of the context.


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

Produces a dummy string to represent the context as a string. This prevents the default behavior, which normally stringifies instance variables. Due to the sheer amount of types Spectator can create and that the Crystal compiler instantiates a #to_s and/or #inspect for each of those types, an explosion in method instances can be created. The compile time is drastically reduced by using a dummy string instead.


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

Produces a dummy string to represent the context as a string. This prevents the default behavior, which normally stringifies instance variables. Due to the sheer amount of types Spectator can create and that the Crystal compiler instantiates a #to_s and/or #inspect for each of those types, an explosion in method instances can be created. The compile time is drastically reduced by using a dummy string instead.


[View source]