Skip to content

Expectation::toBeTruthy ​

Member of Expectation

idl
Expectation.toBeTruthy, $
  /_expect_failure

Verifies that the expectation value is truthy. Unlike idl toBeTrue this does not require a scalar and does not raise an error when no value is set. A value is truthy if it is:

  • a non-empty string
  • a non-zero number
  • a valid pointer or object reference (lists, hashes, orderedhashes and dictionaries must also have at least one element)
  • a structure
  • an array

Anything else, including a missing value (!null), is falsy.

Examples ​

idl
(it.expects('text')).toBeTruthy
(it.expects(2)).toBeTruthy
(it.expects(list(1))).toBeTruthy
(it.expects(''))._not_.toBeTruthy

Keywords ​

_expect_failure {#kw-_expect_failure} ​

optionalinputtype=Boolean

If the test fails for some reason, set this to force passing because we expected failure. This keyword is for internal use only.

Licensed under MIT.