Sha256: 3fdbedc994e976689ac893c869d338f40823bfce14605babe13833736cb351a0

Contents?: true

Size: 1.37 KB

Versions: 15

Compression:

Stored size: 1.37 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '../../../_lib'))

require 'einhorn'

class InterfaceTest < EinhornTestCase
  include Einhorn::Command

  describe "when a command is received" do
    it "calls that command" do
      conn = stub(:log_debug => nil)
      conn.expects(:write).once.with do |message|
        # Remove trailing newline
        message = message[0...-1]
        parsed = YAML.load(URI.unescape(message))
        parsed['message'] =~ /Welcome, gdb/
      end
      request = {
        'command' => 'ehlo',
        'user' => 'gdb'
      }
      Interface.process_command(conn, YAML.dump(request))
    end
  end

  describe "when an unrecognized command is received" do
    it "calls the unrecognized_command method" do
      conn = stub(:log_debug => nil)
      Interface.expects(:unrecognized_command).once
      request = {
        'command' => 'made-up',
      }
      Interface.process_command(conn, YAML.dump(request))
    end
  end

  describe "when a worker ack is received" do
    it "registers ack and close the connection" do
      conn = stub(:log_debug => nil)
      conn.expects(:close).once
      conn.expects(:write).never
      request = {
        'command' => 'worker:ack',
        'pid' => 1234
      }
      Einhorn::Command.expects(:register_manual_ack).once.with(1234)
      Interface.process_command(conn, YAML.dump(request))
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
einhorn-0.8.2 test/unit/einhorn/command/interface.rb
einhorn-0.7.4 test/unit/einhorn/command/interface.rb
einhorn-0.7.3 test/unit/einhorn/command/interface.rb
einhorn-0.7.2 test/unit/einhorn/command/interface.rb
einhorn-0.7.1 test/unit/einhorn/command/interface.rb
einhorn-0.7.0 test/unit/einhorn/command/interface.rb
einhorn-0.6.5 test/unit/einhorn/command/interface.rb
einhorn-0.6.4 test/unit/einhorn/command/interface.rb
einhorn-0.6.3 test/unit/einhorn/command/interface.rb
einhorn-0.6.2 test/unit/einhorn/command/interface.rb
einhorn-0.6.1 test/unit/einhorn/command/interface.rb
einhorn-0.6.0 test/unit/einhorn/command/interface.rb
einhorn-0.5.7 test/unit/einhorn/command/interface.rb
einhorn-0.5.6 test/unit/einhorn/command/interface.rb
einhorn-0.5.5 test/unit/einhorn/command/interface.rb