Sha256: 6c6e6ee05d6dc2916858a82992740ed2eac64e55da48616ec55c92abfc9abb7c

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

require File.expand_path('../test_helper', __FILE__)

module Propono
  class ProponoTest < Minitest::Test

    def test_publish_calls_publisher_publish
      topic, message = "Foo", "Bar"
      Publisher.expects(:publish).with(topic, message, {})
      Propono.publish(topic, message)
    end

    def test_subscribe_by_queue_calls_subscribe
      topic = 'foobar'
      Subscriber.expects(:subscribe_by_queue).with(topic)
      Propono.subscribe_by_queue(topic)
    end

    def test_subscribe_by_post_calls_subscribe
      topic, endpoint = 'foo', 'bar'
      Subscriber.expects(:subscribe_by_post).with(topic, endpoint)
      Propono.subscribe_by_post(topic, endpoint)
    end

    def test_listen_to_queue_calls_queue_listener
      topic = 'foobar'
      QueueListener.expects(:listen).with(topic)
      Propono.listen_to_queue(topic)
    end

    def test_listen_to_udp_calls_udp_listener
      UdpListener.expects(:listen).with()
      Propono.listen_to_udp()
    end

    def test_listen_to_tcp_calls_tcp_listener
      TcpListener.expects(:listen).with()
      Propono.listen_to_tcp()
    end

    def test_proxy_udp_calls_listen
      UdpListener.expects(:listen).with()
      Propono.proxy_udp()
    end

    def test_proxy_udp_calls_publish_in_the_block
      topic = "foobar"
      message = "message"
      options = {id: "catdog"}
      Propono.stubs(:listen_to_udp).yields(topic, message, options)
      Publisher.expects(:publish).with(topic, message, options)
      Propono.proxy_udp
    end

    def test_proxy_tcp_calls_listen
      TcpListener.expects(:listen).with()
      Propono.proxy_tcp()
    end

    def test_proxy_tcp_calls_publish_in_the_block
      topic = "foobar"
      message = "message"
      options = {id: "catdog"}
      Propono.stubs(:listen_to_tcp).yields(topic, message, options)
      Publisher.expects(:publish).with(topic, message, options)
      Propono.proxy_tcp
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
propono-0.9.1 test/propono_test.rb
propono-0.9.0 test/propono_test.rb