Module MiniTest::Assertions
In: lib/minitest/unit.rb

MiniTest Assertions. All assertion methods accept a msg which is printed if the assertion fails.

Methods

Public Instance methods

Fails unless test is a true value.

Fails unless obj is empty.

Fails unless exp == act.

For floats use assert_in_delta

For comparing Floats. Fails unless exp and act are within delta of each other.

  assert_in_delta Math::PI, (22.0 / 7.0), 0.01

For comparing Floats. Fails unless exp and act have a relative error less than epsilon.

Fails unless collection includes obj.

Fails unless obj is an instace of cls.

Fails unless obj is a kind of cls.

Fails unless exp is =~ act.

Fails unless obj is nil

For testing equality operators and so-forth.

  assert_operator 5, :<=, 4

Fails if stdout or stderr do not output the expected results. Pass in nil if you don‘t care about that streams output. Pass in "" if you require it to be silent.

See also: assert_silent

Fails unless the block raises one of exp

Fails unless obj responds to meth.

Fails unless exp and act are equal?

send_ary is a receiver, message and arguments.

Fails unless the call returns a true value TODO: I should prolly remove this from specs

Fails if the block outputs anything to stderr or stdout.

See also: assert_output

Fails unless the block throws sym

Captures $stdout and $stderr into strings:

  out, err = capture_io do
    warn "You did a bad thing"
  end

  assert_match %r%bad%, err

Returns details for exception e

Fails with msg

Returns a proc that will output msg along with the default message.

mu_pp gives a human-readable version of obj. By default inspect is called. You can override this to use pretty_print if you want.

used for counting assertions

Fails if test is a true value

Fails if obj is empty.

Fails if exp == act.

For floats use refute_in_delta.

For comparing Floats. Fails if exp is within delta of act

  refute_in_delta Math::PI, (22.0 / 7.0)

For comparing Floats. Fails if exp and act have a relative error less than epsilon.

Fails if collection includes obj

Fails if obj is an instance of cls

Fails if obj is a kind of cls

Fails if obj is nil.

Fails if +o1+ is not op +o2+ nil. eg:

  refute_operator 1, :>, 2 #=> pass
  refute_operator 1, :<, 2 #=> fail

Fails if obj responds to the message meth.

Fails if exp is the same (by object identity) as act.

Skips the current test. Gets listed at the end of the run but doesn‘t cause a failure exit code.

[Validate]