class Mocks::ArgumentsPattern(Positional, KeywordArguments)

Overview

Arguments matched against to determine if a stub should be used or a call had expected arguments.

The Positional type parameter must be a Tuple. The KeywordArguments type parameter must be a NamedTuple.

Defined in:

mocks/arguments_pattern.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(positional : Positional, named : KeywordArguments) #

Creates a pattern to match against arguments passed to a method.


[View source]

Class Method Detail

def self.any : AbstractArgumentsPattern | Nil #

Returns a value that matches against any and all arguments.


[View source]
def self.build(*args, **named) : AbstractArgumentsPattern #

Creates a pattern to match against arguments written as a normal parameter list.


[View source]
def self.none : AbstractArgumentsPattern #

Creates an empty set of arguments to match against. Matching against this indicates no arguments were passed.


[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def ===(arguments : Arguments(Args, Splat, DoubleSplat)) : Bool forall Args, Splat, DoubleSplat #

Checks if arguments passed to a method match those specified by this pattern.


[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def named : KeywordArguments #

Keyword arguments.


[View source]
def positional : Positional #

Positional arguments.


[View source]
def to_args : Arguments #

Returns the arguments as-if they were passed to a method.


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

Generates the string representation of the argument pattern.


[View source]