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