Skip to content

Commit

Permalink
chore(lint): lint'em real good
Browse files Browse the repository at this point in the history
  • Loading branch information
mhenrixon committed Feb 12, 2024
1 parent 81cc875 commit f65ecbc
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 48 deletions.
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ RSpec/RepeatedExample:
Exclude:
- spec/sidekiq_unique_jobs/unique_args_spec.rb

RSpec/SpecFilePathFormat:
Exclude:
- spec/performance/**/*
- spec/sidekiq_unique_jobs/configuration_spec.rb
- spec/sidekiq_unique_jobs/middleware/server/until_and_while_executing_spec.rb

Style/Documentation:
Enabled: true
Exclude:
Expand Down
2 changes: 1 addition & 1 deletion lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def configure(options = {})
yield config
else
options.each do |key, val|
config.send("#{key}=", val)
config.send(:"#{key}=", val)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/performance/lock_digest_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

RSpec.describe SidekiqUniqueJobs::LockDigest, perf: true do
RSpec.describe SidekiqUniqueJobs::LockDigest, :perf do
let(:lock_digest) { described_class.new(item) }
let(:job_class) { UntilExecutedJob }
let(:class_name) { worker_class.to_s }
Expand Down
2 changes: 1 addition & 1 deletion spec/performance/locksmith_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

RSpec.describe SidekiqUniqueJobs::Locksmith, perf: true do
RSpec.describe SidekiqUniqueJobs::Locksmith, :perf do
let(:locksmith_one) { described_class.new(item_one) }
let(:locksmith_two) { described_class.new(item_two) }

Expand Down
26 changes: 13 additions & 13 deletions spec/sidekiq_unique_jobs/changelog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@

it "clears out all entries" do
expect { clear }.to change { entity.entries.size }.by(-1)
expect(clear).to be == 1
expect(clear).to eq 1
end
end

context "without entries" do
it "returns 0 (zero)" do
expect { clear }.not_to change { entity.entries.size }
expect(clear).to be == 0
expect(clear).to eq 0
end
end
end
Expand All @@ -55,27 +55,27 @@
subject(:exist?) { entity.exist? }

context "when no entries exist" do
it { is_expected.to be == false }
it { is_expected.to be false }
end

context "when entries exist" do
before { simulate_lock(key, job_id) }

it { is_expected.to be == true }
it { is_expected.to be true }
end
end

describe "#pttl" do
subject(:pttl) { entity.pttl }

context "when no entries exist" do
it { is_expected.to be == -2 }
it { is_expected.to eq(-2) }
end

context "when entries exist without expiration" do
before { simulate_lock(key, job_id) }

it { is_expected.to be == -1 }
it { is_expected.to eq(-1) }
end

context "when entries exist with expiration" do
Expand All @@ -92,13 +92,13 @@
subject(:ttl) { entity.ttl }

context "when no entries exist" do
it { is_expected.to be == -2 }
it { is_expected.to eq(-2) }
end

context "when entries exist without expiration" do
before { simulate_lock(key, job_id) }

it { is_expected.to be == -1 }
it { is_expected.to eq(-1) }
end

context "when entries exist with expiration" do
Expand All @@ -107,15 +107,15 @@
expire(key.changelog, 600)
end

it { is_expected.to be == 600 }
it { is_expected.to eq 600 }
end
end

describe "#expires?" do
subject(:expires?) { entity.expires? }

context "when no entries exist" do
it { is_expected.to be == false }
it { is_expected.to be false }
end

context "when entries exist" do
Expand All @@ -124,21 +124,21 @@
expire(key.changelog, 600)
end

it { is_expected.to be == true }
it { is_expected.to be true }
end
end

describe "#count" do
subject(:count) { entity.count }

context "when no entries exist" do
it { is_expected.to be == 0 }
it { is_expected.to eq 0 }
end

context "when entries exist" do
before { simulate_lock(key, job_id) }

it { is_expected.to be == 2 }
it { is_expected.to eq 2 }
end
end

Expand Down
12 changes: 6 additions & 6 deletions spec/sidekiq_unique_jobs/lua/delete_by_digest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
it "deletes the expected keys from redis" do
expect(delete_by_digest).to eq(8)

expect(queued.count).to be == 0
expect(primed.count).to be == 0
expect(locked.count).to be == 0
expect(queued.count).to eq 0
expect(primed.count).to eq 0
expect(locked.count).to eq 0

expect(run_queued.count).to be == 0
expect(run_primed.count).to be == 0
expect(run_locked.count).to be == 0
expect(run_queued.count).to eq 0
expect(run_primed.count).to eq 0
expect(run_locked.count).to eq 0
end
end
2 changes: 1 addition & 1 deletion spec/sidekiq_unique_jobs/lua/lock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
let(:now_f) { SidekiqUniqueJobs.now_f }
let(:lock_limit) { 1 }

shared_context "with a primed key", with_primed_key: true do
shared_context "with a primed key", :with_primed_key do
before do
call_script(:queue, key.to_a, argv_one)
rpoplpush(key.queued, key.primed)
Expand Down
12 changes: 6 additions & 6 deletions spec/sidekiq_unique_jobs/lua/unlock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
let(:locked_jid) { job_id_one }
let(:lock_limit) { 1 }

