From e1691042f5cfeabf2d89553c334d4457eb6c95e8 Mon Sep 17 00:00:00 2001 From: Eduardo Navarro Date: Tue, 28 May 2024 14:18:30 +0200 Subject: [PATCH] Fix RSpec/NamedSubject RuboCop offenses manually --- .rubocop_todo.yml | 8 ------ .../influx_db/rails/configuration_spec.rb | 28 +++++++++---------- spec/unit/influx_db/rails/sql/query_spec.rb | 6 ++-- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c79bc65..97efd6e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -47,14 +47,6 @@ RSpec/FilePath: RSpec/MultipleExpectations: Max: 2 -# Offense count: 15 -# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. -# SupportedStyles: always, named_only -RSpec/NamedSubject: - Exclude: - - 'spec/unit/influx_db/rails/configuration_spec.rb' - - 'spec/unit/influx_db/rails/sql/query_spec.rb' - # Offense count: 1 # Configuration parameters: Include. # Include: **/*_spec*rb*, **/spec/**/* diff --git a/spec/unit/influx_db/rails/configuration_spec.rb b/spec/unit/influx_db/rails/configuration_spec.rb index e9dcd07..62f16a4 100644 --- a/spec/unit/influx_db/rails/configuration_spec.rb +++ b/spec/unit/influx_db/rails/configuration_spec.rb @@ -6,84 +6,84 @@ end describe "client configuration" do - subject { InfluxDB::Rails.configuration.client } + subject(:configuration_client) { InfluxDB::Rails.configuration.client } describe "#max_retries" do it "defaults to 0" do - expect(subject.max_retries).to eq(0) + expect(configuration_client.max_retries).to eq(0) end it "can be updated" do InfluxDB::Rails.configure do |config| config.client.max_retries = 5 end - expect(subject.max_retries).to be(5) - expect(subject.write_options.max_retries).to be(5) + expect(configuration_client.max_retries).to be(5) + expect(configuration_client.write_options.max_retries).to be(5) end end describe "#open_timeout" do it "defaults to 5 seconds" do - expect(subject.open_timeout).to be(5) + expect(configuration_client.open_timeout).to be(5) end it "can be updated" do InfluxDB::Rails.configure do |config| config.client.open_timeout = 5 end - expect(subject.open_timeout).to be(5) + expect(configuration_client.open_timeout).to be(5) end end describe "#write_timeout" do it "defaults to 5 seconds" do - expect(subject.write_timeout).to be(5) + expect(configuration_client.write_timeout).to be(5) end it "can be updated" do InfluxDB::Rails.configure do |config| config.client.write_timeout = 5 end - expect(subject.write_timeout).to be(5) + expect(configuration_client.write_timeout).to be(5) end end describe "#read_timeout" do it "defaults to 60 seconds" do - expect(subject.read_timeout).to be(60) + expect(configuration_client.read_timeout).to be(60) end it "can be updated" do InfluxDB::Rails.configure do |config| config.client.read_timeout = 5 end - expect(subject.read_timeout).to be(5) + expect(configuration_client.read_timeout).to be(5) end end describe "#precision" do it "defaults to milli seconds" do - expect(subject.precision).to eql(InfluxDB2::WritePrecision::MILLISECOND) + expect(configuration_client.precision).to eql(InfluxDB2::WritePrecision::MILLISECOND) end it "can be updated" do InfluxDB::Rails.configure do |config| config.client.precision = InfluxDB2::WritePrecision::NANOSECOND end - expect(subject.precision).to eql(InfluxDB2::WritePrecision::NANOSECOND) + expect(configuration_client.precision).to eql(InfluxDB2::WritePrecision::NANOSECOND) end end describe "#async" do it "set write_type to batching by default" do - expect(subject.write_options.write_type).to eql(InfluxDB2::WriteType::BATCHING) + expect(configuration_client.write_options.write_type).to eql(InfluxDB2::WriteType::BATCHING) end it "can be updated" do InfluxDB::Rails.configure do |config| config.client.async = false end - expect(subject.write_options.write_type).to eql(InfluxDB2::WriteType::SYNCHRONOUS) + expect(configuration_client.write_options.write_type).to eql(InfluxDB2::WriteType::SYNCHRONOUS) end end end diff --git a/spec/unit/influx_db/rails/sql/query_spec.rb b/spec/unit/influx_db/rails/sql/query_spec.rb index 4ab3d3d..e87da78 100644 --- a/spec/unit/influx_db/rails/sql/query_spec.rb +++ b/spec/unit/influx_db/rails/sql/query_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" RSpec.describe InfluxDB::Rails::Sql::Query do - subject { described_class.new(payload) } + subject(:sql_query_with_payload) { described_class.new(payload) } let(:payload) do { @@ -11,11 +11,11 @@ end describe "#class_name" do - it { expect(subject.class_name).to eq("User") } + it { expect(sql_query_with_payload.class_name).to eq("User") } end describe "#operation" do - it { expect(subject.operation).to eq("SELECT") } + it { expect(sql_query_with_payload.operation).to eq("SELECT") } end describe "#track?" do