W3cubDocs

/Crystal

module Spec::ObjectExtensions

Direct including types

Defined in:

spec/expectations.cr

Instance Method Summary

Instance Method Detail

def should(expectation : BeAExpectation(T), file = __FILE__, line = __LINE__) : T forall TSource

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::Expecations for available expectations.

def should(expectation, file = __FILE__, line = __LINE__)Source

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

See Spec::Expecations for available expectations.

def should_not(expectation : BeAExpectation(T), file = __FILE__, line = __LINE__) forall TSource

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::Expecations for available expectations.

def should_not(expectation : BeNilExpectation, file = __FILE__, line = __LINE__)Source

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::Expecations for available expectations.

def should_not(expectation, file = __FILE__, line = __LINE__)Source

Validates an expectation and fails the example if it matches.

See Spec::Expecations for available expectations.

© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/Spec/ObjectExtensions.html