| Class | CustomMatcher |
| In: |
lib/rspec/custom_matcher.rb
|
| Parent: | Object |
# 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
# File lib/rspec/custom_matcher.rb, line 10
10: def initialize(expected = nil)
11: @expected = expected
12: end
# File lib/rspec/custom_matcher.rb, line 22
22: def matcher(target, expected)
23: target == expected
24: end
# 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