Tag Archives: assertions

Assit on GitHub – the gem is back

I while ago I wrote a small ruby library for runtime assertions to use in our projects. While I didn’t use it as heavily as expected, it has been useful in debugging in the beginning. It offers the possibility to include extra runtime checks – even expensive ones – to the code, which can be disabled in production code.

I’ve moved the project to github now, and the gem is not broken anymore. This means that you can

sudo gem install averell23-assit

from gems.github.com. The old gem (assit) is still around on rubyforge for some reason, but it’ll remain on 0.0.3 forever. If you use this, better get the github version (averell23-assit) now.

Runtime Assertions in Ruby

I’ve published my first gem on rubyforge: assit. It does runtime assertions for Ruby.

When I got started with Ruby, I was flabbergasted that there weren’t any runtime assertions at all. I have no idea why – even though there are one gadzillion different unit testing whatnots, a decent debugger and even a profiler. But this basic debugging tool, that has been there since the dawning days of C, is flatly missing; although it’d be even more useful in a language that doesn’t do any static checking.

So I’ve written my own little thing, and put it on for everyone to use. Getting started is easy: Just do

sudo gem install assit

and you’ll be ready to use it.

In the code, it’ll work like this:

require 'assit'

# Just some examples, there are more assertions
assit(defined?(assit)) # Yes, this is self-referential ;-)

x = 2 + 3
assit_equal(5, x, "There seems to be a problem with the addition")

foo = Foo.new
assit_kind_of(Foo, foo)

Continue reading