when i try to test the rspec for the sidekiq, it sending the params as string to the method.
for example:
my rspec
" expect(User::RemoveAccess).to have_enqueued_sidekiq_job(user.id,user_account_ids)
"
here user account ids is an array like user_account_ids = user.pluck(:account_ids)
my ruby code:
User::RemoveAccess.perform_async(user.id,user.pluck(:account_ids))
the error I'm getting in rspec is:
expected to have an enqueued User::RemoveAccess job
arguments: [12670, ["e012-40d-4f50-8d96-14"]]
found
arguments: [[12670, "e012-40d-4f50-8d96-14"]]
I'm not sure where I'm getting wrong, is any thing i missed?.
The wrong arguments error is happening because you are calling.pluck on a single user instance and not an active record collection
If you want an array, you need to change this
user.pluck(:account_ids)
To this
users.pluck(:account_ids)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.