Sha256: 718d70530e8d77bbbd08489beac41a8203f1e07502784595b63206be14109eb2

Contents?: true

Size: 767 Bytes

Versions: 3

Compression:

Stored size: 767 Bytes

Contents

$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'erlectricity'
require 'rubygems'
require 'test/unit'
require 'test/spec'

class Test::Unit::TestCase
  
  def run_erl(code)
    cmd = %Q{erl -noshell -eval "A = #{code.split.join(' ')}, io:put_chars(A)." -s erlang halt}
    `#{cmd}`
  end
  
  def encode_packet(code)
    bin = run_erl("term_to_binary(#{code})")
    [bin.length, bin].pack("Na#{bin.length}")
  end
  
  def word_length
    (1.size * 8) - 2
  end
end

class FakePort < Erlectricity::Port
  attr_reader :sent
  attr_reader :terms
  
  def initialize(*terms)
    @terms = terms
    @sent = []
    super(StringIO.new(""), StringIO.new(""))
  end

  def send(term)
    sent << term
  end
  
  private
  def read_from_input
    @terms.shift
  end
end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
mojombo-erlectricity-0.2.1 test/test_helper.rb
tmm1-erlectricity-0.2.1 test/test_helper.rb
erlectricity-0.2.1 test/test_helper.rb