title: How to mock method with expectation on what is passed to the block
body: <p>Lets say we have a class:</p>
  
  <pre><code>class ObjectWithCaching
    def cached_attribute(key, cache_handler)
      cache_handler.cache(key) { expensive_operation }
    end
  
    def expensive_operation
      #...
    end
  end
  </code></pre>
  
  <p>And we already tested cache_handler so we know that it will execute the block only when <code>key</code> is not found in <code>cache</code>.</p>
  
  <p>We want to test if cache_handler#cache is executed properly.</p>
  
  <p>Question is: <strong>How to write remaining pending spec?</strong></p>
  
  <pre><code>describe ObjectWithCaching, "#cached_attribute" do
    let(:key) { double }
    let(:cache_handler) { double }
  
    specify do
      cache_handler.should_receive(:cache).with(key)
      subject.cached_attribute(key, cache_handler)
    end
  
    it "passes #expensive_operation to block of cache_handler#cache" do
      pending
      subject.cached_attribute(key, cache_handler)
    end
  end
  </code></pre>