Skip to content
trans edited this page Sep 13, 2010 · 8 revisions

AE is an assertions framework. It was designed to serve as a reusable domain language for other test frameworks, such as QED and Cucumber. Essentially AE defines the method assert. The method is compatible with the same method as defined by Test::Unit and minitest which verifies truth of a single argument (and can accept an optional failure message).

  assert( true )

In addition AE’s assert method has been extended to accept a block, the result of which is likewise verified.

  assert{ true }

But the real power the AE’s assert method lies in it’s use without an argument or a block. In that case it returns an instance of Assertor. An Assertor is an Assertions Functor, or Higher-Order Function —a function that operates on another function. With it, we easily make assertions with a fluent notation.

  x.assert == y

  a.assert.include? e

  StandardError.assert.raised? do
    ...
  end

And so forth. Any method can be used in conjunction with assert to make an assertion.

  class String
    def daffy?
      /daffy/i =~ self
    end
  end

  "Daffy Duck".assert.daffy?

In addition to assert, AE provides an additional assertion method expect.

Please have a look at the QED generated Demonstrandum or the RDoc generated API Documentation to learn more.

Clone this wiki locally