Object
# File lib/rspec/matchers/operator_matcher.rb, line 14 14: def get(klass, operator) 15: registry[klass] && registry[klass][operator] 16: end
# File lib/rspec/matchers/operator_matcher.rb, line 19 19: def initialize(actual) 20: @actual = actual 21: end
# 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
# File lib/rspec/matchers/operator_matcher.rb, line 5 5: def registry 6: @registry ||= {} 7: end
# 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
# 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.
Generated with the Darkfish Rdoc Generator 1.1.6.