title: rspec: How to stub an instance method called by constructor?
body: <pre><code>class A
    def initialize
      @x = do_something
    end
  
    def do_something
      42
    end
  end
  </code></pre>
  
  <p>How can I stub <code>do_something</code> in rspec, before the original implementation is called (thus assigning 42 to <code>@x</code>)? And without changing the implementation, of course.</p>