diff options
Diffstat (limited to 'spec/ruby/core/module')
| -rw-r--r-- | spec/ruby/core/module/alias_method_spec.rb | 12 | ||||
| -rw-r--r-- | spec/ruby/core/module/refine_spec.rb | 11 |
2 files changed, 23 insertions, 0 deletions
diff --git a/spec/ruby/core/module/alias_method_spec.rb b/spec/ruby/core/module/alias_method_spec.rb index 662e91011f..571191fe29 100644 --- a/spec/ruby/core/module/alias_method_spec.rb +++ b/spec/ruby/core/module/alias_method_spec.rb @@ -42,6 +42,18 @@ describe "Module#alias_method" do @object.was_private_one.should == 1 end + it "handles aliasing a method only present in a refinement" do + c = @class + Module.new do + refine c do + def uno_refined_method + end + alias_method :double_refined_method, :uno_refined_method + instance_method(:uno_refined_method).should == instance_method(:double_refined_method) + end + end + end + it "fails if origin method not found" do -> { @class.make_alias :ni, :san }.should raise_error(NameError) { |e| # a NameError and not a NoMethodError diff --git a/spec/ruby/core/module/refine_spec.rb b/spec/ruby/core/module/refine_spec.rb index 66c19ddb66..81dd492362 100644 --- a/spec/ruby/core/module/refine_spec.rb +++ b/spec/ruby/core/module/refine_spec.rb @@ -704,6 +704,17 @@ describe "Module#refine" do -> { [1,2].orig_count }.should raise_error(NoMethodError) end + it "and instance_methods returns a list of methods including those of the refined module" do + methods = Array.instance_methods + methods_2 = [] + Module.new do + refine Array do + methods_2 = instance_methods + end + end + methods.should == methods_2 + end + # Refinements are inherited by module inclusion. # That is, using activates all refinements in the ancestors of the specified module. # Refinements in a descendant have priority over refinements in an ancestor. |
