Class: Riot::EqualsMacro
- Inherits:
-
AssertionMacro
- Object
- AssertionMacro
- Riot::EqualsMacro
- Defined in:
- lib/riot/assertion_macros/equals.rb
Overview
In the positive case, asserts that the result of the test equals the expected value. Using the == operator to assert equality.
asserts("test") { "foo" }.equals("foo")
should("test") { "foo" }.equals("foo")
asserts("test") { "foo" }.equals { "foo" }
In the negative case, asserts that the result of the test *does not* equal the expected value. Using the == operator.
denies("test") { "foo" }.equals("bar")
denies("test") { "foo" }.equals { "bar" }
Instance Attribute Summary
Attributes inherited from AssertionMacro
Instance Method Summary collapse
-
#devaluate(actual, expected) ⇒ Array
Supports negative/converse assertion testing.
-
#evaluate(actual, expected) ⇒ 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, expected) ⇒ Array
Supports negative/converse assertion testing. This is also where magic happens.
29 30 31 32 33 34 35 |
# File 'lib/riot/assertion_macros/equals.rb', line 29 def devaluate(actual, expected) if expected != actual pass .is_equal_to(expected).when_it_is(actual) else fail .did_not_expect(actual) end end |
#evaluate(actual, expected) ⇒ Array
Supports positive assertion testing. This is where magic happens.
19 20 21 22 23 24 25 |
# File 'lib/riot/assertion_macros/equals.rb', line 19 def evaluate(actual, expected) if expected == actual pass .is_equal_to(expected) else fail (expected).not(actual) end end |