Sha256: 8005c890ec1b6231c88da4710f927ae044c704b1e3669c56f796330294e2daf8

Contents?: true

Size: 831 Bytes

Versions: 2

Compression:

Stored size: 831 Bytes

Contents

require_relative "../test_helper"
require_relative "../../lib/message_queue/serializers/plain"
require_relative "../../lib/message_queue/adapters/memory"

class MemoryTest < Test::Unit::TestCase
  def test_connected?
    connection = MessageQueue::Adapters::Memory.new_connection MessageQueue::Serializers::Plain
    assert !connection.connected?
  end

  def test_pub_sub
    connection = MessageQueue::Adapters::Memory.new_connection MessageQueue::Serializers::Plain
    connection.with_connection do |conn|
      producer = conn.new_producer
      consumer = conn.new_consumer
      consumer.subscribe(:producer => producer)

      msg = Time.now.to_s
      producer.publish msg, :type => :time

      message = consumer.queue.pop
      assert_equal :time, message.type
      assert_equal msg, message.payload
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
message_queue-0.1.1 test/adapters/memory_test.rb
message_queue-0.1.0 test/adapters/memory_test.rb