I've got a bunch of Sidekiq workers in app/workers, and some matching specs in spec/workers. How can I add both to my rspec
runs? As in stands none are included when I hit up rspec
on the Terminal.
I see a few alternatives for your situation:
spec/worker
follow the pattern setup for Rspec (e.g. *.rb
or *_spec.rb
).spec_helper.rb
.spec/worker
and app/worker
files in your spec_helper.rb
with a Ruby-defined glob.rspec-sidekiq
gem to your project, as explained at Sidekiq's.To add a bulk of files to the load path, you can either:
$:
global variable, early in your boot process (e.g. at the beginning of spec_helper.rb
):$:.unshift(File.expand_path('../app/workers/**/*_worker.rb', File.dirname(__FILE__))
Dir[File.expand_path('../app/workers/**/*_worker.rb', File.dirname(__FILE__))].each do |file|
require file
end