title: Test that an object calls a private method in Ruby with Minitest
body: <p>Given the following ruby code, I want to ensure that the private method, <code>start</code>, only gets started if the app has been configured to run it. I think that means I need to mock the class and stub the private method, but I'm just not putting it together right. Anyone able to give me a push?
  </p>
  
  <pre><code>module Work
    class Thing
      def initialize(value:)
        @local_state = value
        if Rails.configuration.report_loop
          start
        end
      end
  
      def change(new_value)
        @local_state = new_value
      end
  
      private
  
      def start
        Thread.new {perform_reporting}.tap do |thread|
          thread.abort_on_exception = true if thread
        end
      end
  
      def perform_reporting
        loop do
          sleep 5
          log @local_state
        end
      end
  end
  </code></pre>
  
  <p>Here is what I'm trying that isn't working</p>
  
  <pre><code>def test_it_starts_reporting_automatically
    mock = Minitest::Mock.new
    mock.expect :start, true
    Work::Thing.stub :start, mock do
        hb = Work::Thing.new value: "test"
    end
    assert_mock mock
  end
  </code></pre>