rspec - VCR unhandled http request error -


my specs pass in master branch. if create new branch , modify code unrelated subscriptions, they'll fail this. way can them pass change vcr.rb have :record => :new_episodes.

if leave option on, every time specs run have new modified data files cassettes end being committed dilute logs git.

any suggestions on how handle this? lot of specs break based on matcher:

  describe "#change_plan_to", vcr: {match_requests_on: [:method, :uri, :body]} 

is matcher open changes? wasn't able specs pass other way stripe api calls.

failure/error: @subscription.create_stripe_customer      vcr::errors::unhandledhttprequesterror:          ================================================================================        http request has been made vcr not know how handle:          post https://api.stripe.com/v1/customers         vcr using following cassette:          - /users/app/spec/data/subscription/_change_plan_to/stripe_customer_subscription_plan_/name/.json          - :record => :once          - :match_requests_on => [:method, :uri, :body]         under current configuration vcr can not find suitable http interaction        replay , prevented recording new requests. there few ways        can deal this:           * if you're surprised vcr raising error            , want insight how vcr attempted handle request,            can use debug_logger configuration option log more details [1].          * can use :new_episodes record mode allow vcr            record new request existing cassette [2].          * if want vcr ignore request (and others it), can            set `ignore_request` callback [3].          * current record mode (:once) not allow new requests recorded            recorded cassette. can delete cassette file , re-run            tests allow cassette recorded request [4].          * cassette contains 109 http interactions have not been            played back. if request non-deterministic, may need            change :match_requests_on cassette option more lenient            or use custom request matcher allow match [5].         [1] https://www.relishapp.com/vcr/vcr/v/2-5-0/docs/configuration/debug-logging        [2] https://www.relishapp.com/vcr/vcr/v/2-5-0/docs/record-modes/new-episodes        [3] https://www.relishapp.com/vcr/vcr/v/2-5-0/docs/configuration/ignore-request        [4] https://www.relishapp.com/vcr/vcr/v/2-5-0/docs/record-modes/once        [5] https://www.relishapp.com/vcr/vcr/v/2-5-0/docs/request-matching        ================================================================================      # ./app/models/subscription.rb:83:in `create_stripe_customer'      # ./spec/models/subscription_spec.rb:68:in `block (3 levels) in <top (required)>'      # -e:1:in `<main>' 

i figured out more. specs break when add new spec stack. how come break when more things added suite?

the behavior seeing suggests 1 of attributes used match requests non-deterministic , changes each time run tests. mention using match_requests_on: [:method, :uri, :body] option -- i'm guessing it's body. bear in mind vcr's built-in body matcher direct body_string == body_string comparison, , it's easy have situations bodies semantically equivalent aren't same string. example, json string {"a": 1", "b": 2} vs {"b": 2, "a": 1}.

my suggestion not match on body @ all: it's there if need in situations, if match more leniently, vcr works fine, since records http interactions in order occur, , then, during playback, plays first unused matched interaction -- which, if test makes requests in same order did, cause correct response played each request.

to more insight what's happening, can use debug logger option, give detailed output trying match, show why doing doing.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -