Module: Expectation::Assertions

Included in:
Test::Unit::TestCase
Defined in:
lib/expectation/assertions.rb

Overview

The Expectation::Assertions module provides expect! and inexpect! assertions to use from within test cases.

Example

require_relative 'test_helper'
require 'expectation/assertions'

class ExpectationTest < Test::Unit::TestCase
  def test_one
  end
end

Instance Method Summary collapse

Instance Method Details

#expect!(*expectation, &block) ⇒ Object

verifies the passed in expectations



30
31
32
33
# File 'lib/expectation/assertions.rb', line 30

def expect!(*expectation, &block)
  good = Expectation.met_expectations?(*expectation, &block)
  assert_block(Expectation.last_error) { good }
end

#inexpect!(*expectation, &block) ⇒ Object

verifies the failure of the passed in expectations



36
37
38
39
# File 'lib/expectation/assertions.rb', line 36

def inexpect!(*expectation, &block)
  good = Expectation.met_expectations?(*expectation, &block)
  assert_block("Expectation(s) should fail, but didn't") { !good }
end