Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

kachick/declare

Repository files navigation

declare

  • This repository is archived
  • No longer maintained
  • All versions have been removed from https://rubygems.org to free up valuable namespace for other developers.

Build Status

A unit testing framework

Usage

Require Ruby 3.1 or later

Overview

Target Code

class Person
  attr_reader :name, :birth

  def initialize(name)
    @name = name
    @birth = Time.now
  end
end

Test Code

require 'declare/autorun'

Declare.describe do
  The Person.new('John') do |john|
    can :name
    can :birth
    is_a Person
    kind_of Object

    NOT 'Taro'

    The john.name do |name|
      kind_of String
      is_a Person
      ok name.kind_of?(String)
      ng name.match(/[1-9]/)
    end

    The john.birth do
      kind_of Time
    end
  end
end

Report

Detail testing report
=====================

### "John" ### [./example/mixed.rb:25]

* ./example/mixed.rb:27
  Expected: it == other
  Actual  : "John" == "Taro"

------------------------------------------------------------------------------
3 scopes, 10 assertions, 1 failures
$ echo $?
1(count of the failures)

How to use in Rake Tasks likely with test-unit

Replace as below.

require 'test/unit'

to

require 'declare/autorun'

About

Cheap unit testing framework made in my younger days

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published