Class Spec::Matchers::OperatorMatcher

  1. lib/spec/matchers/operator_matcher.rb
Parent: Object

Public class methods

get (klass, operator)
[show source]
# File lib/spec/matchers/operator_matcher.rb, line 15
        def get(klass, operator)
          registry[klass] && registry[klass][operator]
        end
new (actual)
[show source]
# File lib/spec/matchers/operator_matcher.rb, line 20
      def initialize(actual)
        @actual = actual
      end
register (klass, operator, matcher)
[show source]
# File lib/spec/matchers/operator_matcher.rb, line 10
        def register(klass, operator, matcher)
          registry[klass] ||= {}
          registry[klass][operator] = matcher
        end
registry ()
[show source]
# File lib/spec/matchers/operator_matcher.rb, line 6
        def registry
          @registry ||= {}
        end
use_custom_matcher_or_delegate (operator)
[show source]
# File lib/spec/matchers/operator_matcher.rb, line 24
      def self.use_custom_matcher_or_delegate(operator)
        define_method(operator) do |expected|
          if matcher = OperatorMatcher.get(@actual.class, operator)
            @actual.send(::Spec::Matchers.last_should, matcher.new(expected))
          else
            eval_match(@actual, operator, expected)
          end
        end
      end

Public instance methods

description ()
[show source]
# File lib/spec/matchers/operator_matcher.rb, line 42
      def description
        "#{@operator} #{@expected.inspect}"
      end
fail_with_message (message)
[show source]
# File lib/spec/matchers/operator_matcher.rb, line 38
      def fail_with_message(message)
        Spec::Expectations.fail_with(message, @expected, @actual)
      end