myronmarston/vcr — Issue #99: Playback a POST without query param(s) & uri_without_param = nil exception.
Author: sfsekaran
Created: 2011-11-01 07:26:09+00:00
State: open

https://www.relishapp.com/myronmarston/vcr/docs/request-matching/uri-without-param-s

I'm using latest VCR (78bb6a175ba0) and when I use the VCR.request_matchers.uri_without_param(:timestamp) matcher, and my scenario runs a call to a url on the same domain which does not have any uri parameters, I get the following failure:

```
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.split (NoMethodError)
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/request_matcher_registry.rb:16:in `block in partial_uri_from'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/request_matcher_registry.rb:15:in `tap'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/request_matcher_registry.rb:15:in `partial_uri_from'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/request_matcher_registry.rb:30:in `call'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/request_matcher_registry.rb:9:in `matches?'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/cassette/http_interaction_list.rb:50:in `block in interaction_matches_request?'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/cassette/http_interaction_list.rb:49:in `each'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/cassette/http_interaction_list.rb:49:in `all?'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/cassette/http_interaction_list.rb:49:in `interaction_matches_request?'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/cassette/http_interaction_list.rb:40:in `block in matching_interaction_index_for'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/cassette/http_interaction_list.rb:40:in `index'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/cassette/http_interaction_list.rb:40:in `matching_interaction_index_for'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/cassette/http_interaction_list.rb:32:in `has_interaction_matching?'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/library_hooks/webmock.rb:47:in `stubbed_response'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/request_handler.rb:5:in `handle'
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/bundler/gems/vcr-78bb6a175ba0/lib/vcr/library_hooks/webmock.rb:63:in `block (2 levels) in '
/Users/sfsekaran/.rvm/gems/ruby-1.9.2-p290@topspin/gems/webmock-1.7.7/lib/webmock/request_pattern.rb:28:in `call'
...
```

I ran debugger and found that the reason is `VCR::RequestMatcherRegistry::URIWithoutParamsMatcher#partial_uri_from` is expecting `uri.query` to never equal `nil` (see `uri.query = uri.query.split('&').tap { |params|` for the culprit `split` call)

To clarify, I'm running two requests: the first is a `POST` with binary content and no query params, and the second is a `GET` with some query params, including a timestamp parameter, to a different path (but same domain) as the first.

We're using Ruby 1.9.2, WebMock 1.7.7.