Class: Quarry::Expectation

Inherits:
Object show all
Defined in:
lib/quarry/expectation.rb

Overview

Expectation

Expectation is an Assertion Functor.

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *a, &b) ⇒ Object (private)

Converts missing method into an Assertion.



27
28
29
30
31
32
33
34
35
36
# File 'lib/quarry/expectation.rb', line 27

def method_missing(sym, *a, &b)
  test = @delegate.__send__(sym, *a, &b)

  if (@negate ? test : !test)
    msg   = @message || __msg__(sym, *a, &b)
    error = Assertion.new(msg)
    error.set_backtrace(@backtrace)
    raise error
  end
end