Module: SimpleContracts

Defined in:
lib/simple_contracts/base.rb,
lib/simple_contracts.rb,
lib/simple_contracts/sampler.rb,
lib/simple_contracts/version.rb,
lib/simple_contracts/statistics.rb

Overview

Base class for writting contracts. the only public method is SimpleContracts::Base#call (or alias SimpleContracts::Base#match!)

The purpose is to validate some action against your expectations. There are 2 kind of them:

  • Guarantee - state that SHOULD be recognized for after every the actions

  • Expectation - state that COULD be recognized after the action

The key behavior is:

  • First verify that all Guarantees are met, then

  • Then move to Expectation and verify that at least one of them met.

  • If any of those checks fail - we should recieve detailed exception - why.

There are 2 kind of exceptions:

  • GuaranteeError - happens if one of the Guarantees failes

  • ExpectationsError - happens if none of Expextations were meet.

Both of them raise with the @meta object, which contains extra debugging info.

Defined Under Namespace

Classes: Base, ExpectationsError, GuaranteesError, Sampler, Statistics

Constant Summary collapse

VERSION =
"0.1.0"