-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathmethod_consolidator_test.rb
81 lines (65 loc) · 2.52 KB
/
method_consolidator_test.rb
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require "test_helper"
describe Casting::MethodConsolidator, "#methods" do
let(:client) {
object = test_person.extend(Casting::Client, Casting::MissingMethodClient, Casting::MethodConsolidator)
object.cast_as(TestPerson::Greeter)
object
}
it "returns all instance methods including private from the object and it's delegates" do
assert_includes(client.methods(true), :psst)
end
it "returns all public instance methods from the object and it's delegates" do
refute_includes(client.methods(false), :psst)
end
it "returns all protected instance methods from the object and it's delegates" do
assert_includes(client.methods(true), :hey)
end
end
describe Casting::MethodConsolidator, "#public_methods" do
let(:client) {
object = test_person.extend(Casting::Client, Casting::MissingMethodClient, Casting::MethodConsolidator)
object.cast_as(TestPerson::Greeter)
object
}
it "returns all public_methods and those from it's delegates" do
assert_includes(client.public_methods, :greet)
end
it "excludes all protected_methods and those from it's delegates" do
refute_includes(client.public_methods, :hey)
end
it "excludes all private_methods from the object and it's delegates" do
refute_includes(client.public_methods, :psst)
end
end
describe Casting::MethodConsolidator, "#protected_methods" do
let(:client) {
object = test_person.extend(Casting::Client, Casting::MissingMethodClient, Casting::MethodConsolidator)
object.cast_as(TestPerson::Greeter)
object
}
it "excludes all public_methods and those from it's delegates" do
refute_includes(client.protected_methods, :greet)
end
it "returns all protected_methods and those from it's delegates" do
assert_includes(client.protected_methods, :hey)
end
it "excludes all private_methods from the object and it's delegates" do
refute_includes(client.protected_methods, :psst)
end
end
describe Casting::MethodConsolidator, "#private_methods" do
let(:client) {
object = test_person.extend(Casting::Client, Casting::MissingMethodClient, Casting::MethodConsolidator)
object.cast_as(TestPerson::Greeter)
object
}
it "excludes all public_methods and those from it's delegates" do
refute_includes(client.private_methods, :greet)
end
it "excludes all protected_methods and those from it's delegates" do
refute_includes(client.private_methods, :hey)
end
it "excludes all private_methods from the object and it's delegates" do
assert_includes(client.private_methods, :psst)
end
end