Skip to content

Commit

Permalink
define_method should modify the visibility of an UnboundMethod.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Sep 14, 2016
1 parent 6ce5e55 commit 70d1fc2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/ruby/core/module/define_method_spec.rb
Expand Up @@ -69,6 +69,23 @@ def test_method
@class.another_test_method.should == :foo
end
end

it "sets the new method's visibility to the current frame's visibility" do
foo = Class.new do
def ziggy
'piggy'
end
private :ziggy

# make sure frame visibility is public
public

define_method :piggy, instance_method(:ziggy)
end

lambda { foo.new.ziggy }.should raise_error(NoMethodError)
foo.new.piggy.should == 'piggy'
end
end

describe "Module#define_method when name is not a special private name" do
Expand Down

0 comments on commit 70d1fc2

Please sign in to comment.