title: How to properly mock itnernal services in RSpec?
body: <p>I would like to learn how to properly mock object calls inside other classes, foor example I have this controller action:</p>
  
  <pre><code>def show
   service = Action::PartsShow.new(show_params, current_user)
   service.call
   render json: service.part, root: :part, serializer: PartSerializer, include: '**',
          scope: {current_user: current_user}
  end
  </code></pre>
  
  <p>The service class looks like this.</p>
  
  <pre><code>module Action
    class PartsShow &lt; PartsShowBase
      def find_part
        ...
      end
    end
  end
  
  module Action
    class PartsShowBase
      attr_reader :part
  
      def initialize(params, current_user)
        @params = params
        @current_user = current_user
      end
  
      def call
        find_part
        reload_part_availability
        reload_part_price if @current_user.present?
      end
  
      private
  
      def reload_part_availability
        ReloadPartAvailabilityWorker.perform_async(part.id)
      end
  
      def reload_part_price
        ExternalData::LauberApi::UpdatePrices.new(@current_user, [part]).execute
      end
    end
  end
  </code></pre>
  
  <p>I don't want to call the actual <code>Action::PartsShow</code> service inside this controller action and all other methods, services + the worker because this makes the test very slow. What I want is to test if this service is being called and mock the rest of the services. I don't want to call them in my tests, I want to mock them.</p>
  
  <p>My test looks like this:</p>
  
  <pre><code>RSpec.describe PartController, type: :request do
    describe 'GET #show' do
      let(:part) { create(:part) }
  
      subject { get "/api/v1/parts/#{part.id}" }
  
      expect(response_body).to eq(200)
      # ...
    end
  end
  </code></pre>
  
  <p>Could you show me how to properly mock it? I've read about RSpec mocks and stubs but I am confused about it. I would appreciate your help.</p>