Skip to content

Commit

Permalink
Run specs with redis client
Browse files Browse the repository at this point in the history
  • Loading branch information
laurafeier committed Oct 17, 2023
1 parent 96e207a commit 5f18eb2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ AllCops:
Exclude:
- gemfiles/**/*

Gemspec/DevelopmentDependencies:
Enabled: false

Layout/LineLength:
Max: 120
Exclude:
Expand Down
6 changes: 2 additions & 4 deletions spec/support/locks_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# frozen_string_literal: true

require 'redis'

module LocksHelpers
def cleanup_locks(**args)
ActiveJob::Uniqueness.unlock!(**args)
end

def locks(**args)
redis.keys(ActiveJob::Uniqueness::LockKey.new(**args).wildcard_key)
redis.call('KEYS', ActiveJob::Uniqueness::LockKey.new(**args).wildcard_key)
end

def locks_count
locks.count
end

def locks_expirations(**args)
locks(**args).map { |key| redis.ttl(key) }
locks(**args).map { |key| redis.call('TTL', key) }
end

def set_lock(job_class, arguments:)
Expand Down
2 changes: 1 addition & 1 deletion spec/support/redis_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module RedisHelpers
def redis
@redis ||= Redis.new
@redis ||= RedisClient.new(url: ENV.fetch('REDIS_URL', 'redis://localhost:6379'))
end
end

Expand Down

0 comments on commit 5f18eb2

Please sign in to comment.