0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

#Ruby + #rspec + VCR で 外部接続のテストをする、わりと最小の書き方

Last updated at Posted at 2020-04-21

code

# https://relishapp.com/vcr/vcr/v/5-1-0/docs/getting-started

# gem install vcr
# gem install webmock
# gem install faraday

require "vcr"
require "faraday"
require "pry" # for debug

VCR.configure do |c|
  c.hook_into :webmock
  c.cassette_library_dir = 'cassettes'
  c.debug_logger = File.open("vcr.log", 'w')
end

describe do
  it do
    VCR.use_cassette('example') do
      response = Faraday.get("https://example.com")
      expect(response.success?).to be true
    end
  end
end

result


  is expected to equal true

Finished in 0.04331 seconds (files took 1.16 seconds to load)
1 example, 0 failures

Original by Github issue

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?