blob: e63a9a3c2f98555b17227dd1b7260909373a8e5f (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
class HPMMSpecs
def self.private_method
end
private_class_method :private_method
end
describe HavePrivateMethodMatcher do
it "inherits from MethodMatcher" do
HavePrivateMethodMatcher.new(:m).should be_kind_of(MethodMatcher)
end
it "matches when mod has the private method" do
matcher = HavePrivateMethodMatcher.new :private_method
matcher.matches?(HPMMSpecs).should be_true
end
it "does not match when mod does not have the private method" do
matcher = HavePrivateMethodMatcher.new :another_method
matcher.matches?(HPMMSpecs).should be_false
end
it "provides a failure message for #should" do
matcher = HavePrivateMethodMatcher.new :some_method
matcher.matches?(HPMMSpecs)
matcher.failure_message.should == [
"Expected HPMMSpecs to have private method 'some_method'",
"but it does not"
]
end
it "provides a failure message for #should_not" do
matcher = HavePrivateMethodMatcher.new :private_method
matcher.matches?(HPMMSpecs)
matcher.negative_failure_message.should == [
"Expected HPMMSpecs NOT to have private method 'private_method'",
"but it does"
]
end
end
|