Spec::ObjectExtensions - Crystal 1.20.1

# module Spec::ObjectExtensions

##
Direct including types

- Object

##
Defined in:

spec/expectations.cr

##
Instance Method Summary

- #should(expectation : BeAExpectation(T), failure_message : String | Nil = nil, *, file = __FILE__, line = __LINE__) : T forall T

  Validates an expectation and fails the example if it does not match.

- #should(expectation, failure_message : String | Nil = nil, *, file = __FILE__, line = __LINE__)

  Validates an expectation and fails the example if it does not match.

- #should_not(expectation : BeAExpectation(T), failure_message : String | Nil = nil, *, file = __FILE__, line = __LINE__) forall T

  Validates an expectation and fails the example if it matches.

- #should_not(expectation : BeNilExpectation, failure_message : String | Nil = nil, *, file = __FILE__, line = __LINE__)

  Validates an expectation and fails the example if it matches.

- #should_not(expectation, failure_message : String | Nil = nil, *, file = __FILE__, line = __LINE__)

  Validates an expectation and fails the example if it matches.

##
Instance Method Detail

def should(expectation : BeAExpectation(T), failure_message : String | Nil = nil, *, file = __FILE__, line = __LINE__) : T forall T #

Validates an expectation and fails the example if it does not match.

This overload returns a value whose type is restricted to the expected type. For example:

    x = 1 || 'a'
    typeof(x) # => Int32 | Char
    x = x.should be_a(Int32)
    typeof(x) # => Int32

See `Spec::Expectations` for available expectations.

def should(expectation, failure_message : String | Nil = nil, *, file = __FILE__, line = __LINE__) #

Validates an expectation and fails the example if it does not match.

See `Spec::Expectations` for available expectations.

def should_not(expectation : BeAExpectation(T), failure_message : String | Nil = nil, *, file = __FILE__, line = __LINE__) forall T #

Validates an expectation and fails the example if it matches.

This overload returns a value whose type is restricted to exclude the given type in `should_not be_a`. For example:

    x = 1 || 'a'
    typeof(x) # => Int32 | Char
    x = x.should_not be_a(Char)
    typeof(x) # => Int32

See `Spec::Expectations` for available expectations.

def should_not(expectation : BeNilExpectation, failure_message : String | Nil = nil, *, file = __FILE__, line = __LINE__) #

Validates an expectation and fails the example if it matches.

This overload returns a value whose type is restricted to be not `Nil`. For example:

    x = 1 || nil
    typeof(x) # => Int32 | Nil
    x = x.should_not be_nil
    typeof(x) # => Int32

See `Spec::Expectations` for available expectations.

def should_not(expectation, failure_message : String | Nil = nil, *, file = __FILE__, line = __LINE__) #

Validates an expectation and fails the example if it matches.

See `Spec::Expectations` for available expectations.