Skip to content

Getting Started

Cyril Kato edited this page Nov 5, 2026 · 2 revisions

Getting Started

The guide on fixrb.dev is where Fix is taught, page by page, with examples whose output is checked on every build of the site: fixrb.dev/gems/fix/v1/getting-started/.

The shortest version, for the impatient:

# Gemfile
gem "fix"
# duck_fix.rb
require "fix"

class Duck
  def walk = "Klop klop!"
  def swim = "Swoosh..."
end

Fix :Duck do
  on :walk do
    it MUST eq "Klop klop!"
  end

  on :swim do
    it MUST eq "Swoosh..."
  end

  on :speak do
    it MAY eq "Quaaaaaack!"
  end
end

exit(Fix[:Duck].test { Duck.new })
$ ruby duck_fix.rb
duck_fix.rb:11: Success: expected "Klop klop!" to eq "Klop klop!"
duck_fix.rb:15: Success: expected "Swoosh..." to eq "Swoosh..."
duck_fix.rb:19: Info: NoMethodError: undefined method 'speak' for an instance of Duck

Fix requires Ruby 3.3 or later on a system with fork. From here, the guide takes over: writing specifications, the matchers, running them with the fix command, and coming from RSpec. The README is the reference, and this wiki explains the why.

Clone this wiki locally