Module: GrumpyOldMan

Defined in:
lib/grumpy_old_man.rb,
lib/grumpy_old_man/version.rb

Overview

A mixin for RSpec tests that provides old school assert methods.

Constant Summary collapse

VERSION =
"0.1.5"

Instance Method Summary collapse

Instance Method Details

#assert(arg = nil) ⇒ Object

A simple assert for RSpec.

Examples:

assert(true)
assert { true.to_s == "true" }


15
16
17
18
19
20
21
# File 'lib/grumpy_old_man.rb', line 15

def assert(arg=nil)
  if block_given?
    assert_equal(yield, true)
  else
    assert_equal(arg, true)
  end
end

#assert_equal(actual, expected) ⇒ Object

A basic assert helper that tests for Object equality. Tests for object equivalence rather than object identity since this is sufficient for most tests.



28
29
30
# File 'lib/grumpy_old_man.rb', line 28

def assert_equal(actual, expected)
  expected.should == actual
end

#assert_raise(ex, &block) ⇒ Object

A basic assert helper that ensures an Error was raised.



34
35
36
# File 'lib/grumpy_old_man.rb', line 34

def assert_raise(ex, &block)
  Proc.new(&block).should raise_error(ex)
end