Sha256: 77a15873134304539f670d03cb4061ee3661852c2c91b8bce5ce6d994bc97bc2

Contents?: true

Size: 962 Bytes

Versions: 25

Compression:

Stored size: 962 Bytes

Contents

require 'pry'
require 'spec_helper'

describe Attune::JsonLogger do
  let(:logger){ double(:logger) }
  let(:connection) do
    Faraday.new(url: 'http://example.com/') do |builder|
      builder.use described_class, logger
      builder.adapter :test do |stubs|
        stubs.get("/test"){ [200, {}, "foobar"] }
      end
    end
  end

  it "logs as expected" do
    logged = ""
    logger.stub(:info){|s| logged << s }

    Benchmark.stub(:realtime).and_yield.and_return(0.12)
    SecureRandom.stub(:uuid).and_return("eaa45af2-efc3-45ef-90da-9bcb56758e77")
    Time.stub(:now).and_return(12345)

    response = connection.get("/test")
    response.status.should == 200
    response.body.should == "foobar"

    expect(logged).to match(/{"ref":null,"v":1,"protocol":"http","host":"example.com","path":"\/test","t":12345000,"r_id":"eaa45af2-efc3-45ef-90da-9bcb56758e77","status":200,"ua":"Faraday v\d+.\d+.\d+","method":"get","perf":{"total":120.0}}/)
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
attune-1.0.21 spec/attune/json_logger_spec.rb
attune-1.0.20 spec/attune/json_logger_spec.rb
attune-1.0.19 spec/attune/json_logger_spec.rb
attune-1.0.18 spec/attune/json_logger_spec.rb
attune-1.0.17 spec/attune/json_logger_spec.rb
attune-1.0.16 spec/attune/json_logger_spec.rb
attune-1.0.15 spec/attune/json_logger_spec.rb
attune-1.0.14 spec/attune/json_logger_spec.rb
attune-1.0.13 spec/attune/json_logger_spec.rb
attune-1.0.12 spec/attune/json_logger_spec.rb
attune-1.0.11 spec/attune/json_logger_spec.rb
attune-1.0.10 spec/attune/json_logger_spec.rb
attune-1.0.9 spec/attune/json_logger_spec.rb
attune-1.0.8 spec/attune/json_logger_spec.rb
attune-1.0.7 spec/attune/json_logger_spec.rb
attune-1.0.6 spec/attune/json_logger_spec.rb
attune-1.0.5 spec/attune/json_logger_spec.rb
attune-1.0.3 spec/attune/json_logger_spec.rb
attune-1.0.2 spec/attune/json_logger_spec.rb
attune-1.0.1 spec/attune/json_logger_spec.rb