A long-lived project that still receives updates
Specing framework for Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 13.0
~> 0.75
~> 0.17
~> 0.9

Runtime

~> 0.1.6
~> 1.1.5
~> 3.0.9
 Project Readme

Fix

Home Version Yard documentation Ruby RuboCop License

Fix specing framework for Ruby

Project Goals

  • Distinguish Specifications from Examples: Clear separation between what is expected (specifications) and how it's demonstrated (examples).
  • Logic-Free Specification Documents: Create specifications that are straightforward and free of complex logic, focusing purely on defining expected behaviors.
  • Nuanced Semantic Language in Specifications: Utilize a rich, nuanced semantic language, similar to that in RFC 2119, employing keywords like MUST, SHOULD, and MAY to define different levels of requirement in specifications.
  • Fast and Individual Test Execution: Enable quick execution of tests on an individual basis, providing immediate feedback on compliance with specifications.

Installation

Add to your Gemfile:

gem "fix", ">= 1.0.0.beta9"

Then execute:

bundle install

Or install it yourself:

gem install fix --pre

Example

Specifications for a Duck class:

# examples/duck/fix.rb

require "fix"

Fix :Duck do
  it SHOULD be_an_instance_of :Duck

  on :swims do
    it MUST be_an_instance_of :String
    it MUST eql "Swoosh..."
  end

  on :speaks do
    it MUST raise_exception NoMethodError
  end

  on :sings do
    it MAY eql "♪... ♫..."
  end
end

Implementing the Duck class:

# examples/duck/app.rb

class Duck
  def walks
    "Klop klop!"
  end

  def swims
    "Swoosh..."
  end

  def quacks
    puts "Quaaaaaack!"
  end
end

Running the test:

# examples/duck/test.rb

require_relative "app"
require_relative "fix"

Fix[:Duck].test { Duck.new }

Execute:

ruby examples/duck/test.rb

Expected output:

(irb):3 Success: expected #<Duck:0x00007fb2fa208708> to be an instance of Duck.
(irb):7 Success: expected to eq "Swoosh...".
(irb):15 NoMethodError: undefined method `sings' for #<Duck:0x00007fb2fd8371d0>.
(irb):6 Success: expected "Swoosh..." to be an instance of String.
(irb):11 Success: undefined method `speaks' for #<Duck:0x00007fb2fcc79258>.

Contact

Versioning

Fix follows Semantic Versioning 2.0.

License

The gem is available as open source under the terms of the MIT License.


This project is sponsored by:
Sashité