Sha256: c5316603e240fb3c86ecac06f0774a89fc4d2d412a79184b289bc588a7c85ddc

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require File.dirname(__FILE__) + '/../lib/drbproxy'

describe DRbProxy do
  before(:all) do
    @server_pid = fork do 
      class TestProxy
        attr_reader :param
        
        CONSTANT = 'constant'
        
        def initialize(param)
          @param = param
        end
        
        def instance_method
          'instance method'
        end

        def self.klass_method
          'klass method'
        end

        class Inner
          CONSTANT = 'inner constant'
          def instance_method
            'inner instance method'
          end

          def self.klass_method
            'inner klass method'
          end
        end
      end
      require File.dirname(__FILE__) + '/../lib/drbproxy/server'
    end
    server = DRbObject.new_with_uri(DRbProxy::DRB_URI)
    sleep(0.1) until server_ready?(server)
  end
  
  after(:all) do
    Process.kill(Signal.list['TERM'], @server_pid)
  end
  
  def server_ready?(server)
    begin
      server.ready?
    rescue Exception#DRb::DRbUnknownError
      false
    end
  end
  
  it "should do something" do
    class TestProxy < DRbProxy::DRbProxyClass
    end

    test = TestProxy.new('test')
    test.instance_method.should == 'instance method'
    test.param.should == 'test'
    TestProxy.klass_method == 'klass method'
    TestProxy::CONSTANT.should == 'constant'
    inner = TestProxy::Inner.new
    inner.instance_method.should == 'inner instance method'
    TestProxy::Inner.klass_method.should == 'inner klass method'
    TestProxy::Inner::CONSTANT.should == 'inner constant'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
drbproxy-0.1.0 spec/drbproxy_spec.rb