Skip to content

fixrb/fix

main
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
bin
 
 
 
 
 
 
fix
 
 
img
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 use.
  • Run tests quickly.

Installation

Add this line to your application's Gemfile:

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

And then execute:

bundle

Or install it yourself as:

gem install fix --pre

Example

Given these specifications:

# 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

When we load this Duck application:

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

  def swims
    "Swoosh..."
  end

  def quacks
    puts "Quaaaaaack!"
  end
end

And we run this test:

# examples/duck/test.rb

require_relative "app"
require_relative "fix"

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

We should see this 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:
Sashite