Sha256: 5f61f0b0364902f5f1c8346fc17e588322fb200ee6b28ed676e861dae47fa089

Contents?: true

Size: 911 Bytes

Versions: 1

Compression:

Stored size: 911 Bytes

Contents

require 'minitest_helper'

describe Asynchronic::TransparentProxy do

  it 'Transparent' do
    proxy = Asynchronic::TransparentProxy.new 1

    proxy.must_equal 1
    (proxy + 1).must_equal 2
    proxy.class.must_equal Fixnum
    proxy.inspect.must_equal 1.inspect
    proxy.methods.must_equal proxy.proxy_methods | 1.methods
  end
  
  it 'Proxy methods' do
    proxy = Asynchronic::TransparentProxy.new 1
    
    proxy.must_be :proxy?
    proxy.proxy_class.must_equal Asynchronic::TransparentProxy
    proxy.proxy_inspect.must_match /#<Asynchronic::TransparentProxy @object=1>/
    proxy.proxy_methods.must_include_all [:__send__, :object_id, :tap]
    proxy.must_respond_to :proxy_respond_to?
  end

  it 'Subclass' do
    class NumberProxy < Asynchronic::TransparentProxy
      def to_letters
        'one'
      end
    end

    proxy = NumberProxy.new 1
    proxy.to_letters.must_equal 'one' 
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
asynchronic-0.2.0 spec/transparent_proxy_spec.rb