Sha256: f513cf918da0eff7a3e3f919aa477ea1afa505b4539eedf04afed115f6455d3f

Contents?: true

Size: 949 Bytes

Versions: 4

Compression:

Stored size: 949 Bytes

Contents

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

describe SPNet::ParamOutPort do
  before :each do
    @value = 0
    
    set_value_handler = lambda do |value|
      return @value = value
    end
    
    get_value_handler = lambda do
      return @value
    end
    
    @out_port = SPNet::ParamOutPort.new
    @in_port = SPNet::ParamInPort.new :get_value_handler => get_value_handler, :set_value_handler => set_value_handler
  end

  describe '#set_value' do
    it 'should pass the given value through ParamInPort#set_value' do
      @out_port.set_link Link.new(:to => @in_port, :from => @out_port)
      @out_port.set_value 5
      @value.should eq(5)
    end
  end
  
  describe '#get_value' do
    it "should return the value from each linked port's ParamInPort#get_value" do
      @value = 7
      @out_port.set_link Link.new(:to => @in_port, :from => @out_port)
      @out_port.get_value.should eq(7)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spnet-0.1.8 spec/ports/param_out_port_spec.rb
spnet-0.1.7 spec/ports/param_out_port_spec.rb
spnet-0.1.6 spec/ports/param_out_port_spec.rb
spnet-0.1.5 spec/ports/param_out_port_spec.rb