HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/src/ruby-2.7.4/spec/ruby/library/weakref/send_spec.rb
require_relative '../../spec_helper'
require 'weakref'

describe "WeakRef#__send__" do
  module WeakRefSpecs
    class << self
      def delegated_method
        :result
      end

      def protected_method
        :result
      end
      protected :protected_method

      def private_method
        :result
      end
      private :private_method
    end
  end

  it "delegates to public methods of the weakly-referenced object" do
    wr = WeakRef.new(WeakRefSpecs)
    wr.delegated_method.should == :result
  end

  it "delegates to protected methods of the weakly-referenced object" do
    wr = WeakRef.new(WeakRefSpecs)
    -> { wr.protected_method }.should raise_error(NameError)
  end

  it "does not delegate to private methods of the weakly-referenced object" do
    wr = WeakRef.new(WeakRefSpecs)
    -> { wr.private_method }.should raise_error(NameError)
  end
end