title: Stubbing a controller method with Sinatra and rspec
body: <p>So I'm trying to figure out a way of stubbing a controller method in rspec for a Sinatra app. The main reason for this is to test the logical flow of the application and to make sure it calls the necessary functions when certain conditions are met. So, in essence, I want to be able to do something like</p>
  
  <pre><code>controller.should_receive(:fancy_method).and_return("This is a string")
  </code></pre>
  
  <p>What I'm having difficulty doing is accessing the controller instance within the sinatra app. I am able to override the current functions using a class_eval on the sinatra controller class, but I'd love to assert that these functions actually run.</p>
  
  <p>Anyone have any advice?</p>
  
  <p>Thanks.</p>