Sha256: 46f2d282a618bd90c570201f9bf38a10ab1cfcb36b6665ad3ed84207670a0d85

Contents?: true

Size: 1.36 KB

Versions: 4

Compression:

Stored size: 1.36 KB

Contents

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

describe SPNet::OutPort do
  describe '.new' do
    it 'link should be nil' do
      port = OutPort.new :matching_class => InPort
      port.link.should be_nil
    end
  end

  describe '#set_link' do
    it 'should set link to given link' do
      in_port = InPort.new(:matching_class => OutPort)
      out_port = OutPort.new(:matching_class => InPort)
      link = Link.new :from => out_port, :to => in_port
      out_port.set_link link
      out_port.link.should eq(link)
    end
  end
  
  describe '#clear_link' do
    it 'should set link to nil' do
      in_port = InPort.new(:matching_class => OutPort)
      out_port = OutPort.new(:matching_class => InPort)
      link = Link.new :from => out_port, :to => in_port
      out_port.set_link link
      out_port.link.should eq(link)
      out_port.clear_link
      out_port.link.should be_nil
    end
  end
  
  describe '#linked?' do
    it 'should return false if port is not linked' do
      out_port = OutPort.new(:matching_class => InPort)
      out_port.linked?.should be_false
    end
    
    it 'should return true if port is linked' do
      in_port = InPort.new(:matching_class => OutPort)
      out_port = OutPort.new(:matching_class => InPort)
      Link.new(:from => out_port, :to => in_port).activate
      out_port.linked?.should be_true
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spnet-0.1.8 spec/core/out_port_spec.rb
spnet-0.1.7 spec/core/out_port_spec.rb
spnet-0.1.6 spec/core/out_port_spec.rb
spnet-0.1.5 spec/core/out_port_spec.rb