spec/integration/sinatra_spec.rb in loga-2.8.0 vs spec/integration/sinatra_spec.rb in loga-2.8.1

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'spec_helper' class MySinatraApp < Sinatra::Base set :logging, false @@ -19,11 +21,11 @@ get '/new' do redirect '/ok' end end -RSpec.describe 'Structured logging with Sinatra', :with_hostname, :timecop do +RSpec.describe 'Structured logging with Sinatra', :timecop, :with_hostname do let(:io) { StringIO.new } let(:format) {} let(:last_log_entry) do io.rewind JSON.parse(io.read) @@ -67,16 +69,16 @@ io.read end let(:data) do { 'method' => 'GET', - 'path' => '/ok', + 'path' => '/ok', 'params' => { 'username'=>'yoshi' }, 'request_id' => '700a6a01', 'request_ip' => '127.0.0.1', 'user_agent' => nil, - 'duration' => 0, + 'duration' => 0, 'status' => 200, } end let(:data_as_text) { "data=#{{ request: data }.inspect}" } let(:time_pid_tags) { '[2015-12-15T09:30:05.123000+06:00 #999][700a6a01 TEST_TAG]' } @@ -95,11 +97,11 @@ describe 'request with redirect' do let(:data) do super().merge( 'status' => 302, - 'path' => '/new', + 'path' => '/new', 'params' => {}, ) end it 'specifies the original path' do @@ -110,17 +112,18 @@ context 'when the request raises an exception' do let(:data) do super().merge( 'status' => 500, - 'path' => '/error', + 'path' => '/error', 'params' => {}, ) end it 'logs the request with the exception' do get '/error', {}, 'HTTP_X_REQUEST_ID' => '700a6a01' - expect(last_log_entry).to eql("E, #{time_pid_tags} GET /error 500 in 0ms type=request #{data_as_text} exception=undefined method `name' for nil:NilClass\n") + + expect(last_log_entry).to start_with("E, #{time_pid_tags} GET /error 500 in 0ms type=request #{data_as_text} exception=undefined method `name' for nil") end end end # rubocop:enable Metrics/LineLength end