Skip to content

SimpleSpec - A Tiny Ruby Testing Library

Published: at 08:22 PM

Why?

Well, why not? In all seriousness though, there are times when I want to test some Ruby code without having to rely a full blown framework. But… I still wanted the expressiveness of how RSpec writes expectations.

So, I wrote a tiny library to do just that. So now I can create a Ruby file anywhere and test it by doing something like the following:

require '~./ruby-tools/simple_spec.rb'
include Eddorre::SimpleSpec

expect(2).to eq(2)

expect { 1 + 1 == 2 }.to be_truthy

expect { 1 + 2 == 5 }.not_to be_truthy

Like any good testing framework, you can also run the library on itself by calling the following:

ruby '~/.ruby-tools/spec.rb'

Of course, you’ll have to clone it into your home directory yourself if you want to do all of that so:

git clone git@github.com:eddorre/ruby_tools.git ~/.ruby_tools

Why is it called Ruby Tools instead of SimpleSpec?

I intend the repo to be a small collection of small Ruby utilities that I might want to include on a Ruby file and testing is one of those utilities. Right now, the only other thing in there is Eddorre::TerminalColors which SimpleSpec uses to colorize PASS and FAIL text.


Previous Post
Exhibit Code - Token Bucket Rate Limiter