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

Example Test using Sidekiq::Testing.inline #44

Closed
ahallock opened this issue Jul 14, 2014 · 3 comments
Closed

Example Test using Sidekiq::Testing.inline #44

ahallock opened this issue Jul 14, 2014 · 3 comments

Comments

@ahallock
Copy link

I have a few service objects I'd like to write integration tests for, so I'm using Sidekiq::Testing.inline! so they run synchronously. This doesn't appear to work with sidekiq-unique jobs. Is there an example or workaround on how to get the job to execute immediately?

@mhenrixon
Copy link
Owner

What I do is this

it 'only allows 1 call per 10 minutes', sidekiq: :inline do
    NetEnt::RefreshSession.perform_async(session_id)
    100.times do
      NetEnt::RefreshSession.perform_async(session_id)
    end

    expect(@multiple_refresh).to have_been_made.once
    NetEnt::RefreshSession.perform_async('another')
    expect(@singular_refresh).to have_been_made.once
    travel_to(11.minutes.from_now) do
      NetEnt::RefreshSession.perform_async(session_id)
      expect(@multiple_refresh).to have_been_made.twice
    end
  end

Does that answer your question?

@salrepe
Copy link
Contributor

salrepe commented Nov 3, 2014

I had more or less the same problems, I could run the first spec, but the next ones failed for me because it is not unlocking the jobs once completed. I have opened this pull request[1] trying to fix that.

[1] #53

@mhenrixon
Copy link
Owner

Fixed, thanks for the PR @salrepe !

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