Sha256: 31b480e8f3ca3172600ea135d97d95401542d5cc81d988ff0eb9a0d29298349a
Contents?: true
Size: 954 Bytes
Versions: 1
Compression:
Stored size: 954 Bytes
Contents
require 'kintama' require_relative '../lib/socketlogger' require 'pry' context 'Logger' do setup do @topic = 'logging' @publisher = Logger.new 4000, :tcp, @topic @message = 'sike!' end it 'should publish to a socket and return a number equal to length of message + length of topic + 1' do sent = @publisher.log @message characters_sent = @message.length + @topic.length + 1 assert_equal characters_sent, sent end end context 'Receiver' do setup do @publisher = Logger.new 4000, :tcp, 'worker' @subscriber = EZMQ::Subscriber.new :bind, port: 4000, topic: 'worker' @message = 'sike!' Thread.new do loop do @publisher.log @message end end end it 'should receive messages' do messages = [] topics = [] 1000.times do message, topic = @subscriber.receive messages << message topics << topic end assert_equal 1000, messages.size end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
socketlogger-0.0.2 | tests/socketlogger.rb |