Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Is webmock caching responses? #346

Closed
ehalferty opened this Issue · 0 comments

1 participant

@ehalferty

I've tried using a lambda in my custom response:

stub_request(
        :post,
        'http://blah.blah/oauth/token'
    ).to_return(
        status: 200,
        body: lambda { |a| '{"access_token":"' + SecureRandom.hex(20) + '","token_type":"bearer","expires_in":"259200"}' }
    )

Maybe this isn't the correct way to handle dynamic responses, but anyway, webmock seems to execute the lambda exactly once. The request is identical each time, so either:

1) My asumption that using a lambda would allow me to generate dynamic content on a per-response basis was wrong.
2) Because the repeated requests are identical, webmock just uses the last response it generated.

@ehalferty ehalferty closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.