ruby on rails - VCR ignored parameter: Get real http request -
i'm recording http requests vcr test suite. have ignore parameter called callback
because parameter random, , don't want vcr record new request when parameter changes (because parameter changes, not request itself).
but problem is, need modify response body vcr serving app, based on original value of callback
client generated @ runtime.
here vcr configuration:
vcr.configure |c| c.cassette_library_dir = 'spec/vcr_cassettes' c.hook_into :webmock c.allow_http_connections_when_no_cassette = false c.ignore_localhost = true c.before_http_request(:stubbed?) |request| # request.uri original request made client puts request.uri end c.before_playback |interaction, cassette| # request uri got value cassette interaction.request.uri # , here want modify interaction.response.body # based on callback parameter original request client interaction.response.body = "...." end # add callback , no caching _ parameter ignored parameters c.default_cassette_options = { record: :once, match_requests_on: [:method, vcr.request_matchers.uri_without_params("callback", "_")] } end
in c.before_http_request(:stubbed?)
callback, real value of callback
in request.uri
. vcr ignores parameter, , replays former recorded cassette. in c.before_playback
callback, can modify interaction.response.body
, callback
parameter got value cassette, when recorded.
how possible real value of callback
inside c.before_playback
callback? because callback 1 allows modify response body. tried out c.after_http_request(:stubbed?)
response body , real value of callback
parameter, hook late, because app received response body.
any monkeypatch, dirty hack or trick great!
i found solution on github when put me right direction: https://github.com/nbibler/vcr-284
Comments
Post a Comment