Fix

Build Status Coverage Status Dependency Status Gem Version Inline docs Documentation License

A specing framework for Ruby.

Contact

Rubies

Fix is supported by Ruby (MRI) 2+.

Installation

Add this line to your application's Gemfile:

gem 'fix'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fix

Philosophy

Minimalist

With ~400 lignes of simple code built on top of Spectus expectation library, facilities such as benchmarking and mocking are not supported. Fix offers however a consistent syntax to DRY and focus your BDD.

Resistant

While specs behave like documents which can be logic-less, their interpretation should not be questioned regardless of the version of Fix, preventing from software erosion. Also, Fix specs are complient with RFC 2119.

Complexity

Monkey-patching, magic tricks and friends are not included. Instead, animated by authentic and immutable Ruby objects, unambiguous, understandable and structured specs are encouraged.

Objective

After having loaded atomically the specs in read-only, the code to be tested can also be loaded and evaluated in isolation by Fix. There is a separation of concerns between the specs and the code.

Usage

class Duck
  def walks
    "Klop klop!"
  end

  def swims
    "Swoosh..."
  end

  def quacks
    puts "Quaaaaaack!"
  end
end

@bird = Duck.new

When I see a #<Duck:0x007f96b285d6d0> that ...

require 'fix'

@duck_spec = Fix::Spec.new :duck do
  on :swims do
    it { SHALL eql: "Swoosh..." }
    it { MAY capture_stdout: " ...\n" }
  end

  on :quacks do
    it { SHOULD capture_stdout: "Quaaaaaack!\n" }
  end

  on :speaks do
    it { MUST raise_exception: NoMethodError }
  end

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

case @duck_spec.valid? @bird
  when true then puts "I call that #{@bird} a duck."
  else warn 'WAT?'
end
ruby test.rb
# Run options: --seed 241686681690348892099960370893524466040
# .....
# Finished in 0.001033 seconds.
# 5 tests, 0 failures, 0 errors

I call that #<Duck:0x007f96b285d6d0> a duck.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Versioning

Fix follows Semantic Versioning 2.0

© 2014 Cyril Wack