VCR

2017-07-08 11 views
0

に可変値を使用した作業私が持っているuriでこのVCR

--- 
http_interactions: 
- request: 
    method: post 
    uri: https://control.msg91.com/api/sendotp.php?message=Your%20otp%20is%200805&mobile=919446733017&otp=0805&sender=TESTER 
    body: 
     encoding: UTF-8 
     string: '' 
    headers: 
     Accept-Encoding: 
     - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 
     Accept: 
     - "*/*" 
     User-Agent: 
     - Ruby 
     Host: 
     - control.msg91.com 
     Cache-Control: 
     - no-cache 
    response: 
    status: 
     code: 200 
     message: OK 
    headers: 
     Server: 
     - nginx 
     Date: 
     - Sat, 08 Jul 2017 13:54:17 GMT 
     Content-Type: 
     - text/html 
     Transfer-Encoding: 
     - chunked 
     Connection: 
     - keep-alive 
     Set-Cookie: 
     - PHPSESSID=od25ntah2t8nf47i947dmevbv0; expires=Sun, 09-Jul-2017 13:54:17 GMT; 
     Max-Age=86400; path=/; HttpOnly 
     Expires: 
     - Thu, 19 Nov 1981 08:52:00 GMT 
     Cache-Control: 
     - no-store, no-cache, must-revalidate, post-check=0, pre-check=0 
     Pragma: 
     - no-cache 
     X-Frame-Options: 
     - SAMEORIGIN 
     X-Xss-Protection: 
     - 1; mode=block 
    body: 
     encoding: UTF-8 
     string: '{"message":"376768737871373032333335","type":"success"}' 
    http_version: 
    recorded_at: Sat, 08 Jul 2017 13:54:17 GMT 
recorded_with: VCR 3.0.3 

のようなVCRのcasetteは、それぞれの要求にランダムな値でありotpmessageフィールドがあります。これらの2つが変更可能(常に変化する)なので、vcrのこれらの2つのフィールドを無視してvcrが正常に動作するようにするにはどうすればよいですか?

答えて

0

vcrには、これに対応したソリューションが組み込まれています。 VCRのconfigブロックにこれを追加する

は私が

を無視する必要がある2つの事がある

config.default_cassette_options = { 
     :match_requests_on => [:method, 
          VCR.request_matchers.uri_without_params(:otp, :message)] 
    } 
ここ

otpmessage作品

関連する問題