Skip to content

Commit

Permalink
Update Rubocop config, fix offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
n-rodriguez committed Sep 25, 2024
1 parent 02d96b2 commit 2dae118
Show file tree
Hide file tree
Showing 65 changed files with 790 additions and 747 deletions.
49 changes: 45 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
require:
- rubocop-performance
- rubocop-rake
# - rubocop-rspec
- rubocop-rspec

AllCops:
NewCops: enable
TargetRubyVersion: 2.7
Exclude:
- bin/*
- gemfiles/*
- spec/**/*
- lib/netbox-client-ruby.rb

Style/Documentation:
Expand All @@ -25,9 +24,51 @@ Style/TrailingCommaInHashLiteral:
Style/AccessModifierDeclarations:
Enabled: false

Style/OpenStructUse:
Enabled: false

Layout/LineLength:
Exclude:
- lib/netbox_client_ruby/api/secrets/session_key.rb

# RSpec/NotToNot:
# EnforcedStyle: to_not
RSpec/NotToNot:
EnforcedStyle: to_not

RSpec/MessageSpies:
EnforcedStyle: receive

RSpec/MetadataStyle:
EnforcedStyle: hash

RSpec/ExampleLength:
Max: 7

RSpec/NestedGroups:
Max: 5

RSpec/MultipleExpectations:
Max: 9

RSpec/MultipleMemoizedHelpers:
Max: 11

RSpec/NamedSubject:
Enabled: false

RSpec/ContextWording:
Enabled: false

Lint/ConstantDefinitionInBlock:
Enabled: false

RSpec/LeakyConstantDeclaration:
Enabled: false

RSpec/SpecFilePathFormat:
Enabled: false

RSpec/IteratedExpectation:
Enabled: false

RSpec/VerifiedDoubles:
Enabled: false
28 changes: 14 additions & 14 deletions spec/netbox_client_ruby/api/circuits/circuit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
require 'spec_helper'

RSpec.describe NetboxClientRuby::Circuits::Circuit, faraday_stub: true do
subject { described_class.new id }

let(:id) { 1 }
let(:base_url) { '/api/circuits/circuits/' }
let(:request_url) { "#{base_url}#{id}.json" }
let(:response) { File.read("spec/fixtures/circuits/circuit_#{id}.json") }

subject { described_class.new id }

describe '#id' do
it 'shall be the expected id' do
expect(subject.id).to eq(id)
end
end

describe '#description' do
it 'should fetch the data' do
it 'fetches the data' do
expect(faraday).to receive(:get).and_call_original

subject.description
Expand All @@ -29,23 +29,23 @@
end

describe '.tenant' do
it 'should be a Tenant object' do
it 'is a Tenant object' do
tenant = subject.tenant
expect(tenant).to be_a NetboxClientRuby::Tenancy::Tenant
expect(tenant.id).to eq(1)
end
end

describe '.provider' do
it 'should be a Provider object' do
it 'is a Provider object' do
provider = subject.provider
expect(provider).to be_a NetboxClientRuby::Circuits::Provider
expect(provider.id).to eq(1)
end
end

describe '.type' do
it 'should be a Type object' do
it 'is a Type object' do
provider = subject.type
expect(provider).to be_a NetboxClientRuby::Circuits::CircuitType
expect(provider.id).to eq(1)
Expand All @@ -57,7 +57,7 @@
let(:response_status) { 204 }
let(:response) { nil }

it 'should delete the object' do
it 'deletes the object' do
expect(faraday).to receive(request_method).and_call_original
subject.delete
end
Expand All @@ -67,14 +67,14 @@
let(:request_method) { :patch }
let(:request_params) { { 'description' => 'noob' } }

it 'should update the object' do
it 'updates the object' do
expect(faraday).to receive(request_method).and_call_original
expect(subject.update(description: 'noob').description).to eq('Desc of Circuit 0')
end
end

describe '.reload' do
it 'should reload the object' do
it 'reloads the object' do
expect(faraday).to receive(request_method).twice.and_call_original

subject.reload
Expand All @@ -87,14 +87,14 @@
let(:request_params) { { 'description' => description } }

context 'update' do
let(:request_method) { :patch }

subject do
entity = described_class.new id
entity.description = description
entity
end

let(:request_method) { :patch }

it 'does not call PATCH until save is called' do
expect(faraday).to_not receive(request_method)
expect(faraday).to_not receive(:get)
Expand All @@ -117,15 +117,15 @@
end

context 'create' do
let(:request_method) { :post }
let(:request_url) { base_url }

subject do
entity = described_class.new
entity.description = description
entity
end

let(:request_method) { :post }
let(:request_url) { base_url }

it 'does not POST until save is called' do
expect(faraday).to_not receive(request_method)
expect(faraday).to_not receive(:get)
Expand Down
24 changes: 12 additions & 12 deletions spec/netbox_client_ruby/api/circuits/circuit_termination_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
require 'spec_helper'

