diff options
author | Radosław Bułat <radek.bulat@gmail.com> | 2020-12-18 19:17:57 +0100 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2020-12-19 18:19:49 +0900 |
commit | eb8ea336d33af7e1dec4c17964c671c33cf75ce1 (patch) | |
tree | 0d093c71f75825dbc5ebfcb3b74bb6fad6250bf9 /spec/ruby/core/module/shared | |
parent | 8148f88b92a6b8d850b991afe74fb0d0f9c11887 (diff) |
Feature 17314: allow to pass array to public, protected and private methods
Diffstat (limited to 'spec/ruby/core/module/shared')
-rw-r--r-- | spec/ruby/core/module/shared/set_visibility.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/ruby/core/module/shared/set_visibility.rb b/spec/ruby/core/module/shared/set_visibility.rb index a04b1a54a0..9f31e230ca 100644 --- a/spec/ruby/core/module/shared/set_visibility.rb +++ b/spec/ruby/core/module/shared/set_visibility.rb @@ -6,6 +6,40 @@ describe :set_visibility, shared: true do end describe "with argument" do + describe "one or more arguments" do + it "sets visibility of given method names" do + visibility = @method + old_visibility = [:protected, :private].find {|vis| vis != visibility } + + mod = Module.new { + send old_visibility + def test1() end + def test2() end + send visibility, :test1, :test2 + } + mod.should send(:"have_#{visibility}_instance_method", :test1, false) + mod.should send(:"have_#{visibility}_instance_method", :test2, false) + end + end + + ruby_version_is "3.0" do + describe "array as a single argument" do + it "sets visibility of given method names" do + visibility = @method + old_visibility = [:protected, :private].find {|vis| vis != visibility } + + mod = Module.new { + send old_visibility + def test1() end + def test2() end + send visibility, [:test1, :test2] + } + mod.should send(:"have_#{visibility}_instance_method", :test1, false) + mod.should send(:"have_#{visibility}_instance_method", :test2, false) + end + end + end + it "does not clone method from the ancestor when setting to the same visibility in a child" do visibility = @method parent = Module.new { |