summaryrefslogtreecommitdiff
path: root/spec/ruby/core/unboundmethod/private_spec.rb
blob: 8ea50bb5d425f4299e003245f64dfa67441e9702 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

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
    end

    it "returns false when the method is protected" do
      obj = UnboundMethodSpecs::Methods.new
      obj.method(:my_protected_method).unbind.private?.should == false
    end

    it "returns true when the method is private" do
      obj = UnboundMethodSpecs::Methods.new
      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