Class: Riot::ExistsMacro
- Inherits:
-
AssertionMacro
- Object
- AssertionMacro
- Riot::ExistsMacro
- Defined in:
- lib/riot/assertion_macros/exists.rb
Overview
Asserts that the result of the test is a non-nil value. This is useful in the case where you don’t want to translate the result of the test into a boolean value
asserts("test") { "foo" }.exists
should("test") { 123 }.exists
asserts("test") { "" }.exists
asserts("test") { nil }.exists # This would fail
Instance Method Summary collapse
Methods inherited from AssertionMacro
default, #error, expects_exception!, #expects_exception?, #fail, #pass, register
Instance Method Details
#evaluate(actual) ⇒ Object
11 12 13 |
# File 'lib/riot/assertion_macros/exists.rb', line 11 def evaluate(actual) !actual.nil? ? pass("is not nil") : fail("expected a non-nil value") end |