Sha256: d9ef70d8cda983baaff796c6930acfd59701ef41fb5d3e8d79c3688afae11b3c

Contents?: true

Size: 990 Bytes

Versions: 7

Compression:

Stored size: 990 Bytes

Contents

require 'spec_helper'

require 'logstasher/device/udp'

describe LogStasher::Device::UDP do

  let(:default_options) {{
                           'hostname' => '127.0.0.1',
                           'port' => 31459
                         }}

  it 'has default options' do
    device = LogStasher::Device::UDP.new
    expect(device.options).to eq(default_options)
  end

  it 'closes the udp socket on #close' do
    device = LogStasher::Device::UDP.new
    expect(device.socket).to receive(:close)
    device.close
  end

  it 'works as a logger device' do
    device = LogStasher::Device::UDP.new
    expect(device).to receive(:write).with('foo')
    logger = Logger.new(device)
    logger << 'foo'
  end

  describe '#write' do
    subject { LogStasher::Device::UDP.new }
    it 'writes the log to the the socket' do
      expect(subject.socket).to receive(:send).with('a log', 0, default_options['hostname'], default_options['port'])
      subject.write('a log')
    end
  end  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
md-logstasher-1.8.0 spec/lib/logstasher/device/udp_spec.rb
md-logstasher-1.7.0 spec/lib/logstasher/device/udp_spec.rb
md-logstasher-1.6.0 spec/lib/logstasher/device/udp_spec.rb
md-logstasher-1.5.0 spec/lib/logstasher/device/udp_spec.rb
md-logstasher-1.4.1 spec/lib/logstasher/device/udp_spec.rb
md-logstasher-1.4.0 spec/lib/logstasher/device/udp_spec.rb
md-logstasher-1.3.0 spec/lib/logstasher/device/udp_spec.rb