blob: f433288057f71aa58a03f8a9699d98f7f34f7202 (
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
RSpec.describe HavePrivateMethodMatcher do
it "inherits from MethodMatcher" do
expect(HavePrivateMethodMatcher.new(:m)).to be_kind_of(MethodMatcher)
end
it "matches when mod has the private method" do
matcher = HavePrivateMethodMatcher.new :private_method
expect(matcher.matches?(HPMMSpecs)).to be_truthy
end
it "does not match when mod does not have the private method" do
matcher = HavePrivateMethodMatcher.new :another_method
expect(matcher.matches?(HPMMSpecs)).to be_falsey
end
it "provides a failure message for #should" do
matcher = HavePrivateMethodMatcher.new :some_method
matcher.matches?(HPMMSpecs)
expect(matcher.failure_message).to eq([
"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)
expect(matcher.negative_failure_message).to eq([
"Expected HPMMSpecs NOT to have private method 'private_method'",
"but it does"
])
end
end
|