Sha256: b6a9eb4c09bd02375a36dc6ed32e7fceb23892413a3548f84d094de7b0409043
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
require 'spec_helper' module LIFX describe Transport::UDP, integration: true do subject(:udp) { Transport::UDP.new(host, port) } let(:host) { 'localhost' } let(:message) { double } let(:port) { 45_828 } describe '#write' do let(:payload) { double } it 'writes a Message to specified host' do expect(message).to receive(:pack).and_return(payload) expect_any_instance_of(UDPSocket).to receive(:send) .with(payload, 0, host, port) udp.write(message) end end describe '#listen' do let(:raw_message) { 'some binary data' } let(:socket) { UDPSocket.new } let(:messages) { [] } before do udp.add_observer(self, :message_received) do |message: nil, ip: nil, transport: nil| messages << message end udp.listen end it 'listens to the specified socket data, unpacks it and notifies observers' do expect(Message).to receive(:unpack) .with(raw_message) .and_return(message) socket.send(raw_message, 0, host, port) wait { expect(messages).to include(message) } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lifx-0.4.11 | spec/transport/udp_spec.rb |
lifx-0.4.10 | spec/transport/udp_spec.rb |
lifx-0.4.8 | spec/transport/udp_spec.rb |