Fix 1.0 is here
Fix 1.0 is out: a Ruby testing framework where a test suite is an RFC 2119 specification, tested against any subject, each context in its own process.
The main gem of Fixrb
Write once what a Ruby object must do; test every implementation against it.
A specification says what a subject MUST, SHOULD or MAY do, in the words of RFC 2119, and nothing about how it is made. Write it once, then test an Array against it today, your own class tomorrow, a library you depend on, or the next version of any of them, beside the RSpec or minitest suite you already have.
gem install fixrequire "fix"
# A stack, whatever it is made of.
Fix :Stack do
on :push, 1 do
on :pop do
it MUST eq 1
end
end
on :pop do
it SHOULD be_nil
end
on :peek do
it MAY be_nil
end
end
# A test picks the subject: an Array.
exit(Fix[:Stack].test { [] })
ruby stack.rb stack.rb:7: Success: expected 1 to eq 1 stack.rb:12: Success: expected nil to be nil stack.rb:16: Info: NoMethodError: undefined method 'peek' for an instance of Array
It is read once, when the file is loaded: no setup, no mock, no logic, and anything wrong in it raises before a test runs. It names no class; the test picks the subject, and one specification serves as many implementations as you like.
MUST, SHOULD and MAY tell what is required, what is recommended and what is optional, so that a contract between a library and its users, or between two teams, says what blocks a build and what does not. A SHOULD not met is a warning, a MAY on a method the subject lacks is an info, and both pass.
Each context runs in a child process. What a subject does to a global, a constant or ENV stays in its context, and the order of the contexts cannot change a result. In a Rails application shows it with a database, which a process does not isolate.
Fix is built from small libraries and extended by small gems. Each does one thing, in a few hundred lines of code at most, so that you can read it before you trust it.
Gems that extend Fix, or bring its specifications to other test frameworks.
Adds the word its to specifications: a method of the subject and its expectation on one line.
Version 1.0
A matcher of matchi that tests a value against a specification of Fix, from any test framework.
Version 4.0
The fix command: runs each specification file in a process of its own, and tells how many files were met.
Version 1.0
Building blocks that do not depend on Fix: use them on their own, with any test framework, or to build one. Fix 1.0 is built on aw, defi, matchi and spectus.
Matchers for any test framework, in which the expected value makes the comparison, not the object under test.
Version 6.0
Expectations with the requirement levels of RFC 2119, MUST, SHOULD and MAY, that give a result instead of raising. The engine of Fix 1.0, built on defi.
Version 6.0
Runs a block in a forked process and returns its result. Fix 1.0 uses it to keep contexts apart.
Version 1.0
Prepares a method call, a name and its arguments, to send to any object and keep what came back.
Version 4.0
Checks a value, or what a block returns or raises, against a matcher. Built on defi; not used by Fix 1.0.
Version 4.0
Presents the result of an expectation: success, warning, info, failure or error. Not used by Fix 1.0.
Version 1.5
A command to run as it is, rather than a library to build on.
Writes plain Ruby test files from a YAML manifest, by recording what the code returns in every combination of contexts. Built on aw.
Version 2.0
Fix 1.0 is out: a Ruby testing framework where a test suite is an RFC 2119 specification, tested against any subject, each context in its own process.
How Fix implements the MUST, SHOULD and MAY requirement levels for more precise specifications, and how this compares with RSpec’s historical evolution.
How Fix’s approach to testing in Ruby keeps specifications apart from their implementations, for a test suite that is easier to maintain and to reuse.