Class: Riot::EquivalentToMacro
- Inherits:
-
AssertionMacro
- Object
- AssertionMacro
- Riot::EquivalentToMacro
- Defined in:
- lib/riot/assertion_macros/equivalent_to.rb
Overview
Asserts that the result of the test is equivalent to the expected value. Using the === operator.
asserts("test") { "foo" }.equivalent_to(String)
should("test") { "foo" }.equivalent_to("foo")
asserts("test") { "foo" }.equivalent_to { "foo" }
Underneath the hood, this assertion macro says:
expected === actual
Instance Attribute Summary
Attributes inherited from AssertionMacro
Instance Method Summary collapse
Methods inherited from AssertionMacro
default, #error, #expected_message, expects_exception!, #expects_exception?, #fail, #new_message, #pass, register, #should_have_message
Instance Method Details
#evaluate(actual, expected) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/riot/assertion_macros/equivalent_to.rb', line 14 def evaluate(actual, expected) if expected === actual pass .is_equivalent_to(expected) else fail (actual).to_be_equivalent_to(expected) end end |