From 583dcca88e7525176e0ac65927d0563a95cf0d46 Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Freeman <the@jeffreyfreeman.me> Date: Mon, 7 Aug 2023 15:41:30 -0400 Subject: [PATCH] Added test for IGateTcp.close --- spec/apex/igate_tcp_spec.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/spec/apex/igate_tcp_spec.rb b/spec/apex/igate_tcp_spec.rb index 342b673..c95d87a 100644 --- a/spec/apex/igate_tcp_spec.rb +++ b/spec/apex/igate_tcp_spec.rb @@ -1,5 +1,6 @@ require_relative '../../lib/apex/igate_tcp' require_relative '../../lib/apex/frame' +require_relative '../../lib/apex/app_info' DECODED_FRAME_IGATE = Apex::Frame::Frame.new( Apex::Frame::Entity.from_raw('W2GMD-1'), @@ -17,7 +18,7 @@ describe Apex::IGateTcp do describe ".connect" do context "When attempting to connect to an igate" do it "The correct login message is sent" do - expect(aprsis_socket).to receive(:puts).with("user WI2ARD pass 17582 vers APEX 1.0.5\r\n") + expect(aprsis_socket).to receive(:puts).with("user WI2ARD pass 17582 vers APEX #{Apex::VERSION}\r\n") igate_tcp.connect(aprsis_socket_override: aprsis_socket) end end @@ -34,7 +35,7 @@ describe Apex::IGateTcp do end end describe ".write" do - context "Given a a valid Frame" do + context "Given a valid Frame" do it "correctly encodes and sends the frame" do allow(aprsis_socket).to receive(:puts) igate_tcp.connect(aprsis_socket_override: aprsis_socket) @@ -44,4 +45,15 @@ describe Apex::IGateTcp do end end end + describe ".close" do + context "Given a connected IGateTcp" do + it "closes the socket when closing the IGate" do + allow(aprsis_socket).to receive(:puts) + igate_tcp.connect(aprsis_socket_override: aprsis_socket) + + expect(aprsis_socket).to receive(:close) + igate_tcp.close + end + end + end end -- GitLab