Skip to content
This repository

When all you need is #assert

tree: 427ceb677d

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 Manifest
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 examples.rb
Octocat-spinner-32 gem.watchr
Octocat-spinner-32 nanotest.gemspec
Octocat-spinner-32 specs.watchr
README.rdoc

“Frustra fit per plura quod potest fieri per pauciora.” –William of Ockham “It is futile to do with more things that which can be done with fewer.”

Summary

Extremely mynymal test framework. Perfect for DIY lovers. Nanotest provides the bare mynymum needed; for everything else, there's ruby.

Install

gem install nanotest --source http://gemcutter.org

Examples

require 'nanotest'
include  Nanotest

assert {     1 == 1 }
assert {     2  > 1 }
assert { not 1  > 2 }
assert {     1 == 2 } #line 12

outputs:

...F
(examples.rb:012) assertion failed

See the phocus gem for a “real life example”.

API

Nanotest has a single method: #assert. You can either include Nanotest as above, or use its method directly:

Nanotest.assert { true }

Its block is expected to return a boolean. If it's false it fails, otherwise it passes. Simple as that.

#assert also accepts a custom failure message (defaults to “assertion failed”):

assert("foo is too small") { @foo > 5 } #line 36
#=> (examples.rb:036) foo is too small

That's pretty much it. Maximum Simplicity. If you insist on doing something fancy, check out the wiki for a few tips and tricks.

Stats

$ rake -s loc
lib contains 18 SLOCs

Links

source

github.com/mynyml/nanotest

docs

rdoc.info/projects/mynyml/nanotest

wiki

wiki.github.com/mynyml/nanotest

bugs

github.com/mynyml/nanotest/issues

Something went wrong with that request. Please try again.