module GrumpyOldMan

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

Constants

VERSION

Public Instance Methods

assert(arg = nil) { || ... } click to toggle source

A simple assert for RSpec.

@example

assert true

@example

assert { true.to_s == "true" }

@param [Object] arg An optional arg to assert as equal to true.

# File lib/grumpy_old_man.rb, line 16
def assert(arg = nil)
  arg = yield if block_given?
  assert_equal !!arg, true
end
assert_equal(actual, expected) click to toggle source

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

@param [Object] actual The Object to compare. @param [Object] expected The expected value.

# File lib/grumpy_old_man.rb, line 40
def assert_equal(actual, expected)
  expect(actual).to eql(expected)
end
assert_raise(ex, &block) click to toggle source

A basic assert helper that ensures an Error was raised. @param [Class] ex The expected Exception class.

# File lib/grumpy_old_man.rb, line 46
def assert_raise(ex, &block)
  expect(Proc.new(&block)).to raise_error(ex)
end
refute(arg = nil) { || ... } click to toggle source

A simple refute for RSpec.

@example

refute false

@example

refute { false.to_s == "true" }

@param [Object] arg An optional arg to assert as equal to true.

# File lib/grumpy_old_man.rb, line 30
def refute(arg = nil)
  arg = yield if block_given?
  assert_equal !!arg, false
end