> Hi Bartosz,
> On Feb 27, 2012, at 5:54 AM, Bartosz Blimke wrote:
> > There is no way to do that without changing WebMock. Maybe there should
> be
> > some configurable strict mode in WebMock.
> > WebMock uses addressable for comparing uris and Addressable treats uris
> that way.
> > u1 = Addressable::URI.parse("
> http://www.example.com/studies/A%20Test/template")
> > u2 = Addressable::URI.parse("http://www.example.com/studies/ATest/template")
> > u1 === u2 #=> true
> > It very much depends on the http client library you use. Some libs will
> consider these two urls as the same.
> Thanks for your reply. In my case, the problem not the client so much as
> the service -- whatever HTTP client (or even curl) I use, if it receives a
> URI with a path component with an unescaped value in it, it won't handle it
> properly. I'd like to be able to use a testing library to verify that the
> URIs my code is using fit this constraint. After I sent my last e-mail, it
> occurred to me that I might be able to do this:
> WebMock.should have_requested(:get, "
> http://www.example.com/studies/A%20Test/template") do |request|
> request.uri.to_s == request.uri.normalize.to_s
> end
> However, this doesn't fail when the tested code does not escape the URI.
> Reviewing the code, it seems like WebMock normalizes URIs as soon as it
> encounters them, both expected and actual, so it would indeed be a big
> change to be able to test proper escaping.
> Thanks again for your time,
> Rhett
> > Bartosz
> > 2012/2/27 Rhett Sutphin <rhett.sutp...@gmail.com>
> > Hi,
> > I've just started using WebMock. Among other things, I like the way it
> lets me verify the body of a request using a block, rather than just a
> string or regex.
> > I do have one problem with it, though: the fact that it considers
> escaped and unescaped URIs to be equivalent. The API I'm interacting with
> only works if I issue requests that are escaped. E.g.,
> > conn.get('studies/A Test/template')
> > will not work, while
> > conn.get('studies/A%20Test/template')
> > will. (I'm using Faraday with the Net::HTTP adapter for the client.)
> > Since WebMock considers "http://example.net/studies/A Test/template"
> and "http://example.net/studies/A%20Test/template" to be the same
> request, I can't test that my client code is properly escaping its request
> URIs. Is there a way to change WebMock's behavior so it doesn't consider
> these URIs to be the same?
> > I've looked through the code and the docs and not seen anything, but I
> thought I'd ask in case anyone more experienced with the library has a
> suggestion.
> > Thanks,
> > Rhett