VCR记录与webmock的HTTP交互创建没有值的.yml

时间:2018-10-12 13:24:34

标签: ruby-on-rails ruby rspec ethereum

我正在与Ganache-以太坊测试网进行HTTP交互。 Ganache网址 :http://127.0.0.1:7545。我通过ethereum.rb gem连接到它,它使用了Net :: HTTP lib: class from ethereum.rb gem which establish connect to ethreum net spec / support / vcr_setup.rb:

require 'vcr'
# spec/support/vcr_setup.rb
VCR.configure do |c|
  #the directory where your cassettes will be saved
  c.cassette_library_dir = 'spec/vcr'
  c.stub_with :webmock
end

spec / support / webmock.rb:

require 'webmock/rspec'
# spec/support/webmock.rb
WebMock.disable_net_connect!(allow_localhost: true)

我的rspec测试:

require 'rails_helper'

describe ::EthereumApi::Rpc do
  it '#.client' do
    VCR.use_cassette 'public_blockchain/rpc/client' do

      client = ::Ethereum::HttpClient.new('http://127.0.0.1:7545')
      first = client.eth_accounts['result'][0]

      expect(first).to eql('0xd1d2982db68fe27216c86c2a03fc4ef136ff8ce2')
    end
  end
end

结果是一个带有密钥但没有值的get .yml文件:

.yml without values spec / vcr / some_folder / my_test.yml:

0 个答案:

没有答案