A unit testing framework
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
lib
test
.gitignore
.travis.yml
.yardopts
Gemfile
MIT-LICENSE
README.md
Rakefile
declare.gemspec

README.md

declare

Build Status Gem Version

Description

A unit testing framework with tiny DSL.

Features

  • Simple syntax.
  • Markdown looks Reports.
  • Tiny keyboard typings :)

Usage

Overview

Product Code

class Person
  attr_reader :name, :birth

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

Test Code

require 'declare/autorun'

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 'Taro'
    ok name.kind_of?(String)
    ng name.match(/[1-9]/)
  end

  The john.birth do
    kind_of Time
  end
end

Report

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

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

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

------------------------------------------------------------------------------
3 scopes, 10 assertions, 1 failures
$ echo $? #=> 1(count of failed behaviors)

How to use in Rake Tasks likely with test/unit

That's easy. Replace below.

require 'test/unit'

to

require 'declare/autorun'

Requirements

Install

$ gem install declare

Link

License

The MIT X11 License
Copyright (c) 2012 Kenichi Kamiya
See MIT-LICENSE for further details.