Sha256: 11e8a57cd1163d5381f87326019ca1857e116302609d7dd0ceef89e292981c8f

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe Profit::Server do

  let!(:redis)         { Redis.new(host: "127.0.0.1", port: 6379) }
  let!(:server)        { TestServer.server }
  let!(:server_thread) { TestServer.server_thread }

  after do
    redis.del("profit:metric:some_slow_piece_of_code")
  end

  it "stores metrics messages" do
    pusher = server.ctx.connect(:PUSH, "tcp://127.0.0.1:5556")

    pusher.send({ recorded_time: (now = Time.now),
                  total_time: 12.012,
                  metric_type: "some_slow_piece_of_code",
                  start_line: 1,
                  end_line: 42,
                  start_file: "/foo/bar/baz.rb",
                  end_file: "/foo/bar/biz.rb" }.to_json)
    server_thread.join(0.1)

    list = redis.lrange("profit:metric:some_slow_piece_of_code", 0, -1)
    expect(list.count).to eq 1
    expect(redis.llen("profit:metric:some_slow_piece_of_code")).to eq 1

    metric = JSON.parse(list[0])
    expect(metric["total_time"]).to eq 12.012
    expect(metric["start_line"]).to eq 1
    expect(metric["end_line"]).to eq 42
    expect(metric["start_file"]).to eq "/foo/bar/baz.rb"
    expect(metric["end_file"]).to eq "/foo/bar/biz.rb"
    expect(metric["recorded_time"]).to eq now.to_s
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
profit-0.1.5 spec/lib/server_spec.rb
profit-0.1.4 spec/lib/server_spec.rb
profit-0.1.3 spec/lib/server_spec.rb
profit-0.1.2 spec/lib/server_spec.rb