mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@83063a3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1e658d45e1
commit
3fa5bd38af
494 changed files with 4133 additions and 3109 deletions
|
@ -488,7 +488,7 @@ describe "A nested method definition" do
|
|||
DefSpecNested.should_not have_instance_method :body_method
|
||||
end
|
||||
|
||||
it "defines methods as public by default" do
|
||||
it "creates an instance method inside Class.new" do
|
||||
cls = Class.new do
|
||||
def do_def
|
||||
def new_def
|
||||
|
@ -500,6 +500,41 @@ describe "A nested method definition" do
|
|||
obj = cls.new
|
||||
obj.do_def
|
||||
obj.new_def.should == 1
|
||||
|
||||
cls.new.new_def.should == 1
|
||||
|
||||
-> { Object.new.new_def }.should raise_error(NoMethodError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "A method definition always resets the visibility to public for nested definitions" do
|
||||
it "in Class.new" do
|
||||
cls = Class.new do
|
||||
private
|
||||
def do_def
|
||||
def new_def
|
||||
1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
obj = cls.new
|
||||
-> { obj.do_def }.should raise_error(NoMethodError, /private/)
|
||||
obj.send :do_def
|
||||
obj.new_def.should == 1
|
||||
|
||||
cls.new.new_def.should == 1
|
||||
|
||||
-> { Object.new.new_def }.should raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
it "at the toplevel" do
|
||||
obj = Object.new
|
||||
-> { obj.toplevel_define_other_method }.should raise_error(NoMethodError, /private/)
|
||||
toplevel_define_other_method
|
||||
nested_method_in_toplevel_method.should == 42
|
||||
|
||||
Object.new.nested_method_in_toplevel_method.should == 42
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue