Skip to content

Commit

Permalink
Improve Rubocop config, fix offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
n-rodriguez committed Aug 31, 2024
1 parent a4dcf87 commit 697eeb8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
9 changes: 8 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ AllCops:
Exclude:
- bin/*
- gemfiles/*
- spec/**/*
- spec/dummy/**/*

Gemspec/RequireMFA:
Enabled: false
Expand Down Expand Up @@ -44,3 +44,10 @@ Layout/EmptyLinesAroundBlockBody:

Layout/EmptyLinesAroundModuleBody:
Enabled: false

#########
# RSPEC #
#########

RSpec/InstanceVariable:
Enabled: false
6 changes: 4 additions & 2 deletions spec/config_rspec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Configure RSpec
RSpec.configure do |config|
# Use DB agnostic schema by default
Expand All @@ -15,11 +17,11 @@
DatabaseCleaner.clean_with(:truncation)
end

config.before(:each) do
config.before do
DatabaseCleaner.start
end

config.after(:each) do
config.after do
DatabaseCleaner.clean
end
end
8 changes: 5 additions & 3 deletions spec/lib/auto_increment/active_record_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

require 'spec_helper'

describe AutoIncrement::ActiveRecord do
before :all do
before :all do # rubocop:disable RSpec/BeforeAfterAll
@account1 = Account.create name: 'My Account'
@account2 = Account.create name: 'Another Account', code: 50

Expand Down Expand Up @@ -29,7 +31,7 @@
end

describe 'locks query for increment' do
before :all do
before :all do # rubocop:disable RSpec/BeforeAfterAll
threads = []
lock = Mutex.new
@account = Account.create name: 'Another Account', code: 50
Expand All @@ -47,7 +49,7 @@
end

let(:account_last_letter_code) do
@accounts.sort_by(&:letter_code).last.letter_code
@accounts.sort_by(&:letter_code).last.letter_code # rubocop:disable Style/RedundantSort
end

it { expect(@accounts.size).to eq 25 }
Expand Down
14 changes: 7 additions & 7 deletions spec/lib/auto_increment/incrementor_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

describe AutoIncrement::Incrementor do
Expand All @@ -12,20 +14,18 @@
}.each do |previous_value, next_value|
describe "increment value for #{previous_value}" do
it do
allow(subject).to receive(:maximum) { previous_value }
expect(subject.send(:increment)).to eq next_value
allow(subject).to receive(:maximum) { previous_value } # rubocop:disable RSpec/SubjectStub, RSpec/NamedSubject
expect(subject.send(:increment)).to eq next_value # rubocop:disable RSpec/NamedSubject
end
end
end

describe 'initial value of string' do
subject do
AutoIncrement::Incrementor.new initial: 'A'
end
subject(:incrementor) { described_class.new initial: 'A' }

it do
allow(subject).to receive(:maximum) { nil }
expect(subject.send(:increment)).to eq 'A'
allow(incrementor).to receive(:maximum).and_return(nil) # rubocop:disable RSpec/SubjectStub
expect(incrementor.send(:increment)).to eq 'A'
end
end
end

0 comments on commit 697eeb8

Please sign in to comment.