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

- (Array) devaluate(actual)

Supports negative/converse assertion testing. This is also where magic happens.



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

- (Array) evaluate(actual)

Supports positive assertion testing. This is where magic happens.



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