blob: b60dd2536bc61638c14f191c5133ebc42b8c5d4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
require 'mspec/matchers/method'
class HaveSingletonMethodMatcher < MethodMatcher
def matches?(obj)
@obj = obj
obj.singleton_methods(@include_super).include? @method
end
def failure_message
["Expected #{@obj} to have singleton method '#{@method.to_s}'",
"but it does not"]
end
def negative_failure_message
["Expected #{@obj} NOT to have singleton method '#{@method.to_s}'",
"but it does"]
end
end
module MSpecMatchers
private def have_singleton_method(method, include_super = true)
HaveSingletonMethodMatcher.new method, include_super
end
end
|