Skip to content

Commit

Permalink
Add a failing spec for a case then protected method called from publi…
Browse files Browse the repository at this point in the history
…c_send in own method (#3681)

* Add specs to call public_send via own public method

ref: https://bugs.ruby-lang.org/issues/7499

* Add a failing tag for above

* Adjust style with classic lambda syntax

ref: #3681 (comment)
kachick authored and brixen committed Jul 22, 2016
1 parent f0373ac commit 8721492
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions spec/ruby/core/kernel/public_send_spec.rb
Original file line number Diff line number Diff line change
@@ -44,6 +44,40 @@ def bar
}.should raise_error(NoMethodError)
end

context 'called from own public method' do
before do
class << @receiver = Object.new
def call_protected_method
public_send :protected_method
end

def call_private_method
public_send :private_method
end

protected

def protected_method
raise 'Should not called'
end

private

def private_method
raise 'Should not called'
end
end
end

it "raises a NoMethodError if the method is protected" do
lambda { @receiver.call_protected_method }.should raise_error(NoMethodError)
end

it "raises a NoMethodError if the method is private" do
lambda { @receiver.call_private_method }.should raise_error(NoMethodError)
end
end

it "raises a NoMethodError if the named method is an alias of a private method" do
class KernelSpecs::Foo
alias :aka :bar
1 change: 1 addition & 0 deletions spec/tags/ruby/core/kernel/public_send_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Kernel#public_send called from own public method raises a NoMethodError if the method is protected

0 comments on commit 8721492

Please sign in to comment.