Fixrb

Fixrb

A collection of Ruby testing libraries designed to make programmers happy.

Fix is at the heart of it. A specification describes how an object must behave, apart from any implementation. A test then challenges one implementation against it, and the same specification can challenge as many implementations as you need.

require "fix"

# A specification
Fix :Calculator do
  on(:new, 2) do
    on(:add, 3) do
      it MUST be 5
    end
  end
end

# An implementation
class Calculator
  def initialize(first)
    @first = first
  end

  def add(second)
    @first + second
  end
end

# A test
Fix[:Calculator].test { Calculator }
The specification names no class: the test chooses which implementation to challenge.

Gems

Each gem does one thing, in a few hundred lines of code at most, so that you can read it before you trust it.

Fix and its extensions

Fix is the main gem of Fixrb. fix-command and fix-its extend it.

  • fix

    Specifications with MUST, SHOULD and MAY requirements, kept apart from the implementations they challenge.

    1.0 in preparation

  • fix-command

    The fix command, to run specification files.

    Moving to Fix 1.0

  • fix-its

    Adds its to specifications, to describe an attribute in one line.

    Moving to Fix 1.0

Libraries

These gems do not extend Fix: use them on their own, with any test framework, or to build one. Fix 1.0 is built on matchi and aw.

  • matchi

    Matchers for any test framework, in which the expected value makes the comparison, not the object under test.

    Version 5.0

  • matchi-fix

    Extends matchi with a matcher that checks a value against a Fix specification, from any test framework.

    Moving to Fix 1.0

  • aw

    Runs a block in a forked process and returns its result. Fix uses it to keep contexts apart.

    1.0 in preparation

  • spectus

    Expectations with the requirement levels of RFC 2119. Built on test_tube and expresenter.

    Version 5.0

  • test_tube

    Checks a value, or what a block returns or raises, against a matcher. Built on defi.

    Version 4.0

  • expresenter

    Presents the result of an expectation: success, warning, info, failure or error.

    Version 1.5

  • defi

    Prepares a method call, a name and its arguments, to send to any object.

    Version 3.0

  • brutal

    Writes plain Ruby tests from a YAML file, by recording what your code returns in every combination of contexts.

    1.6 in beta

From the blog

All posts