Skip to content

Commit

Permalink
Merge pull request #1033 from AI-Mozi/add_specs_for_method_pub_priv_prot
Browse files Browse the repository at this point in the history
Change `#public?`, `#protected?` and `#private?` specs for `Method`
  • Loading branch information
andrykonchin authored May 17, 2023
2 parents 2494bf8 + e8e2c0d commit a33e563
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 12 deletions.
11 changes: 9 additions & 2 deletions core/method/private_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

ruby_version_is "3.1"..."3.2" do
describe "Method#private?" do
describe "Method#private?" do
ruby_version_is "3.1"..."3.2" do
it "returns false when the method is public" do
obj = MethodSpecs::Methods.new
obj.method(:my_public_method).private?.should == false
Expand All @@ -18,4 +18,11 @@
obj.method(:my_private_method).private?.should == true
end
end

ruby_version_is "3.2" do
it "has been removed" do
obj = MethodSpecs::Methods.new
obj.method(:my_private_method).should_not.respond_to?(:private?)
end
end
end
11 changes: 9 additions & 2 deletions core/method/protected_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

ruby_version_is "3.1"..."3.2" do
describe "Method#protected?" do
describe "Method#protected?" do
ruby_version_is "3.1"..."3.2" do
it "returns false when the method is public" do
obj = MethodSpecs::Methods.new
obj.method(:my_public_method).protected?.should == false
Expand All @@ -18,4 +18,11 @@
obj.method(:my_private_method).protected?.should == false
end
end

ruby_version_is "3.2" do
it "has been removed" do
obj = MethodSpecs::Methods.new
obj.method(:my_protected_method).should_not.respond_to?(:protected?)
end
end
end
11 changes: 9 additions & 2 deletions core/method/public_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

ruby_version_is "3.1"..."3.2" do
describe "Method#public?" do
describe "Method#public?" do
ruby_version_is "3.1"..."3.2" do
it "returns true when the method is public" do
obj = MethodSpecs::Methods.new
obj.method(:my_public_method).public?.should == true
Expand All @@ -18,4 +18,11 @@
obj.method(:my_private_method).public?.should == false
end
end

ruby_version_is "3.2" do
it "has been removed" do
obj = MethodSpecs::Methods.new
obj.method(:my_public_method).should_not.respond_to?(:public?)
end
end
end
11 changes: 9 additions & 2 deletions core/unboundmethod/private_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

ruby_version_is "3.1"..."3.2" do
describe "UnboundMethod#private?" do
describe "UnboundMethod#private?" do
ruby_version_is "3.1"..."3.2" do
it "returns false when the method is public" do
obj = UnboundMethodSpecs::Methods.new
obj.method(:my_public_method).unbind.private?.should == false
Expand All @@ -18,4 +18,11 @@
obj.method(:my_private_method).unbind.private?.should == true
end
end

ruby_version_is "3.2" do
it "has been removed" do
obj = UnboundMethodSpecs::Methods.new
obj.method(:my_private_method).unbind.should_not.respond_to?(:private?)
end
end
end
11 changes: 9 additions & 2 deletions core/unboundmethod/protected_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

ruby_version_is "3.1"..."3.2" do
describe "UnboundMethod#protected?" do
describe "UnboundMethod#protected?" do
ruby_version_is "3.1"..."3.2" do
it "returns false when the method is public" do
obj = UnboundMethodSpecs::Methods.new
obj.method(:my_public_method).unbind.protected?.should == false
Expand All @@ -18,4 +18,11 @@
obj.method(:my_private_method).unbind.protected?.should == false
end
end

ruby_version_is "3.2" do
it "has been removed" do
obj = UnboundMethodSpecs::Methods.new
obj.method(:my_protected_method).unbind.should_not.respond_to?(:protected?)
end
end
end
11 changes: 9 additions & 2 deletions core/unboundmethod/public_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

ruby_version_is "3.1"..."3.2" do
describe "UnboundMethod#public?" do
describe "UnboundMethod#public?" do
ruby_version_is "3.1"..."3.2" do
it "returns true when the method is public" do
obj = UnboundMethodSpecs::Methods.new
obj.method(:my_public_method).unbind.public?.should == true
Expand All @@ -18,4 +18,11 @@
obj.method(:my_private_method).unbind.public?.should == false
end
end

ruby_version_is "3.2" do
it "has been removed" do
obj = UnboundMethodSpecs::Methods.new
obj.method(:my_public_method).unbind.should_not.respond_to?(:public?)
end
end
end

0 comments on commit a33e563

Please sign in to comment.