Class: Riot::AnyMacro
- Inherits:
-
AssertionMacro
- Object
- AssertionMacro
- Riot::AnyMacro
- Defined in:
- lib/riot/assertion_macros/any.rb
Overview
In the positive case, asserts the result has items using the any?
operator.
asserts("an array") { [1] }.any
asserts("a hash") { {:name => 'washington'} }.any
In the negative case, asserts the result has no items using the any?
operator.
denies("an empty array") { [] }.any
denies("an empty hash") { {} }.any
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/any.rb', line 20 def devaluate(actual) any?(actual) ? fail((actual).not_to_have_items) : pass("has items") end |
#evaluate(actual) ⇒ Array
Supports positive assertion testing. This is where magic happens.
15 16 17 |
# File 'lib/riot/assertion_macros/any.rb', line 15 def evaluate(actual) any?(actual) ? pass("has items") : fail((actual).to_have_items) end |