Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

50 lines (44 sloc) 1.419 kb
require File.expand_path(File.join(File.dirname(__FILE__), '../../../test_helper'))
require 'einhorn'
class InterfaceTest < Test::Unit::TestCase
include Einhorn::Command
context "when a command is received" do
should "call 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
context "when an unrecognized command is received" do
should "call 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
context "when a worker ack is received" do
should "register 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
Jump to Line
Something went wrong with that request. Please try again.