myronmarston/vcr — Issue #91: Allow users to globally handle all requests without needing to wrap code in VCR.use_cassette
Author: myronmarston
Created: 2011-10-14 15:04:48+00:00
State: open

Now that VCR has a global hook into every request, it makes it possible to do something like this:

``` ruby
VCR.configure do |c|
c.before_cassetteless_request do |request|
VCR.insert_cassette(URI(request.uri).host)
end
c.after_cassetteless_request do |request|
VCR.eject_cassette
end
end
```
Open questions:

* Is this the right API for this?
* I could provide an `around_cassetteless_request` callback, too, but that would only work with fibers on 1.9. Is it worth it? (I'm leaning towards yes).
* Should the argument yielded to the `after_cassetteless_request` be the whole HTTPInteraction?
* What else could users use this for beside inserting/ejecting a cassette? One idea is to allow them to call `request.ignore!` in the before hook, which would cause the request to be ignored.