Skip to content

Commit

Permalink
Fix RSpec/NamedSubject RuboCop offenses manually
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoj committed May 28, 2024
1 parent ed20a20 commit e169104
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
8 changes: 0 additions & 8 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*
Expand Down
28 changes: 14 additions & 14 deletions spec/unit/influx_db/rails/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/influx_db/rails/sql/query_spec.rb
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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
Expand Down

0 comments on commit e169104

Please sign in to comment.