fakeweb
fakeweb copied to clipboard
Different Responses to the same URI based on the passed data
I am working on a project using fakeweb. Found it to be useful. :)
I have a scenario in which I need to return different responses based on the data passed in the request on the same URI. Example below:
FakeWeb.register_uri(:post,
%r{http:\/\/api.flickr.com\/services\/rest\/},
parameters: {method: 'flickr.reflection.getMethods', format: 'json', nojsoncallback: "1"},
body: "First Content")
# Should return First Content
FakeWeb.register_uri(:post,
%r{http:\/\/api.flickr.com\/services\/rest\/},
parameters: {method: 'flickr.photos.getRecent', format: 'json', nojsoncallback: "1"},
body: "Second Content")
# Should return Second Content
In the case above, the URI is the same, however, the values of the parameters are different.
How this can be achieved?
It doesn't look like this functionality is currently present, I also need this feature and haven't yet found a solution.
They support rotating responses
but that too doesn't seem to work. It always responds with first registered response.