Sha256: f285c50a93392ca21fbb5f397f7e42248d372db3fe581f5a15e54eb1dd3ab002

Contents?: true

Size: 1.19 KB

Versions: 29

Compression:

Stored size: 1.19 KB

Contents

require File.expand_path('../spec_helper', __FILE__)

require 'asir'
require 'asir/transport/demux'

require 'asir/transport/buffer'

describe "ASIR::Transport::Demux" do
  attr_accessor :transport, :object

  before(:each) do
    self.transport = ASIR::Transport::Demux.new
    self.transport.transport_proc = lambda do | t, m |
      m.arguments[0].size % 2 == 0 ? t[:even] : t[:odd]
    end
    self.transport[:even] = ASIR::Transport::Buffer.new(:transport => ASIR::Transport::Local.new)
    self.transport[:even].pause!
    self.transport[:odd]  = ASIR::Transport::Buffer.new(:transport => ASIR::Transport::Local.new)
    self.transport[:odd].pause!
    self.object = ASIR::Test::TestObject.new(self)
    object.class.asir.transport = transport
  end

  it 'should direct even-sized arg[0] Arrays to transport[:even].' do
    result = object.asir.return_argument [ 1, 2 ]
    transport[:even].size.should == 1
    transport[:odd].size.should == 0
    result.should == nil
  end

  it 'should direct odd-sized arg[0] Arrays to transport[:odd].' do
    result = object.asir.return_argument [ 1, 2, 3 ]
    transport[:even].size.should == 0
    transport[:odd].size.should == 1
    result.should == nil
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
asir-1.2.10 spec/demux_spec.rb
asir-1.2.9 spec/demux_spec.rb
asir-1.2.8 spec/demux_spec.rb
asir-1.2.7 spec/demux_spec.rb
asir-1.2.6 spec/demux_spec.rb
asir-1.2.5 spec/demux_spec.rb
asir-1.2.3 spec/demux_spec.rb
asir-1.2.2 spec/demux_spec.rb
asir-1.2.1 spec/demux_spec.rb
asir-1.2.0 spec/demux_spec.rb
asir-1.1.12 spec/demux_spec.rb
asir-1.1.11 spec/demux_spec.rb
asir-1.1.10 spec/demux_spec.rb
asir-1.1.9 spec/demux_spec.rb
asir-1.1.8 spec/demux_spec.rb
asir-1.1.7 spec/demux_spec.rb
asir-1.1.6 spec/demux_spec.rb
asir-1.1.5 spec/demux_spec.rb
asir-1.1.4 spec/demux_spec.rb
asir-1.1.3 spec/demux_spec.rb