Created: 2012-08-21 05:22
Updated: 2014-02-23 17:03

Grumpy Old Man

Build Status Dependency Status Code Climate

Adding old school asserts to RSpec

GrumpyOldMan adds the following methods to RSpec without compromising any of RSpec's awesomeness.

  • assert
  • assert_equal
  • assert_raise

I love several things about RSpec.

  • Its beautiful output from the test runner
  • Its declarative approach to writing tests... well at least the outer wrapper i.e.
describe Thing do
  it 'should do stuff' do
    # ...

Unfortunately parts of RSpec add unwanted complexity to a relatively simple problem:

assert true

Simple is better

I contend it's better to write tests in the same manner you write your app. Doing so reduces cognitive load by eliminating the context switching between app code and wonky DSLs in the test suite.

It simplifies your tests... and that's a good thing.

Consider the following example from the RSpec docs.

expect( eq(, :USD))

Rewritten with GrumpyOldMan.

assert ==, :USD)
# or ...
assert_equal,, :USD)

Asserts encourage tests that more closely resemble the app logic itself. Making tests look familiar & more natural.


gem install grumpy_old_man

Simply include GrumpyOldMan in your spec/test like so.

require 'grumpy_old_man'

describe Thing
  include GrumpyOldMan

  it "should feel good" do
    assert true

  it "should be balanced" do
    actual = true
    expected = true
    assert_equal actual, expected

  it "should be exceptional" do
    assert_raise(Exception) do


You might not agree, but I'm sticking with my old fashioned assert.

Now get off my lawn!

If you like GrupyOldMan, check out MicroTest and discover just how serene testing can be.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more