06 Jul '13, 1pm
Spying on Your Tests with VCR #NOTPRISM
VCR is a great tool for recording http requests during a test suite so that you can play them back later when the external server is not running or available. However, I’d like to show you how to abuse VCR into giving you the ability to spy on the network interactions during your test suite. Here’s why: I wanted my integration test suite for AwesomeResource to kill two birds with one stone: Prove that it integrates correctly with a rails server that serializes models to JSON the default Rails way Create executable documentation for anyone that wants to look at the required JSON format In other words, I needed to write a cucumber scenario like the following: Scenario: Endpoint responds with 201 When I call `create` on an Article model: """ Article.create title: "foo" """ Then the Article model should successfully POST the following JSON to "http://localhost:3001/articles": ...