Fix

Home Version Yard documentation CI RuboCop License

⚠️ This project is still in the experimental phase. May be used at your own risk.

Fix specing framework for Ruby

Project goals

  • Extract specs from the tests.
  • Look like English documents.
  • Be minimalist and easy to hack.
  • Run tests quickly.

Installation

Add this line to your application's Gemfile:

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

And then execute:

bundle

Or install it yourself as:

gem install fix --pre

Example

Given this app:

# examples/duck/app.rb
class Duck
  def walks
    "Klop klop!"
  end

  def swims
    "Swoosh..."
  end

  def quacks
    puts "Quaaaaaack!"
  end
end

And this fixed behavior:

# examples/duck/fix.rb

relative "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

When I run this test:

# examples/duck/test.rb

require_relative "app"
require_relative "fix"

Fix[:Duck].test { Duck.new }
ruby examples/duck/test.rb

I should see this output:

Success: expected #<Duck:0x00007fc55b3c6388> to be an instance of Duck.
Success: expected to eql "Swoosh...".
Success: undefined method `speaks' for #<Duck:0x00007fc55b3c46f0>.
NoMethodError: undefined method `sings' for #<Duck:0x00007fc558aab6d8>.

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:
Sashite