When you don’t have time or are too lazy to write a proper spec

require 'rspec'
require_relative '../lib/tasty_sarnie.rb'

describe TastySarnie do
  it "should not catch fire when you create an instance" do
    TastySarnie( "arg1", "arg2" ).should_not == nil

This shows you:

  • TastySarnie is a class (or walks like a class).
  • TastySarnie is found in the ../lib/tasty_sarnie.rb file.
  • tasty_sarnie.rb doesn’t contain syntax errors.
  • TastySarnie.new takes 2 arguments without crying.
  • TastySarnie.new returns something.
  • It doesn’t throw an exception.

This is the absolute minimum there should be for a spec/test.

I got this basic test from reading Russ Olsen’s Elegant Rubyhttp://www.rubyinside.com/a-review-of-eloquen…, a book I highly recommend.

Added on:
Last updated: