I'm writing specs for a Rails controller that receives HTTP JSON requests, and returns a response to those requests. In my test suite, I'd like to have some fixtured HTTP requests that I can play back against my application.
Sample code:
context "when '/product/add' is requested" do
subject do
get '/product/add', fixtured_request # <-- This is some kind of recorded request
end
it do
expect(subject).to have_http_status(200)
end
end
Basically, I want VCR but in reverse, so I can play back a set of known requests in my specs to make sure my application is behaving as I expect.
- Can VCR record & playback inbound requests against my application?
- If it can, how can I record "inbound requests"?
- If it can't, is there a gem that can do something like this?
(Also, this guy is doing something similar, but it doesn't really mesh well with my test suite.)