title: How can I test Rack middleware?
body: <p>I'm writing a middleware that does something like this</p>
  
  <pre><code>Given I am logged in
  When I visit home page
  Then the request and all of my user information should get logged into CouchDB
  </code></pre>
  
  <p>This is basically it, the middleware itself isn't that complicated, but I'm having trouble with the workflow.</p>
  
  <p>First thing is, that I have no idea how to test something like this. The feature itself is pretty clear, but how would I go about implementing it? Probably the highest level test that I can do is send a request via <code>curl</code> and then check if it got saved into CouchDB.</p>
  
  <p>The problem is, I'm not really sure at what level should I test this and what types of tests will be most helpful. At the moment I basically hit F5 and take a look in the db if there is a new record.</p>
  
  <p>The app is running on Rails 3.2.2 and I'm using <code>couchrest</code> gem to do the logging.</p>