Module: Expectation::Assertions
- Defined in:
- lib/expectation/assertions.rb
Overview
The Expectation::Assertions module provides expect! and inexpect! assertions to use from within test cases.
Example
class ExpectationTest < Test::Unit::TestCase
include Expectation::Assertions
def test_one
end
end
Instance Method Summary collapse
-
#expect!(*expectation, &block) ⇒ Object
verifies the passed in expectations.
-
#inexpect!(*expectation, &block) ⇒ Object
verifies the failure of the passed in expectations.
Instance Method Details
#expect!(*expectation, &block) ⇒ Object
verifies the passed in expectations
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/expectation/assertions.rb', line 22 def expect!(*expectation, &block) exc = nil begin Expectation.expect!(*expectation, &block) rescue Expectation::Error exc = $ERROR_INFO end assert_block(exc && exc.) { !exc } end |
#inexpect!(*expectation, &block) ⇒ Object
verifies the failure of the passed in expectations
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/expectation/assertions.rb', line 35 def inexpect!(*expectation, &block) exc = nil begin Expectation.expect!(*expectation, &block) rescue Expectation::Error exc = $ERROR_INFO end assert_block("Expectation(s) should fail, but didn't") { exc } end |