Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RSpec/NamedSubject RuboCop offenses manually #232

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 2 additions & 30 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,50 +31,22 @@ RSpec/DescribeClass:
- '**/spec/views/**/*'
- 'spec/integration/influxdb_rails_sends_metrics_spec.rb'

# Offense count: 36
# Offense count: 35
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 19

# Offense count: 5
# Offense count: 1
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Include: **/*_spec*rb*, **/spec/**/*
RSpec/FilePath:
Exclude:
- 'spec/unit/block_instrumentation_spec.rb'
- 'spec/unit/configuration_spec.rb'
- 'spec/unit/sql/normalizer_spec.rb'
- 'spec/unit/sql/query_spec.rb'
- 'spec/unit/tags.rb'

# Offense count: 3
RSpec/MultipleExpectations:
Max: 2

# Offense count: 15
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Exclude:
- 'spec/unit/configuration_spec.rb'
- 'spec/unit/sql/query_spec.rb'

# Offense count: 2
RSpec/RepeatedDescription:
Exclude:
- 'spec/requests/active_record_sql_metrics_spec.rb'

# Offense count: 4
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
# Include: **/*_spec.rb
RSpec/SpecFilePathFormat:
Exclude:
- '**/spec/routing/**/*'
- 'spec/unit/block_instrumentation_spec.rb'
- 'spec/unit/configuration_spec.rb'
- 'spec/unit/sql/normalizer_spec.rb'
- 'spec/unit/sql/query_spec.rb'

# Offense count: 1
# Configuration parameters: Include.
# Include: **/*_spec*rb*, **/spec/**/*
Expand Down
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
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
Loading