diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-29 16:08:16 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-29 16:08:16 +0000 |
commit | 3fa5bd38af50fb3d98de0ea51043d73f8d06a24b (patch) | |
tree | d473b71cc6925ee1e17727215e9f9a66e3f24802 /spec/ruby/core/module | |
parent | 1e658d45e1f8dbadab18f9c35b5cfb5a5fec98bf (diff) | |
download | ruby-3fa5bd38af50fb3d98de0ea51043d73f8d06a24b.tar.gz |
Update to ruby/spec@83063a3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/module')
-rw-r--r-- | spec/ruby/core/module/const_missing_spec.rb | 9 | ||||
-rw-r--r-- | spec/ruby/core/module/define_method_spec.rb | 25 | ||||
-rw-r--r-- | spec/ruby/core/module/eql_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/module/equal_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/module/equal_value_spec.rb | 2 |
5 files changed, 37 insertions, 3 deletions
diff --git a/spec/ruby/core/module/const_missing_spec.rb b/spec/ruby/core/module/const_missing_spec.rb index 24f2b49edc..c6143f2b4c 100644 --- a/spec/ruby/core/module/const_missing_spec.rb +++ b/spec/ruby/core/module/const_missing_spec.rb @@ -24,4 +24,13 @@ describe "Module#const_missing" do end end + it "is called regardless of visibility" do + klass = Class.new do + def self.const_missing(name) + "Found:#{name}" + end + private_class_method :const_missing + end + klass::Hello.should == 'Found:Hello' + end end diff --git a/spec/ruby/core/module/define_method_spec.rb b/spec/ruby/core/module/define_method_spec.rb index be0e2f0a0b..94995414b7 100644 --- a/spec/ruby/core/module/define_method_spec.rb +++ b/spec/ruby/core/module/define_method_spec.rb @@ -631,3 +631,28 @@ describe "Method#define_method when passed an UnboundMethod object" do @obj.method(:n).parameters.should == @obj.method(:m).parameters end end + +describe "Method#define_method when passed a Proc object" do + describe "and a method is defined inside" do + it "defines the nested method in the default definee where the Proc was created" do + prc = nil + t = Class.new do + prc = -> { + def nested_method_in_proc_for_define_method + 42 + end + } + end + + c = Class.new do + define_method(:test, prc) + end + + o = c.new + o.test + o.should_not have_method :nested_method_in_proc_for_define_method + + t.new.nested_method_in_proc_for_define_method.should == 42 + end + end +end diff --git a/spec/ruby/core/module/eql_spec.rb b/spec/ruby/core/module/eql_spec.rb index f8878d7f4e..9cb7bd1d24 100644 --- a/spec/ruby/core/module/eql_spec.rb +++ b/spec/ruby/core/module/eql_spec.rb @@ -3,5 +3,5 @@ require File.expand_path('../fixtures/classes', __FILE__) require File.expand_path('../shared/equal_value', __FILE__) describe "Module#eql?" do - it_behaves_like(:module_equal, :eql?) + it_behaves_like :module_equal, :eql? end diff --git a/spec/ruby/core/module/equal_spec.rb b/spec/ruby/core/module/equal_spec.rb index bc70a6277a..f5d12c541a 100644 --- a/spec/ruby/core/module/equal_spec.rb +++ b/spec/ruby/core/module/equal_spec.rb @@ -3,5 +3,5 @@ require File.expand_path('../fixtures/classes', __FILE__) require File.expand_path('../shared/equal_value', __FILE__) describe "Module#equal?" do - it_behaves_like(:module_equal, :equal?) + it_behaves_like :module_equal, :equal? end diff --git a/spec/ruby/core/module/equal_value_spec.rb b/spec/ruby/core/module/equal_value_spec.rb index 12494477f9..f8ecede3d8 100644 --- a/spec/ruby/core/module/equal_value_spec.rb +++ b/spec/ruby/core/module/equal_value_spec.rb @@ -3,5 +3,5 @@ require File.expand_path('../fixtures/classes', __FILE__) require File.expand_path('../shared/equal_value', __FILE__) describe "Module#==" do - it_behaves_like(:module_equal, :==) + it_behaves_like :module_equal, :== end |