RSpec test runs successfully, but VCR doesn't generate yml file.
spec/spec_helper.rb
require 'vcr'
VCR.configure do |c|
c.cassette_library_dir = 'spec/cassettes'
c.hook_into :typhoeus
# c.ignore_localhost = false
# c.default_cassette_options = { :record => :new_episodes }
end
spec/smoothPayApi_spec.rb
require 'smoothPayApi'
require 'spec_helper'
describe SmoothPayApi do
before :each do
@item = SmoothPayApi.new
@token = ''
end
describe "#getToken" do
# use_vcr_cassette
it "gets token by calling gen_token_test" do
VCR.use_cassette 'api/getToken' do
return_info = @item.getToken('X3r82l89', 1)
expect(return_info.message).to eq('success')
@token = return_info.data
end
end
end
end
SmoothPayApi::getToken uses Net::HTTP::Post.
I do this test in localhost. Is it the problem?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…