RSpec.describe NetboxClientRuby::Circuits::CircuitTermination, faraday_stub: true do
subject { described_class.new id }

let(:id) { 1 }
let(:base_url) { '/api/circuits/circuit-terminations/' }
let(:request_url) { "#{base_url}#{id}.json" }
let(:response) { File.read("spec/fixtures/circuits/circuit-termination_#{id}.json") }

subject { described_class.new id }

describe '#id' do
it 'shall be the expected id' do
expect(subject.id).to eq(id)
end
end

describe '#term_side' do
it 'should fetch the data' do
it 'fetches the data' do
expect(faraday).to receive(:get).and_call_original

subject.term_side
Expand All @@ -29,7 +29,7 @@
end

describe '.site' do
it 'should be a Site object' do
it 'is a Site object' do
site = subject.site
expect(site).to be_a NetboxClientRuby::DCIM::Site
expect(site.id).to eq(1)
Expand All @@ -41,7 +41,7 @@
let(:response_status) { 204 }
let(:response) { nil }

it 'should delete the object' do
it 'deletes the object' do
expect(faraday).to receive(request_method).and_call_original
subject.delete
end
Expand All @@ -51,14 +51,14 @@
let(:request_method) { :patch }
let(:request_params) { { 'term_side' => 'noob' } }

it 'should update the object' do
it 'updates the object' do
expect(faraday).to receive(request_method).and_call_original
expect(subject.update(term_side: 'noob').term_side).to eq('A')
end
end

describe '.reload' do
it 'should reload the object' do
it 'reloads the object' do
expect(faraday).to receive(request_method).twice.and_call_original

subject.reload
Expand All @@ -71,14 +71,14 @@
let(:request_params) { { 'term_side' => term_side } }

context 'update' do
let(:request_method) { :patch }

subject do
entity = described_class.new id
entity.term_side = term_side
entity
end

let(:request_method) { :patch }

it 'does not call PATCH until save is called' do
expect(faraday).to_not receive(request_method)
expect(faraday).to_not receive(:get)
Expand All @@ -101,15 +101,15 @@
end

context 'create' do
let(:request_method) { :post }
let(:request_url) { base_url }

subject do
entity = described_class.new
entity.term_side = term_side
entity
end

let(:request_method) { :post }
let(:request_url) { base_url }

it 'does not POST until save is called' do
expect(faraday).to_not receive(request_method)
expect(faraday).to_not receive(:get)
Expand Down
22 changes: 11 additions & 11 deletions spec/netbox_client_ruby/api/circuits/circuit_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
require 'spec_helper'

RSpec.describe NetboxClientRuby::Circuits::CircuitType, faraday_stub: true do
subject { described_class.new id }

let(:id) { 1 }
let(:base_url) { '/api/circuits/circuit-types/' }
let(:request_url) { "#{base_url}#{id}.json" }
let(:response) { File.read("spec/fixtures/circuits/circuit-type_#{id}.json") }

subject { described_class.new id }

describe '#id' do
it 'shall be the expected id' do
expect(subject.id).to eq(id)
end
end

describe '#name' do
it 'should fetch the data' do
it 'fetches the data' do
expect(faraday).to receive(:get).and_call_original

subject.name
Expand All @@ -33,7 +33,7 @@
let(:response_status) { 204 }
let(:response) { nil }

it 'should delete the object' do
it 'deletes the object' do
expect(faraday).to receive(request_method).and_call_original
subject.delete
end
Expand All @@ -43,14 +43,14 @@
let(:request_method) { :patch }
let(:request_params) { { 'name' => 'noob' } }

it 'should update the object' do
it 'updates the object' do
expect(faraday).to receive(request_method).and_call_original
expect(subject.update(name: 'noob').name).to eq('Circuit Type 0')
end
end

describe '.reload' do
it 'should reload the object' do
it 'reloads the object' do
expect(faraday).to receive(request_method).twice.and_call_original

subject.reload
Expand All @@ -63,14 +63,14 @@
let(:request_params) { { 'name' => name } }

context 'update' do
let(:request_method) { :patch }

subject do
entity = described_class.new id
entity.name = name
entity
end

let(:request_method) { :patch }

it 'does not call PATCH until save is called' do
expect(faraday).to_not receive(request_method)
expect(faraday).to_not receive(:get)
Expand All @@ -93,15 +93,15 @@
end

context 'create' do
let(:request_method) { :post }
let(:request_url) { base_url }

subject do
entity = described_class.new
entity.name = name
entity
end

let(:request_method) { :post }
let(:request_url) { base_url }

it 'does not POST until save is called' do
expect(faraday).to_not receive(request_method)
expect(faraday).to_not receive(:get)
Expand Down
Loading

0 comments on commit 2dae118

Please sign in to comment.