title: Ruby block to string instead of executing
body: <p>Take this example:</p>
  
  <pre><code>write_as_string { puts 'x' }
  </code></pre>
  
  <p>I then want to be able to do</p>
  
  <pre><code>def write_as_string(&amp;block)
    puts block.to_s
  end
  </code></pre>
  
  <p>When I execute this, I want the output to be:</p>
  
  <pre><code>"puts 'x'"
  </code></pre>
  
  <p>I want to be able to receive the block and get the actual code for the block instead of executing it. </p>
  
  <p>Motivation: Creating a DSL, I want to the mock to be converted into a number of other method calls, hidden from the calling code - using existing objects and methods without monkey patching them. </p>
  
  <p>Any ideas on this would be great!</p>
  
  <p>Thanks</p>
  
  <p>Ben</p>