struct

Spectator::Matchers::TruthyMatcher

Inherits Spectator::Matchers::StandardMatcher / Spectator::Matchers::Matcher / Struct / Value / Object

Matcher that tests whether a value is truthy or falsey. Falsey means a value is considered false by an if-statement, which are false and nil in Crystal. Truthy is the opposite of falsey.

Additionally, different matchers can be created by using the #<, #<=, #>, #>=, #==, and #!= operators.

Constructors

new(truthy : Bool = true)

Creates the truthy matcher. The truthy argument should be true to match "truthy" values, and false to match "falsey" values.

Source

Instance methods

!=(value)

Creates a matcher that checks if a value is not equal to an expected value. The spec would look like:

expect(0).to be != 1
Source
<(value)

Creates a matcher that checks if a value is less than an expected value. The spec would look like:

expect(0).to be &lt; 1
Source
<=(value)

Creates a matcher that checks if a value is less than or equal to an expected value. The spec would look like:

expect(0).to be &lt;= 1
Source
==(value)

Creates a matcher that checks if a value is equal to an expected value. The spec would look like:

expect(0).to be == 0
Source
===(value)

Creates a matcher that checks if a value is semantically equal to an expected value. The spec would look like:

expect(&quot;foobar&quot;).to be === /foo/
Source
=~(value)

Creates a matcher that checks if a value matches the pattern of an expected value. The spec would look like:

expect(&quot;foobar&quot;).to be =~ /foo/
Source
>(value)

Creates a matcher that checks if a value is greater than an expected value. The spec would look like:

expect(2).to be &gt; 1
Source
>=(value)

Creates a matcher that checks if a value is greater than or equal to an expected value. The spec would look like:

expect(2).to be &gt;= 1
Source
description

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.

Source