class Matchy::Expectations::OperatorExpectation

Class to handle operator expectations.

Examples

13.should == 13
"hello".length.should_not == 2

Public Class Methods

new(receiver, match) click to toggle source
# File lib/matchy/built_in/operator_expectations.rb, line 13
def initialize(receiver, match)
  @receiver, @match = receiver, match
end

Protected Instance Methods

fail!(operator) click to toggle source
# File lib/matchy/built_in/operator_expectations.rb, line 29
def fail!(operator)
  flunk @match ? failure_message(operator) : negative_failure_message(operator)
end
failure_message(operator) click to toggle source
# File lib/matchy/built_in/operator_expectations.rb, line 33
def failure_message(operator)
  "Expected #{@receiver.inspect} to #{operator} #{@expected.inspect}."
end
negative_failure_message(operator) click to toggle source
# File lib/matchy/built_in/operator_expectations.rb, line 37
def negative_failure_message(operator)
  "Expected #{@receiver.inspect} to not #{operator} #{@expected.inspect}."
end
pass!() click to toggle source
# File lib/matchy/built_in/operator_expectations.rb, line 25
def pass!
  defined?($current_test_case) ? $current_test_case.assert(true) : (assert true)
end