blob: 00dcbd39eb3b49674058c76b2327dd31ba7e09c1 (
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 HaveInstanceMethodMatcher < MethodMatcher
def matches?(mod)
@mod = mod
mod.instance_methods(@include_super).include? @method
end
def failure_message
["Expected #{@mod} to have instance method '#{@method.to_s}'",
"but it does not"]
end
def negative_failure_message
["Expected #{@mod} NOT to have instance method '#{@method.to_s}'",
"but it does"]
end
end
class Object
def have_instance_method(method, include_super=true)
HaveInstanceMethodMatcher.new method, include_super
end
end
|