Skip to content

Commit

Permalink
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/ruby/core/module/define_method_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 70d1fc2

Please sign in to comment.