Sha256: cb6660c9d65c39b262511a97ce55235ed17c4b957a3797b353bcb178945aa277

Contents?: true

Size: 788 Bytes

Versions: 2

Compression:

Stored size: 788 Bytes

Contents

require 'spec_helper'

RSpec.describe Appdash::Client do

  let(:mock_socket) { double("TCPSocket", close: nil) }
  before  { allow(TCPSocket).to receive(:new).and_return(mock_socket) }

  it "should collect spans" do
    span = subject.span
    span.event(Appdash::Event::Message.new("Hello world!"))

    expect(mock_socket).to receive(:write) do |raw|
      expect(raw.bytesize).to eq(57)
      expect(raw.bytes.first).to eq(56)
    end.and_return(57)
    span.flush
  end

  it "should support buffering" do
    subject = described_class.new(max_buffer_size: 1000)
    subject.span do |s|
      s.message("Message A")
      s.message("Message B")
    end

    expect(mock_socket).to receive(:write) do |raw|
      expect(raw.bytesize).to eq(117)
    end
    subject.close
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
appdash-0.6.3 spec/appdash/client_spec.rb
appdash-0.6.2 spec/appdash/client_spec.rb