Sha256: 68360852cfbefec20b9c71a586497eeca3dff1bab641415610dcc0c5d53da1b1

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

RSpec.describe Appdash::Event::RackServer do

  let(:time)     { Time.utc(2001,2,3,4,5,6) }
  let(:response) { Rack::Response.new([], 201, 'Content-Length' => 33) }
  let(:request) do
    env = Rack::MockRequest.env_for("http://example.com:8080/path?a=1", "REMOTE_ADDR" => "10.10.10.10", 'CONTENT_LENGTH' => 12, 'HTTP_USER_AGENT' => 'Test/1.0')
    Rack::Request.new(env)
  end

  before  { allow(Time).to receive(:now).and_return(time) }
  subject { described_class.new request, response, route: 'createPost' }

  it "should init" do
    expect(subject.schema).to eq("HTTPServer")
    expect(subject.attrs.size).to eq(1)
  end

  it "should annotate" do
    expect(atoh(subject.to_a)).to eq(
      "Server.Request.ContentLength" => "12",
      "Server.Request.Host" => "example.com",
      "Server.Request.Method" => "GET",
      "Server.Request.Scheme" => "http",
      "Server.Request.RemoteIP" => "10.10.10.10",
      "Server.Request.Path" => "/path?a=1",
      "Server.Request.UserAgent" => "Test/1.0",
      "Server.Response.ContentLength" => "33",
      "Server.Response.StatusCode" => "201",
      "Server.Route" => "createPost",
      "Server.Send" => "2001-02-03T04:05:06.000000+00:00",
      "_schema:HTTPServer" => "",
    )
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
appdash-0.6.3 spec/appdash/event/rack_server_spec.rb
appdash-0.6.2 spec/appdash/event/rack_server_spec.rb
appdash-0.6.1 spec/appdash/event/rack_server_spec.rb