I'm trying to write tests for a model that calls external API. Is it possible,using WebMock, to extract the parameters from the URL?
For example, I want to match any URL that's like that:
http://test.com?id=#{number}&id2=#{number2}
with #{number} and #{number2} being regular expressions. Till here, this is possible using WebMock as stated here: https://github.com/bblimke/webmock#matching-uris-using-regular-expressions
My problem is that I need to know what 'number' and 'number2' were in the request to use them inside the test. Is there any way to do that?
If there's an alternative to WebMock, feel free to suggest it.
EDIT: Some extra details:
Assume I have a test that tests a function that would call the external API, I know that it would be called with some parameters in the URL but I don't know the values it would take so I do like this:
stub_request(:get,/test.com?id=(?<first_id>\d+)&id2=(?<second_id>\d+)/).to_return(:status => 200, :body => some_function_that_can_use(first_id,second_id))