Sha256: f4ac6cfa8bcf462885591b1b18793c6fdde1f4e5e36ad8621877022fdf4472f0

Contents?: true

Size: 1.68 KB

Versions: 10

Compression:

Stored size: 1.68 KB

Contents

require "spec_helper"

describe Invoker::IPC::ClientHandler do
  let(:client_socket) { StringIO.new }
  let(:client) { Invoker::IPC::ClientHandler.new(client_socket) }

  describe "add command" do
    let(:message_object) { MM::Add.new(process_name: 'foo') }
    it "should run if read from socket" do
      invoker_commander.expects(:on_next_tick).with("foo")
      client_socket.string = message_object.encoded_message

      client.read_and_execute
    end
  end

  describe "remove command" do
    it "with specific signal" do
      message_object = MM::Remove.new(process_name: 'foo', signal: 'INT')
      invoker_commander.expects(:on_next_tick)
      client_socket.string = message_object.encoded_message

      client.read_and_execute
    end

    it "with default signal" do
      message_object = MM::Remove.new(process_name: 'foo')
      invoker_commander.expects(:on_next_tick)
      client_socket.string = message_object.encoded_message

      client.read_and_execute
    end
  end

  describe "add_http command" do
    let(:message_object) { MM::AddHttp.new(process_name: 'foo', port: 9000)}
    it "adds the process name and port to dns cache" do
      invoker_dns_cache.expects(:add).with('foo', 9000, nil)
      client_socket.string = message_object.encoded_message

     client.read_and_execute
    end
  end

  describe "add_http command with optional ip" do
    let(:message_object) { MM::AddHttp.new(process_name: 'foo', port: 9000, ip: '192.168.0.1')}
    it "adds the process name, port and host ip to dns cache" do
      invoker_dns_cache.expects(:add).with('foo', 9000, '192.168.0.1')
      client_socket.string = message_object.encoded_message

     client.read_and_execute
    end
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
itrg-invoker-1.6.1 spec/invoker/ipc/client_handler_spec.rb
itrg-invoker-1.6.0 spec/invoker/ipc/client_handler_spec.rb
invoker-1.5.8 spec/invoker/ipc/client_handler_spec.rb
invoker-1.5.7 spec/invoker/ipc/client_handler_spec.rb
invoker-1.5.6 spec/invoker/ipc/client_handler_spec.rb
invoker-1.5.5 spec/invoker/ipc/client_handler_spec.rb
invoker-1.5.4 spec/invoker/ipc/client_handler_spec.rb
invoker-1.5.3 spec/invoker/ipc/client_handler_spec.rb
meepo-1.5.2 spec/invoker/ipc/client_handler_spec.rb
invoker-1.5.1 spec/invoker/ipc/client_handler_spec.rb