As seen in the real world (tm), sometimes queries have values but no keys which
causes webmock to blow up with a TypeError:
lib/webmock/util/query_mapper.rb:187:in `dup': can't dup NilClass (TypeError)
from ./gems/webmock-1.15.2/lib/webmock/util/query_mapper.rb:187:in `block in values_to_query'
from ./gems/webmock-1.15.2/lib/webmock/util/query_mapper.rb:185:in `each'
from ./gems/webmock-1.15.2/lib/webmock/util/query_mapper.rb:185:in `values_to_query'
from ./gems/webmock-1.15.2/lib/webmock/util/uri.rb:18:in `block in <class:URI>'
from ./gems/webmock-1.15.2/lib/webmock/util/uri.rb:33:in `yield'
from ./gems/webmock-1.15.2/lib/webmock/util/uri.rb:33:in `normalize_uri'
from ./gems/webmock-1.15.2/lib/webmock/request_signature.rb:10:in `initialize'
from ./gems/webmock-1.15.2/lib/webmock/http_lib_adapters/net_http.rb:290:in `new'
from ./gems/webmock-1.15.2/lib/webmock/http_lib_adapters/net_http.rb:290:in `request_signature_from_request'
from ./gems/webmock-1.15.2/lib/webmock/http_lib_adapters/net_http.rb:75:in `request'
from ./gems/net-http-persistent-2.9/lib/net/http/persistent.rb:986:in `request'
from ./bundler/gems/mechanize-3c0a3714926e/lib/mechanize/http/agent.rb:259:in `fetch'
from ./bundler/gems/mechanize-3c0a3714926e/lib/mechanize.rb:440:in `get'
This resolves that by casting nil to a string as with Symbol.
unit spec for query mapper examples
convert nil to "", e.g. an empty key, prevents error with `dup`
Is it allowed to have blank query keys in the url according to the spec?
A query string is any character between ? and # citation with the only further thing said "often used to carry identifying information in the form of 'key=value' pair" however, URI.parse handles it, and it's seen in the wild, and as a testing framework I think this should be handled gracefully, and this is the best effort at that.
An alternative would be to validate the format of the query string before attempting to split it into key value pairs, as the query string could then just be left alone.
Ok, looks good. Cheers.
Released as 1.17.0