chrisk/fakeweb

FakeWeb registering a url but ignore it afterwards

Closed this issue · 2 comments

Registered URI:

[#<FakeWeb::Responder:0x106d219f8 @uri=/http:\/\/ws\.audioscrobbler\.com\/([^\/&]+)\/\?artist=([^\/&]+)&method=album.getinfo&api_key=([^\/&]+)&album=([^\/&]+)/, @method=:any, @times=1, @options={:body=>"<lfm status=\"ok\">trimmed</lfm>"}>]

Does not match

http://ws.audioscrobbler.com/2.0/?artist=Cher&method=album.getinfo&api_key=edited&album=Prisoner

Error:
Real HTTP connections are disabled. Unregistered request: GET http://ws.audioscrobbler.com/2.0/?artist=Cher&method=album.getinfo&api_key=edited&album=Prisoner

Have a look at:
http://rubular.com/regexes/13511

I forgot that if I hardcode the entire path string FakeWeb does its job, so the problem arises only when I pass a Regex object as second parameter.

It's because FakeWeb sorts your query parameters before matching against the regular expressions you've registered (this definitely needs to be better documented). So you need to write your regexp with that in mind.

For a write up of why it works that way, see #7.