I’m writing a middleware that does something like this
Given I am logged in
When I visit home page
Then the request and all of my user information should get logged into CouchDB
This is basically it, the middleware itself isn’t that complicated, but I’m having trouble with the workflow.
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 curl and then check if it got saved into CouchDB.
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.
The app is running on Rails 3.2.2 and I’m using couchrest gem to do the logging.
This seems like the place for integration tests. If the stock rails integration tests bypass your middleware treat it like a rack app and use [ https://github.com/brynary/rack-test ]