File tree Expand file tree Collapse file tree 3 files changed +15
-19
lines changed
sidekiq_adhoc_job/requests/jobs Expand file tree Collapse file tree 3 files changed +15
-19
lines changed Original file line number Diff line number Diff line change 66 include_context 'SidekiqAdhocJob setup'
77 include_context 'request setup'
88
9- xit 'returns list of workers and arguments' do
9+ it 'returns list of workers and arguments' do
1010 get '/adhoc-jobs'
1111
1212 expect ( last_response . status ) . to eq 200
Original file line number Diff line number Diff line change 66 include_context 'SidekiqAdhocJob setup'
77 include_context 'request setup'
88
9- xcontext 'has arguments' do
9+ context 'has arguments' do
1010 it 'generates form for running job' do
1111 get '/adhoc-jobs/sidekiq_adhoc_job_test_dummy_worker'
1212
7373 end
7474 end
7575
76- xcontext 'has rest args' do
76+ context 'has rest args' do
7777 it 'generates form for running job' do
7878 get '/adhoc-jobs/sidekiq_adhoc_job_test_dummy_rest_args_worker'
7979
117117 end
118118 end
119119
120- xcontext 'no argument' do
120+ context 'no argument' do
121121 it 'generates form for running job' do
122122 get '/adhoc-jobs/sidekiq_adhoc_job_test_dummy_no_arg_worker'
123123
Original file line number Diff line number Diff line change 4949 # mock_redis setup
5050 config . before do
5151 require 'mock_redis'
52- require 'sidekiq/redis_connection '
52+ require 'sidekiq'
5353
54- redis = MockRedis . new
54+ mock_redis = MockRedis . new
55+ mock_redis . define_singleton_method ( :config ) { OpenStruct . new ( server_url : 'redis://localhost:6379' ) }
5556
56- connection = {
57- location : '127.0.0.1:6379' ,
58- db : '0'
59- }
60-
61- redis . define_singleton_method ( :connection ) { connection }
62-
63- allow ( Sidekiq ::RedisConnection ) . to receive ( :create ) . and_return ( ConnectionPool . new ( { } ) {
64- redis
65- } )
66- allow ( Sidekiq ) . to receive ( :redis ) do |&block |
67- block . call ( redis )
68- end
57+ # sscan in redis-client used by sidekiq allows calling with only the key
58+ # We intercept such calls to sscan and default the cursor to 0 when calling sscan in MockRedis
59+ #
60+ # See: https://github.com/sidekiq/sidekiq/blob/dddf20b/lib/sidekiq/api.rb#L70
61+ # See: https://github.com/redis-rb/redis-client/blob/a2f16fc/lib/redis_client.rb#L384
62+ # See: https://github.com/sds/mock_redis/blob/640f19c/lib/mock_redis/set_methods.rb#L145-L147
63+ allow ( mock_redis ) . to receive ( :sscan ) { |key | mock_redis . common_scan ( mock_redis . smembers ( key ) , 0 ) [ 1 ] }
64+ allow ( Sidekiq ) . to receive ( :redis ) . and_yield ( mock_redis )
6965 end
7066# The settings below are suggested to provide a good initial experience
7167# with RSpec, but feel free to customize to your heart's content.
You can’t perform that action at this time.
0 commit comments