Class: Riot::AnyMacro Deprecated

Inherits:
AssertionMacro show all
Defined in:
lib/riot/assertion_macros/any.rb

Overview

Deprecated.

Please use asserts.empty or denies.empty instead.

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

#file, #line

Instance Method Summary collapse

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.

Parameters:

Returns:



23
24
25
26
# File 'lib/riot/assertion_macros/any.rb', line 23

def devaluate(actual)
  warn "any is deprecated; please use asserts.empty or denies.empty instead"
  any?(actual) ? fail(expected_message(actual).not_to_have_items) : pass("has items")
end

#evaluate(actual) ⇒ Array

Supports positive assertion testing. This is where magic happens.

Parameters:

Returns:



17
18
19
20
# File 'lib/riot/assertion_macros/any.rb', line 17

def evaluate(actual)
  warn "any is deprecated; please use asserts.empty or denies.empty instead"
  any?(actual) ? pass("has items") : fail(expected_message(actual).to_have_items)
end