title: How to test background jobs (Sidekiq) with Rspec?
body: <p>A large part of my application relies on background jobs to process user's websites, so I need to write some tests to cover these.</p>
  
  <p>First question is how to test code that's in a <a href="https://github.com/mperham/sidekiq">Sidekiq</a> worker class, for example <code>app/workers/some_worker.rb</code></p>
  
  <pre><code>class SomeWorker
    include Sidekiq::Worker
  
    def perform(model_id)
      ...
    end
  end
  </code></pre>
  
  <p>Secondly, how do I stub code such as the following so I don't need to actually run workers and slow down my tests?</p>
  
  <pre><code>response = HTTParty.get("http://users-site.com", timeout: 30)
  </code></pre>