Assuming your VCR is recording to YAML (the default, I believe?), this one-liner returns an array of HTTP URIs that were called during the current cassette block:
YAML.load_file(VCR.current_cassette.file)["http_interactions"].pluck("request").pluck("uri")
E.g.,
YAML.load_file(VCR.current_cassette.file)["http_interactions"].pluck("request").pluck("uri")
[
[0] "https://stackoverflow.com/wayland-project/libinput/e0008d3d/tools/libinput-debug-gui.c",
[1] "https://stackoverflow.com/wayland-project/libinput"
]
You can use an array matching method of your choice to assert the expected request URI from there.
Other members of the request
object you might want to pluck
instead of uri
:
{
"method" => "get",
"uri" => "https://stackoverflow.com/adomain",
"body" => {
"encoding" => "US-ASCII",
"string" => ""
},
"headers" => {
"Accept" => [
...
}
}