class

Spectator::Block(T)

Inherits Spectator::Expression / Spectator::AbstractExpression / Reference / Object

Represents a block from a test. This is typically captured by an expect macro. It consists of a label and parameter-less block. The label should be a string recognizable by the user, or nil if one isn't available.

Constructors

new(block : -> T, label : Label = nil)

Creates the block expression from a proc. The proc will be called to evaluate the value of the expression. The label is usually the Crystal code for the proc. It can be nil if it isn't available.

Source
new(label : Label = nil, &block : -> T)

Creates the block expression by capturing a block as a proc. The block will be called to evaluate the value of the expression. The label is usually the Crystal code for the block. It can be nil if it isn't available.

Source

Instance methods

value

Evaluates the block and returns the value from it. This method does not cache the resulting value like #value does. Successive calls to this method may return different values.

Source