Sha256: a56dec93445098cac94b4cc14802e9a7f7134d0544c63064b0587945ca4e74e7

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

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

describe SPNet::InPort do
  describe '.new' do
    it 'link should be nil' do
      port = InPort.new :matching_class => OutPort
      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
      in_port.set_link link
      in_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
      in_port.set_link link
      in_port.link.should eq(link)
      in_port.clear_link
      in_port.link.should be_nil
    end
  end
  
  describe '#linked?' do
    it 'should return false if port is not linked' do
      in_port = InPort.new(:matching_class => OutPort)
      in_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
      in_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/in_port_spec.rb
spnet-0.1.7 spec/core/in_port_spec.rb
spnet-0.1.6 spec/core/in_port_spec.rb
spnet-0.1.5 spec/core/in_port_spec.rb