title: Rspec 3 stub class variable
body: <p>anybody know, how I can stub class variable initialization?</p>
  
  <p>I define</p>
  
  <pre><code>@@connection = Bunny.new.start
  </code></pre>
  
  <p>for restrict connection numbers, but now I have to test it, and when I try stub it in general way, like </p>
  
  <pre><code>allow_any_instance_of(Bunny).to receive(:start) { something }
  </code></pre>
  
  <p>it doesn't work. <code>@@</code> variable initializes earlier.</p>
  
  <p>Also, I can redefine it:</p>
  
  <pre><code>before do
    @@connection = double('conn')
  end
  </code></pre>
  
  <p>but it doesn't suit for me because I have to do not allow create a connection to AMQP</p>
  
  <p><strong>SOLVE</strong></p>
  
  <p>I didn't figure out how to do that, so I used bunny-mock, and it helped me</p>