Class CustomMatcher
In: lib/rspec/custom_matcher.rb
Parent: Object

Methods

Public Class methods

[Source]

   # File lib/rspec/custom_matcher.rb, line 4
4:   def self.create(class_name, &block)
5:     klass = Class.new(CustomMatcher)
6:     klass.send(:define_method, :matcher, &block) if block_given?
7:     Object.const_set(build_class_name(class_name), klass)
8:   end

[Source]

    # File lib/rspec/custom_matcher.rb, line 10
10:   def initialize(expected = nil)
11:     @expected = expected
12:   end

Public Instance methods

[Source]

    # File lib/rspec/custom_matcher.rb, line 14
14:   def failure_message
15:     message
16:   end

[Source]

    # File lib/rspec/custom_matcher.rb, line 22
22:   def matcher(target, expected)
23:     target == expected
24:   end

[Source]

    # File lib/rspec/custom_matcher.rb, line 26
26:   def matches?(target)
27:     @target = target
28:     if self.method(:matcher).arity == 2
29:       matcher(@target, @expected)
30:     else
31:       matcher(@target)
32:     end
33:   end

[Source]

    # File lib/rspec/custom_matcher.rb, line 18
18:   def negative_failure_message
19:     message(false)
20:   end

[Validate]