This module defines a number of methods to create expectations, which are automatically included into the top level namespace.
Expectations are used by Spec::ObjectExtensions#should
and Spec::ObjectExtensions#should_not
.
Creates an Expectation
that passes if actual and value are identical (.same?
).
Returns a factory to create a comparison Expectation
that:
Creates an Expectation
that passes if actual is within delta of expected.
Creates an Expectation
that passes if actual is empty (.empty?
).
Creates an Expectation
that passes if actual is false (== false
).
Creates an Expectation
that passes if actual is falsy (nil
or false
).
Creates an Expectation
that passes if actual is nil (== nil
).
Creates an Expectation
that passes if actual is true (== true
).
Creates an Expectation
that passes if actual is truthy (neither nil
nor false
).
Creates an Expectation
that passes if actual includes expected (.includes?
).
Creates an Expectation
that passes if actual ends with expected (.ends_with?
).
Creates an Expectation
that passes if actual equals value (==
).
Runs the block and passes if it raises an exception of type klass and the error message matches.
Creates an Expectation
that passes if actual matches value (=~
).
Creates an Expectation
that passes if actual starts with expected (.starts_with?
).
Creates an Expectation
that passes if actual is of type type (is_a?
).
Creates an Expectation
that passes if actual and value are identical (.same?
).
Returns a factory to create a comparison Expectation
that:
be < value
be <= value
be > value
be >= value
Creates an Expectation
that passes if actual is within delta of expected.
Creates an Expectation
that passes if actual is empty (.empty?
).
Creates an Expectation
that passes if actual is false (== false
).
Creates an Expectation
that passes if actual is falsy (nil
or false
).
Creates an Expectation
that passes if actual is nil (== nil
).
Creates an Expectation
that passes if actual is true (== true
).
Creates an Expectation
that passes if actual is truthy (neither nil
nor false
).
Creates an Expectation
that passes if actual includes expected (.includes?
). Works on collections and String
.
Creates an Expectation
that passes if actual ends with expected (.ends_with?
). Works on String
.
Creates an Expectation
that passes if actual equals value (==
).
Runs the block and passes if it raises an exception of type klass and the error message matches.
If message is a string, it matches if the exception's error message contains that string. If message is a regular expression, it is used to match the error message.
It returns the rescued exception.
Creates an Expectation
that passes if actual matches value (=~
).
Creates an Expectation
that passes if actual starts with expected (.starts_with?
). Works on String
.
Creates an Expectation
that passes if actual is of type type (is_a?
).
© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/Spec/Expectations.html