From 61a06331be93a082de895d3af623cb2b562900be Mon Sep 17 00:00:00 2001 From: Andrey Novikov Date: Thu, 3 Aug 2023 20:45:08 +0900 Subject: [PATCH] Fix rubocop warnings --- .rubocop.yml | 2 +- lib/yabeda/rails/config.rb | 1 + lib/yabeda/rails/event.rb | 1 + spec/yabeda/rails_spec.rb | 25 +++++++++++++++---------- yabeda-rails.gemspec | 2 +- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ceedffe..cd0a443 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ require: - rubocop-rspec AllCops: - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.5 Metrics/BlockLength: Exclude: diff --git a/lib/yabeda/rails/config.rb b/lib/yabeda/rails/config.rb index a3eb92b..0c10ea5 100644 --- a/lib/yabeda/rails/config.rb +++ b/lib/yabeda/rails/config.rb @@ -4,6 +4,7 @@ module Yabeda module Rails + # yabeda-rails configuration class Config < ::Anyway::Config config_name :yabeda_rails diff --git a/lib/yabeda/rails/event.rb b/lib/yabeda/rails/event.rb index 5d526d3..e991a3f 100644 --- a/lib/yabeda/rails/event.rb +++ b/lib/yabeda/rails/event.rb @@ -2,6 +2,7 @@ module Yabeda module Rails + # ActiveSupport Event with added logic for Yabeda tags formatting class Event < ActiveSupport::Notifications::Event def labels @labels ||= begin diff --git a/spec/yabeda/rails_spec.rb b/spec/yabeda/rails_spec.rb index e02ddbd..37be964 100644 --- a/spec/yabeda/rails_spec.rb +++ b/spec/yabeda/rails_spec.rb @@ -30,15 +30,20 @@ def app .with_tags(controller: "hello", action: "internal_server_error", status: 500, method: "get", format: :html) end - it "supports configuring controller name case" do - original_case = described_class.config.controller_name_case - described_class.config.controller_name_case = :camel - - expect { get "/hello/world" }.to \ - increment_yabeda_counter(Yabeda.rails.requests_total) - .with_tags(controller: "HelloController", action: "world", status: 200, method: "get", format: :html) - .by(1) - - described_class.config.controller_name_case = original_case + context "with changed controller name case config tp camel case" do + around do |example| + original_case = described_class.config.controller_name_case + described_class.config.controller_name_case = :camel + example.call + ensure + described_class.config.controller_name_case = original_case + end + + it "reports controller tag in camel case" do + expect { get "/hello/world" }.to \ + increment_yabeda_counter(Yabeda.rails.requests_total) + .with_tags(controller: "HelloController", action: "world", status: 200, method: "get", format: :html) + .by(1) + end end end diff --git a/yabeda-rails.gemspec b/yabeda-rails.gemspec index 4947c9e..5ccc535 100644 --- a/yabeda-rails.gemspec +++ b/yabeda-rails.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.required_ruby_version = ">= 2.4" + spec.required_ruby_version = ">= 2.5" spec.add_dependency "activesupport" spec.add_dependency "anyway_config", ">= 1.3", "< 3"