title: Testing a Thor script with rspec and vcr
body: <p>I built a Thor script that connects to an HTTP API to perform some very simple actions. I've coded tests for the backend but the Thor script is basically untested, which is quite suboptimal.</p>
  
  <p>My first approach was to capture the output of the commands itself and write test against such output, the resulting tests are unsurprisingly slow.</p>
  
  <pre><code>expect(`bin/script foo`).to eq('bar')
  </code></pre>
  
  <p>I then tried to use both <code>webmock</code> and <code>vcr</code> but using this approach none of these frameworks are invoked, even if I mock the exact request the mock is unused, most probably because both <code>webmock</code> and <code>vcr</code> are unable to hook into the thor script.</p>
  
  <p>Has anybody found a nice solution for this? Invoking the Thor script directly (<code>Thorclass.action('bar')</code>) would be enough for my taste, but I haven't found a way to do it.
  Any suggestion? Thanks in advance.</p>