diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index d4f3b68..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,112 +0,0 @@ -basic_build: &basic_build - working_directory: ~/loga - docker: - - image: cimg/ruby:2.7.5 - -test_build: &test_build - working_directory: ~/loga - steps: - - checkout - - &restore_gems - restore_cache: - keys: - - v2-gems-{{ checksum "Gemfile" }}-{{ checksum "Appraisals"}}-{{ .Environment.CIRCLE_JOB }} - - v2-gems-{{ checksum "Gemfile" }} - - &bundle_install - run: bundle install --jobs 4 --path=vendor/bundle --retry 3 - - run: bundle exec appraisal install - - &cache_gems - save_cache: - key: v2-gems-{{ checksum "Gemfile" }}-{{ checksum "Appraisals"}}-{{ .Environment.CIRCLE_JOB }} - paths: - - gemfiles/vendor/bundle - - vendor/bundle - - attach_workspace: - at: ./tmp - - run: RACK_ENV=development bundle exec appraisal rspec - - run: RACK_ENV=production bundle exec appraisal rspec - - store_artifacts: - path: coverage - -version: 2 -jobs: - ruby-2.5: - docker: - - image: circleci/ruby:2.5 - <<: *test_build - ruby-2.6: - docker: - - image: circleci/ruby:2.6 - <<: *test_build - ruby-2.7: - docker: - - image: cimg/ruby:2.7 - - image: redis:7 - <<: *test_build - ruby-3.0: - docker: - - image: cimg/ruby:3.0 - - image: redis:7 - <<: *test_build - rubocop: - <<: *basic_build - steps: - - checkout - - *restore_gems - - *bundle_install - - *cache_gems - - run: bundle exec rubocop - push-to-rubygems: - <<: *basic_build - steps: - - checkout - - *restore_gems - - *bundle_install - - *cache_gems - - run: - name: Build the gem - command: gem build $CIRCLE_PROJECT_REPONAME.gemspec - - deploy: - name: Publish to rubygems - command: | - mkdir ~/.gem - echo ":rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials - chmod 0600 ~/.gem/credentials - gem push $CIRCLE_PROJECT_REPONAME-$(echo $CIRCLE_TAG | sed -e 's/v//').gem -workflows: - version: 2 - test-then-push-gem: - jobs: - - rubocop: - filters: - tags: - only: /.*/ - - ruby-2.5: - filters: - tags: - only: /.*/ - - ruby-2.6: - filters: - tags: - only: /.*/ - - ruby-2.7: - filters: - tags: - only: /.*/ - - ruby-3.0: - filters: - tags: - only: /.*/ - - push-to-rubygems: - context: org-rubygems - filters: - tags: - only: /^v\d.+/ - branches: - ignore: /.*/ - requires: - - rubocop - - ruby-2.5 - - ruby-2.6 - - ruby-2.7 - - ruby-3.0 diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..2b862fc --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,72 @@ +name: Build & Test +run-name: Build & Test - ${{ github.ref_name }} + +on: + push: + branches: + - '**' + +jobs: + version-check: + runs-on: ubuntu-latest + if: "!contains(github.ref, 'master')" + steps: + - name: Checkout commit + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Gem versioned correctly + shell: sh + run: | + CHANGED=$(git diff origin/master HEAD --name-only | grep 'lib/loga') || exit 0 + [[ -z "$CHANGED" ]] || (echo "$CHANGED" | grep 'version.rb') || exit 1 + + rubocop: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + + - name: Run RuboCop + run: bundle exec rubocop + + build-and-test: + runs-on: ubuntu-latest + services: + redis: + image: redis:7 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 6379:6379 + strategy: + matrix: + ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3', 'head'] + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Set up Ruby ${{ matrix.ruby-version }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + + - name: Install appraisal gems + run: bundle exec appraisal install + + - name: Test with RACK_ENV=development + run: RACK_ENV=development bundle exec appraisal rspec + + - name: Test with RACK_ENV=production + run: RACK_ENV=production bundle exec appraisal rspec diff --git a/.github/workflows/publish-gem.yml b/.github/workflows/publish-gem.yml new file mode 100644 index 0000000..b4c4c1a --- /dev/null +++ b/.github/workflows/publish-gem.yml @@ -0,0 +1,28 @@ +name: Deploy to RubyGems +run-name: ${{ github.actor }} is publishing a new version + +on: + release: + types: [published] + +jobs: + publish-gem: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + + - name: Build gem + run: gem build loga.gemspec + + - name: Publish gem + env: + GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} + run: | + gem push loga-*.gem diff --git a/.rubocop.yml b/.rubocop.yml index 24d7ff2..cf02cab 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,8 @@ +inherit_from: .rubocop_todo.yml + AllCops: + TargetRubyVersion: 2.7 + NewCops: enable Exclude: - '*.gemspec' - 'gemfiles/*' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..97bfa29 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,206 @@ +# This configuration was generated by +# `rubocop --auto-gen-config --exclude-limit 10000000` +# on 2024-02-09 15:03:07 UTC using RuboCop version 1.60.2. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. +# Include: **/*.gemfile, **/Gemfile, **/gems.rb +Bundler/OrderedGems: + Exclude: + - 'Gemfile' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'lib/loga/formatters/gelf_formatter.rb' + +# Offense count: 34 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Exclude: + - 'lib/loga/configuration.rb' + - 'lib/loga/formatters/gelf_formatter.rb' + - 'lib/loga/rack/logger.rb' + - 'lib/loga/railtie.rb' + - 'lib/loga/sidekiq6/job_logger.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. +Layout/LeadingCommentSpace: + Exclude: + - 'lib/loga/railtie.rb' + +# Offense count: 2 +# Configuration parameters: AllowComments, AllowEmptyLambdas. +Lint/EmptyBlock: + Exclude: + - 'Appraisals' + - 'spec/integration/sinatra_spec.rb' + +# Offense count: 1 +# Configuration parameters: AllowedParentClasses. +Lint/MissingSuper: + Exclude: + - 'lib/loga/formatters/gelf_formatter.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Lint/RedundantCopDisableDirective: + Exclude: + - 'lib/loga/railtie.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Lint/SendWithMixinArgument: + Exclude: + - 'lib/loga/railtie.rb' + +# Offense count: 1 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/CyclomaticComplexity: + Max: 8 + +# Offense count: 1 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/PerceivedComplexity: + Max: 9 + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Migration/DepartmentName: + Exclude: + - 'lib/loga/railtie.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Exclude: + - 'lib/loga/sidekiq5/job_logger.rb' + +# Offense count: 3 +# Configuration parameters: Prefixes, AllowedPatterns. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: + - 'spec/support/gethostname_shared.rb' + - 'spec/support/timecop_shared.rb' + - 'spec/unit/loga/configuration_spec.rb' + +# Offense count: 41 +# Configuration parameters: AllowSubject. +RSpec/MultipleMemoizedHelpers: + Max: 12 + +# Offense count: 6 +# Configuration parameters: AllowedPatterns. +# AllowedPatterns: ^expect_, ^assert_ +RSpec/NoExpectationExample: + Exclude: + - 'spec/integration/sidekiq60_spec.rb' + - 'spec/integration/sidekiq61_spec.rb' + - 'spec/integration/sidekiq65_spec.rb' + - 'spec/integration/sidekiq7_spec.rb' + +# Offense count: 2 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: + Exclude: + - '**/spec/routing/**/*' + - 'spec/integration/rails/action_mailer_spec.rb' + - 'spec/integration/rails/railtie_spec.rb' + +# Offense count: 1 +RSpec/SubjectDeclaration: + Exclude: + - 'spec/unit/loga/event_spec.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +Style/CollectionCompact: + Exclude: + - 'lib/loga/configuration.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Keywords, RequireColon. +# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE +Style/CommentAnnotation: + Exclude: + - 'lib/loga/configuration.rb' + +# Offense count: 25 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Exclude: + - 'Appraisals' + - 'Gemfile' + - 'Guardfile' + - 'Rakefile' + - 'lib/loga.rb' + - 'lib/loga/configuration.rb' + - 'lib/loga/event.rb' + - 'lib/loga/ext/core/tempfile.rb' + - 'lib/loga/ext/rails/rack/debug_exceptions.rb' + - 'lib/loga/ext/rails/rack/logger.rb' + - 'lib/loga/ext/rails/rack/logger3.rb' + - 'lib/loga/formatters/gelf_formatter.rb' + - 'lib/loga/formatters/simple_formatter.rb' + - 'lib/loga/log_subscribers/action_mailer.rb' + - 'lib/loga/parameter_filter.rb' + - 'lib/loga/rack/logger.rb' + - 'lib/loga/rack/request.rb' + - 'lib/loga/rack/request_id.rb' + - 'lib/loga/railtie.rb' + - 'lib/loga/service_version_strategies.rb' + - 'lib/loga/sidekiq5/job_logger.rb' + - 'lib/loga/sidekiq6/job_logger.rb' + - 'lib/loga/tagged_logging.rb' + - 'lib/loga/utilities.rb' + - 'lib/loga/version.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/GlobalStdStream: + Exclude: + - 'lib/loga/configuration.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'lib/loga/rack/request.rb' + +# Offense count: 2 +Style/OpenStructUse: + Exclude: + - 'spec/unit/loga/formatters/gelf_formatter_spec.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantFileExtensionInRequire: + Exclude: + - 'lib/loga/railtie.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantFreeze: + Exclude: + - 'lib/loga/sidekiq7/job_logger.rb' diff --git a/Appraisals b/Appraisals index fc7ce40..3145f9f 100644 --- a/Appraisals +++ b/Appraisals @@ -1,12 +1,4 @@ -if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7.0') - appraise 'rails42' do - gem 'rails', '~> 4.2.0' - end - - appraise 'rails50' do - gem 'rails', '~> 5.0.0' - end - +if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0') appraise 'rails52' do gem 'rails', '~> 5.2.0' end @@ -16,60 +8,80 @@ appraise 'sinatra14' do gem 'sinatra', '~> 1.4.0' end -if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.5.0') - appraise 'rails60' do - gem 'rails', '~> 6.0.0' - end +appraise 'sinatra2' do + gem 'sinatra', '~> 2.2.4' +end - appraise 'sidekiq60' do - gem 'sidekiq', '~> 6.0.0' - end +appraise 'sinatra3' do + gem 'sinatra', '~> 3.2.0' +end - appraise 'sidekiq61' do - gem 'sidekiq', '~> 6.1.0' - end +appraise 'sinatra4' do + gem 'sinatra', '~> 4.0.0' +end - appraise 'sidekiq62' do - gem 'sidekiq', '~> 6.2.0' - end +appraise 'sidekiq51' do + gem 'sidekiq', '~> 5.1.0' +end - appraise 'sidekiq63' do - gem 'sidekiq', '~> 6.3.0' - end +appraise 'sidekiq60' do + gem 'sidekiq', '~> 6.0.0' +end - appraise 'sidekiq64' do - gem 'sidekiq', '~> 6.4.0' - end +appraise 'sidekiq61' do + gem 'sidekiq', '~> 6.1.0' +end - appraise 'sidekiq65' do - gem 'sidekiq', '~> 6.5.0' - end +appraise 'sidekiq62' do + gem 'sidekiq', '~> 6.2.0' +end + +appraise 'sidekiq63' do + gem 'sidekiq', '~> 6.3.0' end -if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.7.0') +appraise 'sidekiq64' do + gem 'sidekiq', '~> 6.4.0' +end + +appraise 'sidekiq65' do + gem 'sidekiq', '~> 6.5.0' +end + +appraise 'sidekiq70' do + gem 'sidekiq', '~> 7.0.0' +end + +appraise 'sidekiq71' do + gem 'sidekiq', '~> 7.1.0' +end + +appraise 'sidekiq7' do + gem 'sidekiq', '~> 7.0' +end + +if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.2.0') + appraise 'rails60' do + gem 'rails', '~> 6.0.0' + end + appraise 'rails61' do gem 'rails', '~> 6.1.4.4' end +end +if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('3.0.0') appraise 'rails70' do gem 'rails', '~> 7.0.0' + gem 'base64' + gem 'mutex_m' end - appraise 'sidekiq7' do - gem 'sidekiq', '~> 7.0' + appraise 'rails71' do + gem 'rails', '~> 7.1.0' + gem 'base64' + gem 'mutex_m' end - - appraise 'sidekiq70' do - gem 'sidekiq', '~> 7.0.0' - end - - appraise 'sidekiq71' do - gem 'sidekiq', '~> 7.1.0' - end -end - -appraise 'sidekiq51' do - gem 'sidekiq', '~> 5.1.0' end appraise 'unit' do diff --git a/CHANGELOG.md b/CHANGELOG.md index e649252..7fb24e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [2.8.1] - 2023-02-12 +### Added +- Improve CI pipeline +### Fixed +- Support for rails 7.1 + ## [2.8.0] - 2023-11-14 ### Added - Support open-telemetry and add trace_id and span_id to logs events diff --git a/Gemfile b/Gemfile index c1e1817..edf5174 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,28 @@ source 'https://rubygems.org' # Specify your gem's dependencies in loga.gemspec gemspec +group :development do + gem 'appraisal' + gem 'bundler', '>= 1.6' + gem 'byebug' + gem 'guard' + gem 'guard-rspec' + gem 'guard-rubocop' + gem 'pry' + gem 'rack-test' + gem 'rake' + gem 'fakeredis' + gem 'rspec', '~> 3.7' + gem 'rubocop' + gem 'rubocop-rspec' + gem 'timecop' + gem 'psych' + gem 'net-smtp' + gem 'net-pop' + gem 'net-imap' + gem 'bigdecimal' +end + group :test do gem 'simplecov', '~> 0.17.0' end diff --git a/gemfiles/rails42.gemfile b/gemfiles/rails42.gemfile deleted file mode 100644 index 6d4b49b..0000000 --- a/gemfiles/rails42.gemfile +++ /dev/null @@ -1,11 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rails", "~> 4.2.0" - -group :test do - gem "simplecov" -end - -gemspec path: "../" diff --git a/gemfiles/rails50.gemfile b/gemfiles/rails50.gemfile deleted file mode 100644 index bb11225..0000000 --- a/gemfiles/rails50.gemfile +++ /dev/null @@ -1,11 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rails", "~> 5.0.0" - -group :test do - gem "simplecov" -end - -gemspec path: "../" diff --git a/gemfiles/rails52.gemfile b/gemfiles/rails52.gemfile index 41fa37d..b78bd34 100644 --- a/gemfiles/rails52.gemfile +++ b/gemfiles/rails52.gemfile @@ -4,8 +4,30 @@ source "https://rubygems.org" gem "rails", "~> 5.2.0" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do - gem "simplecov" + gem "simplecov", "~> 0.17.0" end gemspec path: "../" diff --git a/gemfiles/rails60.gemfile b/gemfiles/rails60.gemfile index 3d49fd5..46c6acd 100644 --- a/gemfiles/rails60.gemfile +++ b/gemfiles/rails60.gemfile @@ -4,6 +4,28 @@ source "https://rubygems.org" gem "rails", "~> 6.0.0" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do gem "simplecov", "~> 0.17.0" end diff --git a/gemfiles/rails61.gemfile b/gemfiles/rails61.gemfile index df49d08..4145e9b 100644 --- a/gemfiles/rails61.gemfile +++ b/gemfiles/rails61.gemfile @@ -4,6 +4,28 @@ source "https://rubygems.org" gem "rails", "~> 6.1.4.4" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do gem "simplecov", "~> 0.17.0" end diff --git a/gemfiles/rails70.gemfile b/gemfiles/rails70.gemfile index 01a984f..a6ae102 100644 --- a/gemfiles/rails70.gemfile +++ b/gemfiles/rails70.gemfile @@ -3,6 +3,30 @@ source "https://rubygems.org" gem "rails", "~> 7.0.0" +gem "base64" +gem "mutex_m" + +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end group :test do gem "simplecov", "~> 0.17.0" diff --git a/gemfiles/rails71.gemfile b/gemfiles/rails71.gemfile new file mode 100644 index 0000000..926c3b1 --- /dev/null +++ b/gemfiles/rails71.gemfile @@ -0,0 +1,35 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 7.1.0" +gem "base64" +gem "mutex_m" + +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + +group :test do + gem "simplecov", "~> 0.17.0" +end + +gemspec path: "../" diff --git a/gemfiles/sidekiq51.gemfile b/gemfiles/sidekiq51.gemfile index fc1d582..f43ead8 100644 --- a/gemfiles/sidekiq51.gemfile +++ b/gemfiles/sidekiq51.gemfile @@ -4,6 +4,28 @@ source "https://rubygems.org" gem "sidekiq", "~> 5.1.0" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do gem "simplecov", "~> 0.17.0" end diff --git a/gemfiles/sidekiq60.gemfile b/gemfiles/sidekiq60.gemfile index ba856cc..66355c3 100644 --- a/gemfiles/sidekiq60.gemfile +++ b/gemfiles/sidekiq60.gemfile @@ -4,6 +4,28 @@ source "https://rubygems.org" gem "sidekiq", "~> 6.0.0" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do gem "simplecov", "~> 0.17.0" end diff --git a/gemfiles/sidekiq61.gemfile b/gemfiles/sidekiq61.gemfile index 6740828..d923dd9 100644 --- a/gemfiles/sidekiq61.gemfile +++ b/gemfiles/sidekiq61.gemfile @@ -4,6 +4,28 @@ source "https://rubygems.org" gem "sidekiq", "~> 6.1.0" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do gem "simplecov", "~> 0.17.0" end diff --git a/gemfiles/sidekiq62.gemfile b/gemfiles/sidekiq62.gemfile index b62b55c..066d678 100644 --- a/gemfiles/sidekiq62.gemfile +++ b/gemfiles/sidekiq62.gemfile @@ -4,6 +4,28 @@ source "https://rubygems.org" gem "sidekiq", "~> 6.2.0" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do gem "simplecov", "~> 0.17.0" end diff --git a/gemfiles/sidekiq63.gemfile b/gemfiles/sidekiq63.gemfile index 2a28090..5a17af7 100644 --- a/gemfiles/sidekiq63.gemfile +++ b/gemfiles/sidekiq63.gemfile @@ -4,6 +4,28 @@ source "https://rubygems.org" gem "sidekiq", "~> 6.3.0" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do gem "simplecov", "~> 0.17.0" end diff --git a/gemfiles/sidekiq64.gemfile b/gemfiles/sidekiq64.gemfile index 65cdc9b..6ec65f5 100644 --- a/gemfiles/sidekiq64.gemfile +++ b/gemfiles/sidekiq64.gemfile @@ -4,6 +4,28 @@ source "https://rubygems.org" gem "sidekiq", "~> 6.4.0" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do gem "simplecov", "~> 0.17.0" end diff --git a/gemfiles/sidekiq65.gemfile b/gemfiles/sidekiq65.gemfile index 6986c23..6c5a775 100644 --- a/gemfiles/sidekiq65.gemfile +++ b/gemfiles/sidekiq65.gemfile @@ -4,6 +4,28 @@ source "https://rubygems.org" gem "sidekiq", "~> 6.5.0" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do gem "simplecov", "~> 0.17.0" end diff --git a/gemfiles/sidekiq7.gemfile b/gemfiles/sidekiq7.gemfile index 0555d25..45ee809 100644 --- a/gemfiles/sidekiq7.gemfile +++ b/gemfiles/sidekiq7.gemfile @@ -4,6 +4,28 @@ source "https://rubygems.org" gem "sidekiq", "~> 7.0" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do gem "simplecov", "~> 0.17.0" end diff --git a/gemfiles/sidekiq70.gemfile b/gemfiles/sidekiq70.gemfile index fd1b640..7070368 100644 --- a/gemfiles/sidekiq70.gemfile +++ b/gemfiles/sidekiq70.gemfile @@ -4,6 +4,28 @@ source "https://rubygems.org" gem "sidekiq", "~> 7.0.0" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do gem "simplecov", "~> 0.17.0" end diff --git a/gemfiles/sidekiq71.gemfile b/gemfiles/sidekiq71.gemfile index f2168fc..83b2b7b 100644 --- a/gemfiles/sidekiq71.gemfile +++ b/gemfiles/sidekiq71.gemfile @@ -4,6 +4,28 @@ source "https://rubygems.org" gem "sidekiq", "~> 7.1.0" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do gem "simplecov", "~> 0.17.0" end diff --git a/gemfiles/sinatra14.gemfile b/gemfiles/sinatra14.gemfile index 500b38d..fb3e953 100644 --- a/gemfiles/sinatra14.gemfile +++ b/gemfiles/sinatra14.gemfile @@ -4,6 +4,28 @@ source "https://rubygems.org" gem "sinatra", "~> 1.4.0" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do gem "simplecov", "~> 0.17.0" end diff --git a/gemfiles/sinatra2.gemfile b/gemfiles/sinatra2.gemfile new file mode 100644 index 0000000..1ffd65a --- /dev/null +++ b/gemfiles/sinatra2.gemfile @@ -0,0 +1,33 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "sinatra", "~> 2.2.4" + +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + +group :test do + gem "simplecov", "~> 0.17.0" +end + +gemspec path: "../" diff --git a/gemfiles/sinatra3.gemfile b/gemfiles/sinatra3.gemfile new file mode 100644 index 0000000..656a73f --- /dev/null +++ b/gemfiles/sinatra3.gemfile @@ -0,0 +1,33 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "sinatra", "~> 3.2.0" + +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + +group :test do + gem "simplecov", "~> 0.17.0" +end + +gemspec path: "../" diff --git a/gemfiles/sinatra4.gemfile b/gemfiles/sinatra4.gemfile new file mode 100644 index 0000000..549304b --- /dev/null +++ b/gemfiles/sinatra4.gemfile @@ -0,0 +1,33 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "sinatra", "~> 4.0.0" + +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + +group :test do + gem "simplecov", "~> 0.17.0" +end + +gemspec path: "../" diff --git a/gemfiles/unit.gemfile b/gemfiles/unit.gemfile index fe10f08..f16e27e 100644 --- a/gemfiles/unit.gemfile +++ b/gemfiles/unit.gemfile @@ -2,6 +2,28 @@ source "https://rubygems.org" +group :development do + gem "appraisal" + gem "bundler", ">= 1.6" + gem "byebug" + gem "guard" + gem "guard-rspec" + gem "guard-rubocop" + gem "pry" + gem "rack-test" + gem "rake" + gem "fakeredis" + gem "rspec", "~> 3.7" + gem "rubocop" + gem "rubocop-rspec" + gem "timecop" + gem "psych" + gem "net-smtp" + gem "net-pop" + gem "net-imap" + gem "bigdecimal" +end + group :test do gem "simplecov", "~> 0.17.0" end diff --git a/lib/loga/railtie.rb b/lib/loga/railtie.rb index b38a9fc..339bd22 100644 --- a/lib/loga/railtie.rb +++ b/lib/loga/railtie.rb @@ -86,10 +86,10 @@ def self.included(base) #:nodoc: private - def render_exception_with_loga(arg, exception) + def render_exception_with_loga(arg, exception, *args) env = arg.is_a?(ActionDispatch::Request) ? arg.env : arg env['loga.exception'] = exception - render_exception_without_loga(arg, exception) + render_exception_without_loga(arg, exception, *args) end end diff --git a/lib/loga/version.rb b/lib/loga/version.rb index a80c433..ad0495c 100644 --- a/lib/loga/version.rb +++ b/lib/loga/version.rb @@ -1,3 +1,3 @@ module Loga - VERSION = '2.8.0'.freeze + VERSION = '2.8.1'.freeze end diff --git a/loga.gemspec b/loga.gemspec index 4688dd9..db157f9 100644 --- a/loga.gemspec +++ b/loga.gemspec @@ -20,19 +20,4 @@ Gem::Specification.new do |spec| spec.add_dependency 'activesupport', '>= 2.3.8' spec.add_dependency 'rack' - - spec.add_development_dependency 'appraisal', '~> 2.4' - spec.add_development_dependency 'bundler', '>= 1.6' - spec.add_development_dependency 'byebug' - spec.add_development_dependency 'guard', '~> 2.13' - spec.add_development_dependency 'guard-rspec', '~> 4.7' - spec.add_development_dependency 'guard-rubocop', '~> 1.2' - spec.add_development_dependency 'pry' - spec.add_development_dependency 'rack-test' - spec.add_development_dependency 'rake' - spec.add_development_dependency 'fakeredis' - spec.add_development_dependency 'rspec', '~> 3.7' - spec.add_development_dependency 'rubocop', '~> 0.57.0' - spec.add_development_dependency 'rubocop-rspec' - spec.add_development_dependency 'timecop' end diff --git a/spec/fixtures/rails42.rb b/spec/fixtures/rails42.rb deleted file mode 100644 index 6e7995c..0000000 --- a/spec/fixtures/rails42.rb +++ /dev/null @@ -1,80 +0,0 @@ -require 'action_controller/railtie' -require 'action_mailer/railtie' - -Bundler.require(*Rails.groups) - -STREAM = StringIO.new unless defined?(STREAM) - -class Dummy < Rails::Application - config.eager_load = true - config.filter_parameters += [:password] - config.secret_key_base = '2624599ca9ab3cf3823626240138a128118a87683bf03ab8f155844c33b3cd8cbbfa3ef5e29db6f5bd182f8bd4776209d9577cfb46ac51bfd232b00ab0136b24' - config.session_store :cookie_store, key: '_rails42_session' - - config.log_tags = [:uuid, 'TEST_TAG'] - config.loga = { - device: STREAM, - host: 'bird.example.com', - service_name: 'hello_world_app', - service_version: '1.0', - } - config.action_mailer.delivery_method = :test -end - -class ApplicationController < ActionController::Base - include Rails.application.routes.url_helpers - protect_from_forgery - - def ok - render text: 'Hello Rails' - end - - def error - nil.name - end - - def show - render json: params - end - - def create - render json: params - end - - def new - redirect_to :ok - end - - def update - @id = params[:id] - render '/user' - end -end - -class FakeMailer < ActionMailer::Base - default from: 'notifications@example.com' - - def self.send_email - basic_mail.deliver_now - end - - def basic_mail - mail( - to: 'user@example.com', - subject: 'Welcome to My Awesome Site', - body: 'Banana muffin', - content_type: 'text/html', - ) - end -end - -Dummy.routes.append do - get 'ok' => 'application#ok' - get 'error' => 'application#error' - get 'show' => 'application#show' - post 'users' => 'application#create' - get 'new' => 'application#new' - put 'users/:id' => 'application#update' -end - -Dummy.initialize! diff --git a/spec/fixtures/rails50.rb b/spec/fixtures/rails71.rb similarity index 96% rename from spec/fixtures/rails50.rb rename to spec/fixtures/rails71.rb index 1fae3cb..5af8df3 100644 --- a/spec/fixtures/rails50.rb +++ b/spec/fixtures/rails71.rb @@ -9,7 +9,7 @@ class Dummy < Rails::Application config.eager_load = true config.filter_parameters += [:password] config.secret_key_base = '2624599ca9ab3cf3823626240138a128118a87683bf03ab8f155844c33b3cd8cbbfa3ef5e29db6f5bd182f8bd4776209d9577cfb46ac51bfd232b00ab0136b24' - config.session_store :cookie_store, key: '_rails50_session' + config.session_store :cookie_store, key: '_rails70_session' config.log_tags = [:uuid, 'TEST_TAG'] config.loga = { diff --git a/spec/integration/rails/action_mailer_spec.rb b/spec/integration/rails/action_mailer_spec.rb index 47f1ceb..d52fca2 100644 --- a/spec/integration/rails/action_mailer_spec.rb +++ b/spec/integration/rails/action_mailer_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe Loga::LogSubscribers::ActionMailer, if: Rails.env.production? do diff --git a/spec/integration/rails/railtie_spec.rb b/spec/integration/rails/railtie_spec.rb index 3b15335..7e26ccb 100644 --- a/spec/integration/rails/railtie_spec.rb +++ b/spec/integration/rails/railtie_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'ostruct' RSpec.describe Loga::Railtie do @@ -17,7 +19,11 @@ let(:formatter) { Loga::Formatters::SimpleFormatter } it 'assign Loga logger to Rails logger' do - expect(Loga.logger).to equal(Rails.logger) + if defined?(ActiveSupport::BroadcastLogger) + expect(Loga.logger).to be_a(Logger) + else + expect(Loga.logger).to equal(Rails.logger) + end end it 'configures Loga with a simple formatter' do @@ -29,7 +35,11 @@ context 'when production', if: Rails.env.production? do describe 'loga_initialize_logger' do it 'assign Loga logger to Rails logger' do - expect(Loga.logger).to equal(Rails.logger) + if defined?(ActiveSupport::BroadcastLogger) + expect(Loga.logger).to be_a(Logger) + else + expect(Loga.logger).to equal(Rails.logger) + end end it 'configures Loga with a structured formatter' do @@ -38,7 +48,7 @@ end it 'disables colorized logging' do - expect(app.config.colorize_logging).to eq(false) + expect(app.config.colorize_logging).to be(false) end end diff --git a/spec/integration/rails/request_spec.rb b/spec/integration/rails/request_spec.rb index 9e6f338..6b15931 100644 --- a/spec/integration/rails/request_spec.rb +++ b/spec/integration/rails/request_spec.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + require 'spec_helper' -RSpec.describe 'Structured logging with Rails', timecop: true, - if: Rails.env.production? do +RSpec.describe 'Structured logging with Rails', :timecop, + if: Rails.env.production? do let(:app) { Rails.application } let(:log_entries) do diff --git a/spec/integration/sidekiq5_spec.rb b/spec/integration/sidekiq5_spec.rb index 6bc175d..8555e86 100644 --- a/spec/integration/sidekiq5_spec.rb +++ b/spec/integration/sidekiq5_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'timecop' require 'fakeredis' @@ -24,8 +26,8 @@ def perform(_name); end attr_reader :latest_error, :mutex, :cond def initialize - @mutex = ::Mutex.new - @cond = ::ConditionVariable.new + @mutex = Mutex.new + @cond = ConditionVariable.new end def processor_died(_inst, err) @@ -84,7 +86,7 @@ def read_json_log(line:) aggregate_failures do expect(last_element['class']).to eq 'MySidekiqWorker' expect(last_element['args']).to eq ['Bob'] - expect(last_element['retry']).to eq true + expect(last_element['retry']).to be true expect(last_element['queue']).to eq 'default' end end @@ -107,16 +109,16 @@ def read_json_log(line:) aggregate_failures do expect(json_line).to include( - '_queue'=> 'default', - '_retry'=> true, - '_params'=> ['Bob'], - '_class'=> 'MySidekiqWorker', - '_type'=> 'sidekiq', - '_service.name'=> 'hello_world_app', - '_service.version'=> '1.0', - '_tags'=> '', - 'level'=> 6, - 'version'=> '1.1', + '_queue' => 'default', + '_retry' => true, + '_params' => ['Bob'], + '_class' => 'MySidekiqWorker', + '_type' => 'sidekiq', + '_service.name' => 'hello_world_app', + '_service.version' => '1.0', + '_tags' => '', + 'level' => 6, + 'version' => '1.1', ) %w[_created_at _enqueued_at _jid _duration timestamp host].each do |key| diff --git a/spec/integration/sidekiq60_spec.rb b/spec/integration/sidekiq60_spec.rb index b532fe9..4dcf870 100644 --- a/spec/integration/sidekiq60_spec.rb +++ b/spec/integration/sidekiq60_spec.rb @@ -31,8 +31,8 @@ def perform(_name) attr_reader :cond def initialize - @mutex = ::Mutex.new - @cond = ::ConditionVariable.new + @mutex = Mutex.new + @cond = ConditionVariable.new end def processor_died(_inst, err) @@ -103,7 +103,7 @@ def dump_log aggregate_failures do expect(last_element['class']).to eq 'MySidekiqWorker' expect(last_element['args']).to eq ['Bob'] - expect(last_element['retry']).to eq true + expect(last_element['retry']).to be true expect(last_element['queue']).to eq 'default' end end diff --git a/spec/integration/sidekiq61_spec.rb b/spec/integration/sidekiq61_spec.rb index 033641a..038a61c 100644 --- a/spec/integration/sidekiq61_spec.rb +++ b/spec/integration/sidekiq61_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'timecop' require 'fakeredis' @@ -27,8 +29,8 @@ def perform(_name) attr_reader :latest_error, :mutex, :cond def initialize - @mutex = ::Mutex.new - @cond = ::ConditionVariable.new + @mutex = Mutex.new + @cond = ConditionVariable.new end def processor_died(_inst, err) @@ -46,7 +48,7 @@ def options concurrency: 3, queues: ['default'], job_logger: Loga::Sidekiq6::JobLogger, - }.tap { |opts| opts[:fetch] = ::Sidekiq::BasicFetch.new(opts) } + }.tap { |opts| opts[:fetch] = Sidekiq::BasicFetch.new(opts) } end end end @@ -87,7 +89,7 @@ def read_json_log(line:) aggregate_failures do expect(last_element['class']).to eq 'MySidekiqWorker' expect(last_element['args']).to eq ['Bob'] - expect(last_element['retry']).to eq true + expect(last_element['retry']).to be true expect(last_element['queue']).to eq 'default' end end diff --git a/spec/integration/sidekiq65_spec.rb b/spec/integration/sidekiq65_spec.rb index a338eb5..849d243 100644 --- a/spec/integration/sidekiq65_spec.rb +++ b/spec/integration/sidekiq65_spec.rb @@ -75,7 +75,7 @@ def read_json_log(line:) aggregate_failures do expect(last_element['class']).to eq 'MySidekiqWorker' expect(last_element['args']).to eq ['Bob'] - expect(last_element['retry']).to eq true + expect(last_element['retry']).to be true expect(last_element['queue']).to eq 'default' end end diff --git a/spec/integration/sinatra_spec.rb b/spec/integration/sinatra_spec.rb index d27a93d..091f0a9 100644 --- a/spec/integration/sinatra_spec.rb +++ b/spec/integration/sinatra_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' class MySinatraApp < Sinatra::Base @@ -21,7 +23,7 @@ class MySinatraApp < Sinatra::Base 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 @@ -69,12 +71,12 @@ class MySinatraApp < Sinatra::Base 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 @@ -97,7 +99,7 @@ class MySinatraApp < Sinatra::Base let(:data) do super().merge( 'status' => 302, - 'path' => '/new', + 'path' => '/new', 'params' => {}, ) end @@ -112,14 +114,15 @@ class MySinatraApp < Sinatra::Base 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 diff --git a/spec/loga/sidekiq5/job_logger_spec.rb b/spec/loga/sidekiq5/job_logger_spec.rb index a8694a6..d156eaa 100644 --- a/spec/loga/sidekiq5/job_logger_spec.rb +++ b/spec/loga/sidekiq5/job_logger_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'loga/sidekiq5/job_logger' diff --git a/spec/loga/sidekiq6/job_logger_spec.rb b/spec/loga/sidekiq6/job_logger_spec.rb index c8a771d..9624c46 100644 --- a/spec/loga/sidekiq6/job_logger_spec.rb +++ b/spec/loga/sidekiq6/job_logger_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'loga/sidekiq6/job_logger' @@ -24,7 +26,7 @@ # https://github.com/mperham/sidekiq/blob/v6.1.2/lib/sidekiq/job_logger.rb it 'inherits from ::Sidekiq::JobLogger' do - expect(subject).to be_a(::Sidekiq::JobLogger) + expect(subject).to be_a(Sidekiq::JobLogger) end describe '#call' do diff --git a/spec/loga/sidekiq7/job_logger_spec.rb b/spec/loga/sidekiq7/job_logger_spec.rb index 2fdc3eb..bc25401 100644 --- a/spec/loga/sidekiq7/job_logger_spec.rb +++ b/spec/loga/sidekiq7/job_logger_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'loga/sidekiq7/job_logger' @@ -26,7 +28,7 @@ # https://github.com/mperham/sidekiq/blob/v6.1.2/lib/sidekiq/job_logger.rb it 'inherits from ::Sidekiq::JobLogger' do - expect(subject).to be_a(::Sidekiq::JobLogger) + expect(subject).to be_a(Sidekiq::JobLogger) end describe '#call' do diff --git a/spec/loga/sidekiq_spec.rb b/spec/loga/sidekiq_spec.rb index 83ec5a1..d58a64e 100644 --- a/spec/loga/sidekiq_spec.rb +++ b/spec/loga/sidekiq_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe Loga::Sidekiq do @@ -32,9 +34,9 @@ case m['version'] when '51' - expect(::Sidekiq.options[:job_logger]).to eq(Loga::Sidekiq5::JobLogger) + expect(Sidekiq.options[:job_logger]).to eq(Loga::Sidekiq5::JobLogger) when '6' - expect(::Sidekiq.options[:job_logger]).to eq(Loga::Sidekiq6::JobLogger) + expect(Sidekiq.options[:job_logger]).to eq(Loga::Sidekiq6::JobLogger) end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2bed20b..9ac1a01 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'byebug' require 'pry' require 'support/gethostname_shared' @@ -8,16 +10,17 @@ require 'simplecov' SimpleCov.start do - command_name "ruby-#{RUBY_VERSION}-#{File.basename(ENV['BUNDLE_GEMFILE'], '.gemfile')}" + command_name "ruby-#{RUBY_VERSION}-#{File.basename(ENV.fetch('BUNDLE_GEMFILE', nil), + '.gemfile')}" # Exclude specs from showing up in the code coverage report. add_filter 'spec/' end -case ENV['BUNDLE_GEMFILE'] +case ENV.fetch('BUNDLE_GEMFILE', nil) when /rails/ rspec_pattern = 'integration/rails/**/*_spec.rb' - /(?rails\d{2})\.gemfile/ =~ ENV['BUNDLE_GEMFILE'] + /(?rails\d{2})\.gemfile/ =~ ENV.fetch('BUNDLE_GEMFILE', nil) require 'rails' require 'action_mailer' require File.expand_path("../fixtures/#{appraisal}.rb", __FILE__) diff --git a/spec/support/gethostname_shared.rb b/spec/support/gethostname_shared.rb index 28590e0..b0eabbd 100644 --- a/spec/support/gethostname_shared.rb +++ b/spec/support/gethostname_shared.rb @@ -1,4 +1,6 @@ -shared_context 'gethostname', with_hostname: true do +# frozen_string_literal: true + +shared_context 'gethostname', :with_hostname do let(:hostname) { 'bird.example.com' } before do diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index bc2ac9d..14321c3 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bigdecimal' module Helpers diff --git a/spec/support/request_spec.rb b/spec/support/request_spec.rb index 739d319..1cdba1f 100644 --- a/spec/support/request_spec.rb +++ b/spec/support/request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.shared_examples 'request logger' do describe 'get request' do it 'logs the request' do @@ -6,23 +8,23 @@ 'HTTP_USER_AGENT' => 'Chrome', 'HTTP_X_REQUEST_ID' => '471a34dc' expect(last_log_entry).to include( - 'version' => '1.1', - 'host' => 'bird.example.com', - 'short_message' => 'GET /ok?username=yoshi 200 in 0ms', - 'timestamp' => 1_450_150_205.123, - 'level' => 6, - '_type' => 'request', - '_service.name' => 'hello_world_app', - '_service.version' => '1.0', - '_request.method' => 'GET', - '_request.path' => '/ok', - '_request.params' => { 'username' => 'yoshi' }, + 'version' => '1.1', + 'host' => 'bird.example.com', + 'short_message' => 'GET /ok?username=yoshi 200 in 0ms', + 'timestamp' => 1_450_150_205.123, + 'level' => 6, + '_type' => 'request', + '_service.name' => 'hello_world_app', + '_service.version' => '1.0', + '_request.method' => 'GET', + '_request.path' => '/ok', + '_request.params' => { 'username' => 'yoshi' }, '_request.request_ip' => '127.0.0.1', '_request.user_agent' => 'Chrome', - '_request.status' => 200, + '_request.status' => 200, '_request.request_id' => '471a34dc', - '_request.duration' => 0, - '_tags' => '471a34dc TEST_TAG', + '_request.duration' => 0, + '_tags' => '471a34dc TEST_TAG', ) end end @@ -36,23 +38,23 @@ 'HTTP_USER_AGENT' => 'Chrome', 'HTTP_X_REQUEST_ID' => '471a34dc' expect(last_log_entry).to include( - 'version' => '1.1', - 'host' => 'bird.example.com', - 'short_message' => 'POST /users?username=yoshi 200 in 0ms', - 'timestamp' => 1_450_150_205.123, - 'level' => 6, - '_type' => 'request', - '_service.name' => 'hello_world_app', - '_service.version' => '1.0', - '_request.method' => 'POST', - '_request.path' => '/users', - '_request.params' => { 'username' => 'yoshi', 'email' => 'hello@world.com' }, + 'version' => '1.1', + 'host' => 'bird.example.com', + 'short_message' => 'POST /users?username=yoshi 200 in 0ms', + 'timestamp' => 1_450_150_205.123, + 'level' => 6, + '_type' => 'request', + '_service.name' => 'hello_world_app', + '_service.version' => '1.0', + '_request.method' => 'POST', + '_request.path' => '/users', + '_request.params' => { 'username' => 'yoshi', 'email' => 'hello@world.com' }, '_request.request_ip' => '127.0.0.1', '_request.user_agent' => 'Chrome', - '_request.status' => 200, + '_request.status' => 200, '_request.request_id' => '471a34dc', - '_request.duration' => 0, - '_tags' => '471a34dc TEST_TAG', + '_request.duration' => 0, + '_tags' => '471a34dc TEST_TAG', ) end @@ -68,23 +70,23 @@ get '/new', {}, 'HTTP_USER_AGENT' => 'Chrome', 'HTTP_X_REQUEST_ID' => '471a34dc' expect(last_log_entry).to include( - 'version' => '1.1', - 'host' => 'bird.example.com', - 'short_message' => 'GET /new 302 in 0ms', - 'timestamp' => 1_450_150_205.123, - 'level' => 6, - '_type' => 'request', - '_service.name' => 'hello_world_app', - '_service.version' => '1.0', - '_request.method' => 'GET', - '_request.path' => '/new', - '_request.params' => {}, + 'version' => '1.1', + 'host' => 'bird.example.com', + 'short_message' => 'GET /new 302 in 0ms', + 'timestamp' => 1_450_150_205.123, + 'level' => 6, + '_type' => 'request', + '_service.name' => 'hello_world_app', + '_service.version' => '1.0', + '_request.method' => 'GET', + '_request.path' => '/new', + '_request.params' => {}, '_request.request_ip' => '127.0.0.1', '_request.user_agent' => 'Chrome', - '_request.status' => 302, + '_request.status' => 302, '_request.request_id' => '471a34dc', - '_request.duration' => 0, - '_tags' => '471a34dc TEST_TAG', + '_request.duration' => 0, + '_tags' => '471a34dc TEST_TAG', ) end end @@ -96,26 +98,26 @@ 'HTTP_USER_AGENT' => 'Chrome', 'HTTP_X_REQUEST_ID' => '471a34dc' expect(last_log_entry).to include( - 'version' => '1.1', - 'host' => 'bird.example.com', - 'short_message' => 'GET /error?username=yoshi 500 in 0ms', - 'timestamp' => 1_450_150_205.123, - 'level' => 3, - '_type' => 'request', - '_service.name' => 'hello_world_app', - '_service.version' => '1.0', - '_request.method' => 'GET', - '_request.path' => '/error', - '_request.params' => { 'username' => 'yoshi' }, - '_request.request_ip' => '127.0.0.1', - '_request.user_agent' => 'Chrome', - '_request.status' => 500, - '_request.request_id' => '471a34dc', - '_request.duration' => 0, - '_exception.klass' => 'NoMethodError', - '_exception.message' => "undefined method `name' for nil:NilClass", + 'version' => '1.1', + 'host' => 'bird.example.com', + 'short_message' => 'GET /error?username=yoshi 500 in 0ms', + 'timestamp' => 1_450_150_205.123, + 'level' => 3, + '_type' => 'request', + '_service.name' => 'hello_world_app', + '_service.version' => '1.0', + '_request.method' => 'GET', + '_request.path' => '/error', + '_request.params' => { 'username' => 'yoshi' }, + '_request.request_ip' => '127.0.0.1', + '_request.user_agent' => 'Chrome', + '_request.status' => 500, + '_request.request_id' => '471a34dc', + '_request.duration' => 0, + '_exception.klass' => 'NoMethodError', + '_exception.message' => start_with("undefined method `name' for nil"), '_exception.backtrace' => be_a(String), - '_tags' => '471a34dc TEST_TAG', + '_tags' => '471a34dc TEST_TAG', ) end end @@ -125,23 +127,23 @@ get '/not_found', {}, 'HTTP_X_REQUEST_ID' => '471a34dc' expect(last_log_entry).to include( - 'version' => '1.1', - 'host' => 'bird.example.com', - 'short_message' => 'GET /not_found 404 in 0ms', - 'timestamp' => 1_450_150_205.123, - 'level' => 6, - '_type' => 'request', - '_service.name' => 'hello_world_app', - '_service.version' => '1.0', - '_request.method' => 'GET', - '_request.path' => '/not_found', - '_request.params' => {}, - '_request.request_ip' => '127.0.0.1', - '_request.user_agent' => nil, - '_request.status' => 404, - '_request.request_id' => '471a34dc', - '_request.duration' => 0, - '_tags' => '471a34dc TEST_TAG', + 'version' => '1.1', + 'host' => 'bird.example.com', + 'short_message' => 'GET /not_found 404 in 0ms', + 'timestamp' => 1_450_150_205.123, + 'level' => 6, + '_type' => 'request', + '_service.name' => 'hello_world_app', + '_service.version' => '1.0', + '_request.method' => 'GET', + '_request.path' => '/not_found', + '_request.params' => {}, + '_request.request_ip' => '127.0.0.1', + '_request.user_agent' => nil, + '_request.status' => 404, + '_request.request_id' => '471a34dc', + '_request.duration' => 0, + '_tags' => '471a34dc TEST_TAG', ) end end @@ -188,9 +190,9 @@ bob_file: Rack::Test::UploadedFile.new('spec/fixtures/random_bin') expect(last_log_entry).to include( - 'short_message' => 'POST /users?username=yoshi 200 in 0ms', - 'level' => 6, - '_request.params' => { + 'short_message' => 'POST /users?username=yoshi 200 in 0ms', + 'level' => 6, + '_request.params' => { 'username' => 'yoshi', 'bob_file' => include( 'filename' => 'random_bin', diff --git a/spec/support/timecop_shared.rb b/spec/support/timecop_shared.rb index d27955e..494697f 100644 --- a/spec/support/timecop_shared.rb +++ b/spec/support/timecop_shared.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + require 'timecop' -shared_context 'timecop', timecop: true do +shared_context 'timecop', :timecop do # Allows fixed timestamps before(:all) { Timecop.freeze(time_anchor) } diff --git a/spec/unit/loga/configuration_spec.rb b/spec/unit/loga/configuration_spec.rb index 5e0b432..0e59bb7 100644 --- a/spec/unit/loga/configuration_spec.rb +++ b/spec/unit/loga/configuration_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Loga::Configuration do @@ -20,8 +22,8 @@ allow(Loga::ServiceVersionStrategies).to receive(:call).and_return('unknown.sha') end - context 'defaults', with_hostname: true do - specify { expect(subject.device).to eq(STDOUT) } + context 'defaults', :with_hostname do + specify { expect(subject.device).to eq($stdout) } specify { expect(subject.filter_exceptions).to eq(framework_exceptions) } specify { expect(subject.filter_parameters).to eq([]) } specify { expect(subject.format).to eq(:simple) } @@ -29,7 +31,7 @@ specify { expect(subject.level).to eq(:info) } specify { expect(subject.service_name).to eq('hello_world_app') } specify { expect(subject.service_version).to eq('unknown.sha') } - specify { expect(subject.sync).to eq(true) } + specify { expect(subject.sync).to be(true) } specify { expect(subject.tags).to eq([]) } end @@ -174,11 +176,11 @@ let(:logdev) { subject.logger.instance_variable_get(:@logdev) } { - debug: 0, - info: 1, - warn: 2, - error: 3, - fatal: 4, + debug: 0, + info: 1, + warn: 2, + error: 3, + fatal: 4, unknown: 5, }.each do |sym, level| context "when log level is #{sym}" do @@ -194,7 +196,7 @@ let(:options) { super().merge(sync: false) } it 'uses warn log level' do - expect(logdev.dev.sync).to eq(false) + expect(logdev.dev.sync).to be(false) end end end diff --git a/spec/unit/loga/event_spec.rb b/spec/unit/loga/event_spec.rb index 2efb923..1555d72 100644 --- a/spec/unit/loga/event_spec.rb +++ b/spec/unit/loga/event_spec.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' -RSpec.describe Loga::Event, timecop: true do +RSpec.describe Loga::Event, :timecop do describe 'initialize' do context 'when no message is passed' do it 'sets message to an empty string' do @@ -9,7 +11,7 @@ end context 'when message is passed' do - let(:message) { "stuff \xC2".force_encoding 'ASCII-8BIT' } + let(:message) { "stuff \xC2".dup.force_encoding 'ASCII-8BIT' } let(:subject) { described_class.new message: message } it 'sanitizes the input to be UTF-8 convertable' do diff --git a/spec/unit/loga/formatters/gelf_formatter_spec.rb b/spec/unit/loga/formatters/gelf_formatter_spec.rb index 94955d0..90c2b80 100644 --- a/spec/unit/loga/formatters/gelf_formatter_spec.rb +++ b/spec/unit/loga/formatters/gelf_formatter_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Loga::Formatters::GELFFormatter do @@ -8,25 +10,25 @@ let(:host) { 'www.example.com' } let(:params) do { - service_name: service_name, + service_name: service_name, service_version: service_version, - host: host, + host: host, } end shared_examples 'valid GELF message' do it 'includes the required fields' do - expect(json).to include('version' => '1.1', - 'host' => host, + expect(json).to include('version' => '1.1', + 'host' => host, 'short_message' => be_a(String), - 'timestamp' => be_a(Float), - 'level' => 6) + 'timestamp' => be_a(Float), + 'level' => 6) end it 'includes Loga additional fields' do - expect(json).to include('_service.name' => service_name, + expect(json).to include('_service.name' => service_name, '_service.version' => service_version, - '_tags' => '') + '_tags' => '') end it 'outputs the timestamp in seconds since UNIX epoch' do @@ -233,11 +235,11 @@ class << self end { - 'DEBUG' => 7, - 'INFO' => 6, - 'WARN' => 4, - 'ERROR' => 3, - 'FATAL' => 2, + 'DEBUG' => 7, + 'INFO' => 6, + 'WARN' => 4, + 'ERROR' => 3, + 'FATAL' => 2, 'UNKNOWN' => 1, }.each do |ruby_severity, syslog_level| context "with severity #{ruby_severity}" do diff --git a/spec/unit/loga/formatters/simple_formatter_spec.rb b/spec/unit/loga/formatters/simple_formatter_spec.rb index 4a6d969..627cbec 100644 --- a/spec/unit/loga/formatters/simple_formatter_spec.rb +++ b/spec/unit/loga/formatters/simple_formatter_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'loga/formatters/simple_formatter' @@ -112,11 +114,11 @@ end { - 'DEBUG' => 'D', - 'INFO' => 'I', - 'WARN' => 'W', - 'ERROR' => 'E', - 'FATAL' => 'F', + 'DEBUG' => 'D', + 'INFO' => 'I', + 'WARN' => 'W', + 'ERROR' => 'E', + 'FATAL' => 'F', 'UNKNOWN' => 'U', }.each do |ruby_severity, formatted_severity| context "with severity #{ruby_severity}" do diff --git a/spec/unit/loga/log_subscribers/action_mailer_spec.rb b/spec/unit/loga/log_subscribers/action_mailer_spec.rb index 3b71425..d270a1e 100644 --- a/spec/unit/loga/log_subscribers/action_mailer_spec.rb +++ b/spec/unit/loga/log_subscribers/action_mailer_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'active_support' require 'loga/log_subscribers/action_mailer' @@ -9,7 +11,7 @@ let(:event) do instance_double( - 'ActiveSupport::Notifications::Event', + ActiveSupport::Notifications::Event, payload: payload, duration: 0.0001, time: Time.now, @@ -21,7 +23,7 @@ let(:payload) do { mailer: 'FakeMailer', - to: ['user@example.com'], + to: ['user@example.com'], } end let(:config) { instance_double Loga::Configuration, hide_pii: hide_pii } @@ -82,8 +84,8 @@ context 'when an email is sent' do let(:payload) do { - mailer: 'FakeMailer', - from: 'loremipsum@example.com', + mailer: 'FakeMailer', + from: 'loremipsum@example.com', subject: 'Lorem ipsum', } end diff --git a/spec/unit/loga/parameter_filter_spec.rb b/spec/unit/loga/parameter_filter_spec.rb index 75968e3..273542b 100644 --- a/spec/unit/loga/parameter_filter_spec.rb +++ b/spec/unit/loga/parameter_filter_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe Loga::ParameterFilter do diff --git a/spec/unit/loga/rack/logger_spec.rb b/spec/unit/loga/rack/logger_spec.rb index f1ff6f2..b193026 100644 --- a/spec/unit/loga/rack/logger_spec.rb +++ b/spec/unit/loga/rack/logger_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'rack/test' @@ -40,22 +42,22 @@ middleware.call(env, started_at) expect(Loga::Event).to have_received(:new).with( - data: { + data: { request: { - 'status' => response_status, - 'method' => 'GET', - 'path' => '/about_us', - 'params' => { 'limit' => '1' }, + 'status' => response_status, + 'method' => 'GET', + 'path' => '/about_us', + 'params' => { 'limit' => '1' }, 'request_id' => nil, 'request_ip' => nil, 'user_agent' => nil, - 'duration' => 500, + 'duration' => 500, }, }, exception: logged_exception, - message: %r{^GET \/about_us\?limit=1 #{response_status} in \d+ms$}, + message: %r{^GET /about_us\?limit=1 #{response_status} in \d+ms$}, timestamp: started_at, - type: 'request', + type: 'request', ) end @@ -82,22 +84,22 @@ expect { middleware.call(env, started_at) }.to raise_error(exception_class) expect(Loga::Event).to have_received(:new).with( - data: { + data: { request: { - 'status' => response_status, - 'method' => 'GET', - 'path' => '/about_us', - 'params' => { 'limit' => '1' }, + 'status' => response_status, + 'method' => 'GET', + 'path' => '/about_us', + 'params' => { 'limit' => '1' }, 'request_id' => nil, 'request_ip' => nil, 'user_agent' => nil, - 'duration' => 500, + 'duration' => 500, }, }, exception: logged_exception, - message: %r{^GET \/about_us\?limit=1 #{response_status} in \d+ms$}, + message: %r{^GET /about_us\?limit=1 #{response_status} in \d+ms$}, timestamp: started_at, - type: 'request', + type: 'request', ) end end diff --git a/spec/unit/loga/rack/request_spec.rb b/spec/unit/loga/rack/request_spec.rb index f2413df..7d405ed 100644 --- a/spec/unit/loga/rack/request_spec.rb +++ b/spec/unit/loga/rack/request_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Loga::Rack::Request do diff --git a/spec/unit/loga/service_version_strategies_spec.rb b/spec/unit/loga/service_version_strategies_spec.rb index 7b49a0f..73fe172 100644 --- a/spec/unit/loga/service_version_strategies_spec.rb +++ b/spec/unit/loga/service_version_strategies_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe Loga::ServiceVersionStrategies do diff --git a/spec/unit/loga/utilities_spec.rb b/spec/unit/loga/utilities_spec.rb index 4d9162e..34fc186 100644 --- a/spec/unit/loga/utilities_spec.rb +++ b/spec/unit/loga/utilities_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Loga::Utilities do diff --git a/spec/unit/loga_spec.rb b/spec/unit/loga_spec.rb index 1a45f30..3632c7e 100644 --- a/spec/unit/loga_spec.rb +++ b/spec/unit/loga_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Loga do @@ -64,7 +66,7 @@ context 'when Loga is configured' do before { subject.configure(options) } - specify { expect(subject.logger).to be_kind_of(Logger) } + specify { expect(subject.logger).to be_a(Logger) } end end