Ruby Gem Version

Contracts::Gen

An extension for Gen::Test, defining generators for Contracts.

Synopsis

require 'gen/test'
require 'contracts'
require 'contracts/gen'

Sum = lambda { |xs| xs.reduce(:+) }

C = Contracts

class SumTest < Minitest::Test
  include Gen::Test

  def test_sum_for_all_arrays_of_integers
    for_all C::ArrayOf[Integer] do |xs|
      y = Sum[xs]
      assert_equal(y, xs.reduce(:+))
    end
  end
end

Install

> gem install contracts-gen

or, add:

gem 'contracts-gen'

to your Gemfile, and then execute:

> bundle

See Also