Parent

Class Index [+]

Quicksearch

RSpec::Matchers::OperatorMatcher

Public Class Methods

get(klass, operator) click to toggle source
    # File lib/rspec/matchers/operator_matcher.rb, line 14
14:         def get(klass, operator)
15:           registry[klass] && registry[klass][operator]
16:         end
new(actual) click to toggle source
    # File lib/rspec/matchers/operator_matcher.rb, line 19
19:       def initialize(actual)
20:         @actual = actual
21:       end
register(klass, operator, matcher) click to toggle source
    # File lib/rspec/matchers/operator_matcher.rb, line 9
 9:         def register(klass, operator, matcher)
10:           registry[klass] ||= {}
11:           registry[klass][operator] = matcher
12:         end
registry() click to toggle source
   # File lib/rspec/matchers/operator_matcher.rb, line 5
5:         def registry
6:           @registry ||= {}
7:         end
use_custom_matcher_or_delegate(operator) click to toggle source
    # File lib/rspec/matchers/operator_matcher.rb, line 23
23:       def self.use_custom_matcher_or_delegate(operator)
24:         define_method(operator) do |expected|
25:           if matcher = OperatorMatcher.get(@actual.class, operator)
26:             @actual.send(::RSpec::Matchers.last_should, matcher.new(expected))
27:           else
28:             eval_match(@actual, operator, expected)
29:           end
30:         end
31: 
32:         negative_operator = operator.sub(/^=/, '!')
33:         if negative_operator != operator && respond_to?(negative_operator)
34:           define_method(negative_operator) do |expected|
35:             opposite_should = ::RSpec::Matchers.last_should == :should ? :should_not : :should
36:             raise "RSpec does not support `#{::RSpec::Matchers.last_should} #{negative_operator} expected`.  " +
37:               "Use `#{opposite_should} #{operator} expected` instead."
38:           end
39:         end
40:       end

Public Instance Methods

description() click to toggle source
    # File lib/rspec/matchers/operator_matcher.rb, line 50
50:       def description
51:         "#{@operator} #{@expected.inspect}"
52:       end
fail_with_message(message) click to toggle source
    # File lib/rspec/matchers/operator_matcher.rb, line 46
46:       def fail_with_message(message)
47:         RSpec::Expectations.fail_with(message, @expected, @actual)
48:       end

Private Instance Methods

eval_match(actual, operator, expected) click to toggle source
    # File lib/rspec/matchers/operator_matcher.rb, line 56
56:       def eval_match(actual, operator, expected)
57:         ::RSpec::Matchers.last_matcher = self
58:         @operator, @expected = operator, expected
59:         __delegate_operator(actual, operator, expected)
60:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.