class RSpecial::Operatics

Operatics delegates operator based assertions for execpt.rb.

Public Class Methods

new(target, negate=false) click to toggle source
# File lib/rspecial/operatics.rb, line 9
def initialize(target, negate=false)
  @target = target
  @negate = negate
end

Private Instance Methods

assert!(op, *a, &b) click to toggle source
# File lib/rspecial/operatics.rb, line 28
def assert!(op, *a, &b)
  if assay = Assertion.by_operator(op)
    return assay.assert!(@target, *a, &b)
  else
    assert! @target.send(op, *a, &b)
  end
end
generic?(op) click to toggle source
# File lib/rspecial/operatics.rb, line 46
def generic?(op)
  @target.method(op).owner == ::Kernel
end
method_missing(op, *a, &b) click to toggle source
Calls superclass method
# File lib/rspecial/operatics.rb, line 17
def method_missing(op, *a, &b)
  super(op, *a, &b) if op.to_s =~ /^\w/

  if @negate
    refute!(op, *a, &b)
  else
    assert!(op, *a, &b)
  end
end
refute!(op, *a, &b) click to toggle source
# File lib/rspecial/operatics.rb, line 37
def refute!(op, *a, &b)
  if assay = Assertion.by_operator(op)
    return assay.refute!(@target, *a, &b)
  else
    refute! @target.send(op, *a, &b)
  end
end