spec/kamerling/logging_spec.rb in kamerling-0.0.1 vs spec/kamerling/logging_spec.rb in kamerling-0.0.2
- old
+ new
@@ -6,21 +6,21 @@
let(:stream) { StringIO.new }
let(:tcp_server) { Server::TCP.new addr: Addr['localhost', 1981, :TCP] }
let(:udp_server) { Server::UDP.new addr: Addr['localhost', 1979, :UDP] }
before do
- Logging.log_to logger: logger
+ Logging.log_to logger
tcp_server.start
udp_server.start
end
after do
tcp_server.stop
udp_server.stop
end
- describe '.new' do
+ describe '.log_to' do
it 'logs TCP server starts' do
logged.must_include 'start localhost:1981 (TCP)'
end
it 'logs TCP server stops' do
@@ -66,8 +66,15 @@
udp_client = UDPSocket.new
udp_client.send 'PING', 0, *udp_server.addr
udp_addr = Addr['127.0.0.1', udp_client.addr[1], :UDP]
run_all_threads
logged.must_include "received #{udp_addr} PING"
+ end
+
+ it 'logs packet dispatches' do
+ server = UDPSocket.new.tap { |s| s.bind '127.0.0.1', 0 }
+ addr = Addr[server.addr[3], server.addr[1], :UDP]
+ NetDispatcher.dispatch addr, 'PING'
+ logged.must_include "sent #{addr} PING"
end
end
end end