spec/mqtt_client_spec.rb in mqtt-0.3.0 vs spec/mqtt_client_spec.rb in mqtt-0.3.1
- old
+ new
@@ -734,9 +734,16 @@
client.instance_variable_set('@last_pingreq', Time.at(0))
expect(client).to receive(:ping).once
client.send(:receive_packet)
end
+ it "should update last_ping_response when receiving a Pingresp" do
+ allow(MQTT::Packet).to receive(:read).and_return MQTT::Packet::Pingresp.new
+ client.instance_variable_set '@last_ping_response', Time.at(0)
+ client.send :receive_packet
+ expect(client.last_ping_response).to be_within(1).of Time.now
+ end
+
it "should close the socket if there is an exception" do
expect(socket).to receive(:close).once
allow(MQTT::Packet).to receive(:read).and_raise(MQTT::Exception)
client.send(:receive_packet)
end