Skip to main content
Arctic Dev

Spectator

Spectator is a behavior-driven, spec-based testing framework. It ports functionality from RSpec to Crystal. Spectator aims to relieve the developer from writing tedious tests. It provides utilities and features to reduce boilerplate.

Here’s a sample of a spec file using Spectator:

require "./spec_helper"

Spectator.describe Clock do
  subject(clock) { Clock.new(7, 30, 0) }

  describe "#tick" do
    it "advances the clock by a second" do
      clock.tick
      expect(clock.second).to eq(1)
    end

    context "near the hour" do
      subject(clock) { Clock.new(6, 59, 59) }

      it "rolls over to the next hour" do
        clock.tick
        is_expected.to have_attributes(hour: 7, minute: 0, second: 0)
      end
    end
  end
end