struct Spectator::Matchers::CollectionMatcher(ExpectedType)

Overview

Matcher for checking that a value is in a collection of other values.

Defined in:

spectator/matchers/collection_matcher.cr

Constructors

Instance Method Summary

Constructor methods inherited from struct Spectator::Matchers::ValueMatcher(ExpectedType)

new(expected : Spectator::Value(ExpectedType)) new

Instance methods inherited from struct Spectator::Matchers::StandardMatcher

match(actual : Expression(T)) : MatchData forall T match, negated_match(actual : Expression(T)) : MatchData forall T negated_match

Instance methods inherited from struct Spectator::Matchers::Matcher

===(actual : Expression(T)) : Bool
===(other) : Bool
===
, description : String description, initialize initialize, match(actual : Expression(T)) : MatchData forall T match, negated_match(actual : Expression(T)) : MatchData forall T negated_match

Constructor methods inherited from struct Spectator::Matchers::Matcher

new new

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(expected : Spectator::Value(ExpectedType)) #

Creates the value matcher. The expected value is stored for later use.


[View source]

Instance Method Detail

def description : String #

Short text about the matcher's purpose. This explains what condition satisfies the matcher. The description is used when the one-liner syntax is used.


[View source]
def of(center) #

Creates a new range matcher with bounds based off of center.

This method expects that the original matcher was created with a "difference" value. That is:

CollectionMatcher.new(diff).of(center)

This implies that the #match method would not work on the original matcher.

The new range will be centered at center and have upper and lower bounds equal to center plus and minus diff. The range will be inclusive.


[View source]