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

Using rspec matcher and getting: NameError: uninitialized constant SidekiqUniqueJobs::Lock::BaseLock::Validator #741

Closed
edelauna opened this issue Nov 18, 2022 · 1 comment

Comments

@edelauna
Copy link

edelauna commented Nov 18, 2022

Describe the bug
Version: sidekiq-unique-jobs (7.1.27)
As per the readme, trying to validate options.

#app/workers/bad_worker.rb
class BadWorker
  include Sidekiq::Job
  sidekiq_options lock: :while_executing, on_conflict: :replace
end

#spec/workers/bad_worker_spec.rb
require "sidekiq_unique_jobs/rspec/matchers"
# require "sidekiq_unique_jobs/testing" -- using this results in a different error

RSpec.describe OutboxMessageEvents::BadWorker do
  specify { expect(described_class).to have_valid_sidekiq_options }
end

Expected behavior

Expected BadWorker to have valid sidekiq options but found the following problems:
on_server_conflict: :replace is incompatible with the server process

Current behavior

 BadWorker is expected to have valid sidekiq options
   Failure/Error: specify { expect(described_class).to have_valid_sidekiq_options }

 NameError:
   uninitialized constant SidekiqUniqueJobs::Lock::BaseLock::Validator
 # ./spec/workers/bad_worker_spec.rb:4:in `block (2 levels) in <top (required)>'
 # -e:1:in `<main>'

Worker class

#app/workers/bad_worker.rb
class BadWorker
  include Sidekiq::Job
  sidekiq_options lock: :while_executing, on_conflict: :replace
end

Additional context
Add any other context about the problem here.

jherdman added a commit to jherdman/sidekiq-unique-jobs that referenced this issue Jan 29, 2024
I ran into mhenrixon#741 pretty quickly when bringing this fantastic gem into a project.

It seems that the testing instructions are out of date. The "testing" lib does everything you need for RSpec, and includes necessary files.
jherdman added a commit to jherdman/sidekiq-unique-jobs that referenced this issue Jan 29, 2024
I ran into a known issue[1] when trying to bring this gem into my project.

It turns out the instructions were just out of date. If you merely include the RSpec
file it misses other necessary requires. The noted file does everything you need
regardless of testing framework.

1. mhenrixon#741
@jherdman
Copy link
Contributor

This should be closed by #827

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants