File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,40 @@ def bar
44
44
} . should raise_error ( NoMethodError )
45
45
end
46
46
47
+ context 'called from own public method' do
48
+ before do
49
+ class << @receiver = Object . new
50
+ def call_protected_method
51
+ public_send :protected_method
52
+ end
53
+
54
+ def call_private_method
55
+ public_send :private_method
56
+ end
57
+
58
+ protected
59
+
60
+ def protected_method
61
+ raise 'Should not called'
62
+ end
63
+
64
+ private
65
+
66
+ def private_method
67
+ raise 'Should not called'
68
+ end
69
+ end
70
+ end
71
+
72
+ it "raises a NoMethodError if the method is protected" do
73
+ lambda { @receiver . call_protected_method } . should raise_error ( NoMethodError )
74
+ end
75
+
76
+ it "raises a NoMethodError if the method is private" do
77
+ lambda { @receiver . call_private_method } . should raise_error ( NoMethodError )
78
+ end
79
+ end
80
+
47
81
it "raises a NoMethodError if the named method is an alias of a private method" do
48
82
class KernelSpecs ::Foo
49
83
alias :aka :bar
Original file line number Diff line number Diff line change
1
+ fails:Kernel#public_send called from own public method raises a NoMethodError if the method is protected
You can’t perform that action at this time.
0 commit comments