title: How to write a stub with RSpec for a Rails method which calls a block and doesn't return value?
body: <p>I have a function defined like this in my controller:</p>
  
  <pre><code>def respond_with(action = 0, &amp;block)
    if block_given?
      response = get_response
      block.call( MyResponse.new(response) )
    end
  end
  </code></pre>
  
  <p>With that I can query the response object:</p>
  
  <pre><code>respond_with do |response|
    case response.status
    when 'ok'
    when 'errors'
     #etc etc...
  end
  </code></pre>
  
  <p>I can just call it without the block of course if I want.</p>
  
  <p>If I had a function which returned a value it would be something like</p>
  
  <pre><code>controller.should_receive(:respond_with).with(DO_SOMETHING).and_return(something)
  </code></pre>
  
  <p>It would be ok for</p>
  
  <pre><code>def respond_with(action = 0)
    ...
    response
  end
  </code></pre>
  
  <p>How do I check that the block is called with a specific value in the |response| ? </p>