Sha256: 657e026f83d39181275f0cd1c3318fedd1035f6198fc273ade6bee0dcbc22e69
Contents?: true
Size: 1013 Bytes
Versions: 1
Compression:
Stored size: 1013 Bytes
Contents
require 'spec_helper' require production_code describe Milight::Commander do let(:socket) { instance_double(UDPSocket) } let(:ip_address) { '127.0.0.1' } let(:port) { 8080 } subject { described_class.new ip_address, port } before do allow(UDPSocket).to receive(:new).and_return(socket) allow(socket).to receive(:close) end describe '#send_command' do it 'sends the given bytes' do payload = [0x42, 0x00, 0x55].pack('C*') expect(socket).to receive(:send).with(payload, 0, ip_address, port) subject.send_command 0x42 end it 'sends the given argument if one is given' do payload = [0x42, 0x01, 0x55].pack('C*') expect(socket).to receive(:send).with(payload, 0, ip_address, port) subject.send_command 0x42, 0x01 end end describe '#command_delay' do it 'pauses for 100 milliseconds' do before = Time.now subject.command_delay after = Time.now expect(after - before).to be > 0.1 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
milight-easybulb-1.0.0 | spec/milight/commander_spec.rb |