title: Stubbing method in ActionDispatch::IntegrationTest
body: <p>I'm doing some stripe integration tests and I would like to stub/mock a few endpoints. I'm attempting to do it like this:</p>
  
  <pre><code>Stripe::Charge.stubs(:retrieve).returns({:balance_transaction =&gt; 40})
  </code></pre>
  
  <p>but I'm getting the following:</p>
  
  <pre><code>NoMethodError: undefined method `stubs' for Stripe::Charge:Class
  </code></pre>
  
  <p>What's the correct syntax for stubbing this? Rails 4, Ruby 2.</p>
  
  <p>Edit: Here is my full test method. Essentially my payment_succeeded webhook hits stripe to retrieve a charge and it's associated balance transaction in order to log the transaction fee. I'm using stripe_mock to mock the webhook events, but I'd rather stub out the rest of them using standard stubbing techniques. Note that even when I change it to 'stub' it throws the same error above (with stub substituted for stubs). </p>
  
  <pre><code>require 'test_helper'
  require 'stripe_mock'
  
  class WebhooksTest &lt; ActionDispatch::IntegrationTest
    # called before every single test
    def setup
      StripeMock.start
    end
  
    # called after every single test
    def teardown
      StripeMock.stop
    end
  
    test 'invoice.payment_succeeded' do
      Stripe::Charge.stubs(:retrieve).returns({:balance_transaction =&gt; 40})
      event = StripeMock.mock_webhook_event('invoice.payment_succeeded', { :customer =&gt; "stripe_customer1", :id =&gt; "abc123" })
      post '/stripe-events', id: event.id
      assert_equal "200", response.code
      assert_equal 1, StripeInvoicePayment.count
      assert_equal 'abc123', event.data.object.id
    end
  end
  </code></pre>