Spectrum is an RSpec-style BDD framework that runs on top of Ruby Test, the universal test harness for Ruby. It supports all of RSpec's organization syntax with only a few exceptions.

Overview

Like RSpec, Spectrum organizes specifications into describe and it blocks. Here is the classic RSpec example.

  describe Order do
    it "sums the prices of its line items" do
      order = Order.new
      order.add_entry(LineItem.new(:item => Item.new(
        :price => Money.new(1.11, :USD)
      )))
      order.add_entry(LineItem.new(:item => Item.new(
        :price => Money.new(2.22, :USD),
        :quantity => 2
      )))
      order.total.should eq(Money.new(5.55, :USD))
    end
  end

Unlike RSpec, Spectrums's assertion framework is completely independent to the test framework, so almost any assertion system will work. In the example above we are using Assay RSpec which is largely compatible with RSpec's expectation system. Other options include A.E. and Fluidity.

The same hold true for mocking systems. Use the mocking system you prefer, such a Mocha. (Though admittedly, it might be nice if someone created a BRASS-compliant mocking system largely compatible with RSpec's.)