Skip to content

Commit

Permalink
Add a spec for #4155.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Sep 14, 2016
1 parent 994a8a2 commit 3b556f6
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 @@ -42,6 +42,23 @@ def test_method
child.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" do
Expand Down

0 comments on commit 3b556f6

Please sign in to comment.