shared_context "with a lock", with_a_lock: true do
shared_context "with a lock", :with_a_lock do
before do
call_script(:queue, key.to_a, argv_one)
rpoplpush(key.queued, key.primed)
Expand Down Expand Up @@ -172,10 +172,10 @@
it "does not unlock" do
expect { unlock }.to change { changelogs.count }.by(1)

expect(queued.count).to be == 0
expect(primed.count).to be == 0
expect(queued.count).to eq 0
expect(primed.count).to eq 0

expect(locked.count).to be == 1
expect(locked.count).to eq 1
expect(locked.entries).to contain_exactly(job_id_two)
expect(locked[job_id_two].to_f).to be_within(0.5).of(now_f)
end
Expand All @@ -189,9 +189,9 @@
expect(queued.count).to eq(1)
expect(queued.entries).to contain_exactly("1")

expect(primed.count).to be == 0
expect(primed.count).to eq 0

expect(locked.count).to be == 0
expect(locked.count).to eq 0
expect(locked.entries).to be_empty
expect(locked[job_id_one]).to be_nil
end
Expand Down
4 changes: 2 additions & 2 deletions spec/sidekiq_unique_jobs/redis/hash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
subject(:count) { entity.count }

context "without entries" do
it { is_expected.to be == 0 }
it { is_expected.to eq 0 }
end

context "with entries" do
before { hset(digest, job_id, now_f) }

it { is_expected.to be == 1 }
it { is_expected.to eq 1 }
end
end
end
4 changes: 2 additions & 2 deletions spec/sidekiq_unique_jobs/redis/set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
subject(:count) { entity.count }

context "without entries" do
it { is_expected.to be == 0 }
it { is_expected.to eq 0 }
end

context "with entries" do
before { sadd(digest, job_id) }

it { is_expected.to be == 1 }
it { is_expected.to eq 1 }
end
end
end
14 changes: 7 additions & 7 deletions spec/sidekiq_unique_jobs/redis/sorted_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,35 @@
context "when given an array of arrays" do
let(:values) { [[1.0, "string"], [2.0, "other"]] }

it { is_expected.to be == 2 }
it { is_expected.to eq 2 }
end

context "when given a string entries" do
let(:values) { "abcdef" }

it { is_expected.to be == true }
it { is_expected.to be true }
end
end

describe "#count" do
subject(:count) { entity.count }

context "without entries" do
it { is_expected.to be == 0 }
it { is_expected.to eq 0 }
end

context "with entries" do
before { zadd(digest, now_f, job_id) }

it { is_expected.to be == 1 }
it { is_expected.to eq 1 }
end
end

describe "#clear" do
subject(:clear) { entity.clear }

context "without entries" do
it { is_expected.to be == 0 }
it { is_expected.to eq 0 }
end

context "with entries" do
Expand All @@ -77,7 +77,7 @@
zcard(digest)
end

it { is_expected.to be == 100 }
it { is_expected.to eq 100 }
end
end

Expand Down Expand Up @@ -105,7 +105,7 @@
context "with entries" do
before { zadd(digest, now_f, job_id) }

it { is_expected.to be == 0 }
it { is_expected.to eq 0 }
end
end
end
8 changes: 4 additions & 4 deletions spec/sidekiq_unique_jobs/redis/string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
subject(:count) { entity.count }

context "without entries" do
it { is_expected.to be == 0 }
it { is_expected.to eq 0 }
end

context "with entries" do
before { set(digest, job_id) }

it { is_expected.to be == 1 }
it { is_expected.to eq 1 }
end
end

Expand All @@ -30,7 +30,7 @@
context "with entries" do
before { set(digest, job_id) }

it { is_expected.to be == job_id }
it { is_expected.to eq job_id }
end
end

Expand All @@ -44,7 +44,7 @@
context "with entries" do
before { set(digest, job_id) }

it { is_expected.to be == 1 }
it { is_expected.to eq 1 }
end
end
end
6 changes: 3 additions & 3 deletions spec/support/shared_contexts/with_sidekiq_options.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# frozen_string_literal: true

RSpec.shared_context "with global config", with_global_config: true do
RSpec.shared_context "with global config", :with_global_config do
let(:global_config) { {} }

around do |example|
SidekiqUniqueJobs.use_config(global_config, &example)
end
end

RSpec.shared_context "with job options", with_job_options: true do
RSpec.shared_context "with job options", :with_job_options do
let(:job_options) { {} }

around do |example|
job_class.use_options(job_options, &example)
end
end

RSpec.shared_context "with sidekiq options", with_sidekiq_options: true do |**_options|
RSpec.shared_context "with sidekiq options", :with_sidekiq_options do |**_options|
let(:sidekiq_options) { {} }

around do |example|
Expand Down
2 changes: 1 addition & 1 deletion spec/support/sidekiq_meta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def sidekiq_redis_driver

if (sidekiq = example.metadata.fetch(:sidekiq, :disable))
sidekiq = :fake if sidekiq == true
Sidekiq::Testing.send("#{sidekiq}!")
Sidekiq::Testing.send(:"#{sidekiq}!")
end

if (sidekiq_ver = example.metadata[:sidekiq_ver])
Expand Down

0 comments on commit f65ecbc

Please sign in to comment.