title: Rspec how to test a Sidekiq job?
body: <p>I have a Sidekiq job that looks something like this:</p>
  <pre><code>class Arbitrary::MarkSold &lt; ApplicationJob
    def perform(item_id)
      return if Rails.env.test?
      item = Item.find_by(item_id)
      item.sold = true
      item.save
    end
  end
  </code></pre>
  <p>And a corresponding RSpec test that looks like this:</p>
  <pre><code>Rspec.describe Arbitrary::MarkSold, type: :job do
    describe 'perform' do
      it 'runs' do
        expect(Arbitrary::Marksold).to receive(:perform).and_return(nil)
        MarkSold.new.perform(34)
      end
    end
  end
  </code></pre>
  <p>When I try to run this test, I get a failure with this error:</p>
  <pre><code>Arbitrary::MarkSold does not implement: perform`.
  </code></pre>
  <p>However, I can clearly see that <code>Arbitrary::MarkSold</code> has a <code>perform</code> method.</p>
  <p>I've read <a href="https://github.com/rspec/rspec-mocks#method-stubs" rel="nofollow noreferrer">Method Stubs</a> but couldn't make heads or tails out of it, or figure out how to apply it to this situation.</p>
  <p>I'd greatly appreciate any pointers or links to documentation other than the one I've linked. As a beginner I find that the rspec docs aren't very beginner-friendly. Thank you in advance!</p>
  <p>Ruby version: 2.4.9
  Rails version: 5.1.7
  RSpec version: 3.7</p>