Sha256: cf781945b5da0730ca8d529d88c1255b42b806ff19b078fced417b8a9ee7e27d

Contents?: true

Size: 888 Bytes

Versions: 1

Compression:

Stored size: 888 Bytes

Contents

require 'spec_helper'
require 'timeout'

describe Zlogger::Client do

  context "Stubbed ZMQ" do
    let(:socket) { double("zmq socket") }
    let(:zmq_context) { double("zmq context", :socket => socket) }
    before do
      ZMQ.stub(:context => zmq_context)
      Zlogger::Client::LogDevice.any_instance.stub(:run_socket_thread => nil)
    end
    it "logs a message" do
      subject.info "Hello"
      subject.close
      expect(socket).to receive(:connect).with("tcp://127.0.0.1:7000")
      expect(socket).to receive(:send_message) { |message|
        expect(message.size).to eq(2)
        expect(message.popstr).to match(/rspec/)
        expect(message.popstr).to eq("INFO: Hello")
      }
      expect(socket).to receive(:close)
      Timeout.timeout(2) do
        subject.log_device.run_socket_loop
      end
    end
    after do
      subject.close if subject
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zlogger-0.1.0 spec/lib/zlogger/client_spec.rb