Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Piotr Romańczuk
Piotr Romańczuk

Posted on

     

When VCR seems to heavy try cURL & WebMock

Do you want to mock exact response (body and headers) for some file download?

VCR is overkill for such small task. One can handcraft it and pass toWebMock'sstub_request. I'd rather go with saving full real response.

There arefine istructions in WebMock README. I want to share it here for reference:

Replaying raw responses recorded with curl -is

In console:

curl -is www.example.com > /tmp/example_curl_-is_output.txt
Enter fullscreen modeExit fullscreen mode

In your test:

raw_response_file=File.new("/tmp/example_curl_-is_output.txt")stub_request(:get,"www.example.com").to_return(raw_response_file)
Enter fullscreen modeExit fullscreen mode

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Location
    Bialystok, Poland
  • Work
    Ruby dev at Arkency
  • Joined

More fromPiotr Romańczuk

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp