Class: Riot::NilMacro
- Inherits:
-
AssertionMacro
- Object
- AssertionMacro
- Riot::NilMacro
- Defined in:
- lib/riot/assertion_macros/nil.rb
Overview
Asserts that the result of the test is nil
asserts("test") { nil }.nil
should("test") { nil }.nil
You could test that the result is not nil, but it would make more sense to use the exists
macro:
denies("test") { "foo" }.nil
asserts("test") { "foo" }.exists
Instance Attribute Summary
Attributes inherited from AssertionMacro
Instance Method Summary collapse
-
#devaluate(actual) ⇒ Array
Supports negative/converse assertion testing.
-
#evaluate(actual) ⇒ Array
Supports positive assertion testing.
Methods inherited from AssertionMacro
#error, #expected_message, expects_exception!, #expects_exception?, #fail, #new_message, #pass, register, #should_have_message
Instance Method Details
#devaluate(actual) ⇒ Array
Supports negative/converse assertion testing. This is also where magic happens.
20 21 22 |
# File 'lib/riot/assertion_macros/nil.rb', line 20 def devaluate(actual) actual.nil? ? fail(.is_nil.not('non-nil')) : pass("is nil") end |
#evaluate(actual) ⇒ Array
Supports positive assertion testing. This is where magic happens.
15 16 17 |
# File 'lib/riot/assertion_macros/nil.rb', line 15 def evaluate(actual) actual.nil? ? pass("is nil") : fail(.nil.not(actual)) end |