fakeweb icon indicating copy to clipboard operation
fakeweb copied to clipboard

Different Responses to the same URI based on the passed data

Open mhaseebkhan opened this issue 11 years ago • 2 comments

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?

mhaseebkhan avatar Aug 26 '13 13:08 mhaseebkhan

It doesn't look like this functionality is currently present, I also need this feature and haven't yet found a solution.

drunkonsound avatar Jul 30 '14 21:07 drunkonsound

They support rotating responses but that too doesn't seem to work. It always responds with first registered response.

ajay-vmware avatar Oct 08 '15 07:10 ajay-vmware