|
1 | | -require 'blockcypher' |
| 1 | +require 'spec_helper' |
2 | 2 |
|
3 | 3 | module BlockCypher |
4 | 4 |
|
5 | | - describe Api do |
| 5 | + describe Api, vcr: {record: :once} do |
6 | 6 | let(:api) do |
7 | 7 | BlockCypher::Api.new({ |
8 | | - api_token: 'testtoken', |
| 8 | + api_token: CONFIG[:api_token], |
9 | 9 | currency: BlockCypher::BCY, |
10 | 10 | network: BlockCypher::TEST_NET, |
11 | 11 | version: BlockCypher::V1 |
12 | 12 | }) |
13 | 13 | end |
14 | 14 |
|
| 15 | + let(:addr1) { api.address_generate } |
| 16 | + let(:addr2) { api.address_generate } |
15 | 17 | context '#address_generate' do |
16 | 18 | it 'should generate new addresses' do |
17 | | - $addr1 = api.address_generate |
18 | | - $addr2 = api.address_generate |
19 | | - expect($addr1["address"]).to be_a(String) |
20 | | - expect($addr2["address"]).to be_a(String) |
| 19 | + expect(addr1["address"]).to be_a(String) |
| 20 | + expect(addr2["address"]).to be_a(String) |
21 | 21 | end |
22 | 22 | end |
23 | 23 |
|
24 | | - let(:address_1) { $addr1["address"].to_s } |
25 | | - let(:address_1_private_key) { $addr1["private"].to_s } |
| 24 | + let(:address_1) { addr1["address"].to_s } |
| 25 | + let(:address_1_private_key) { addr1["private"].to_s } |
26 | 26 |
|
27 | | - let(:address_2) { $addr2["address"].to_s } |
28 | | - let(:address_2_private_key) { $addr2["private"].to_s } |
| 27 | + let(:address_2) { addr2["address"].to_s } |
| 28 | + let(:address_2_private_key) { addr2["private"].to_s } |
29 | 29 |
|
30 | 30 | context '#faucet' do |
31 | 31 | it 'should fund a bcy test address with the faucet' do |
@@ -74,16 +74,15 @@ module BlockCypher |
74 | 74 | expect(forward_details["input_address"].length).to be(34) # Ok this isn't strictly true but.. |
75 | 75 | end |
76 | 76 |
|
77 | | - it 'allows creating a payment forward with a callback' do |
78 | | - forward_details = api.create_forwarding_address(address_1, callback_url: "http://test.com/foo") |
79 | | - expect(forward_details["callback_url"]).to eql("http://test.com/foo") |
80 | | - expect(forward_details["enable_confirmations"]).to be nil |
81 | | - end |
82 | | - |
83 | | - it 'allows creating a payment forward with a callback and confirmation notifications enabled' do |
84 | | - forward_details = api.create_forwarding_address(address_1, callback_url: "http://test.com/foo", enable_confirmations: true) |
| 77 | + it 'allows creating a payment forward with options' do |
| 78 | + forward_details = api.create_forwarding_address(address_1, { |
| 79 | + callback_url: "http://test.com/foo", |
| 80 | + enable_confirmations: true, |
| 81 | + mining_fees_satoshis: 20_000, |
| 82 | + }) |
85 | 83 | expect(forward_details["callback_url"]).to eql("http://test.com/foo") |
86 | 84 | expect(forward_details["enable_confirmations"]).to be true |
| 85 | + expect(forward_details["mining_fees_satoshis"]).to be 20_000 |
87 | 86 | end |
88 | 87 |
|
89 | 88 | it 'is possible to use the alias create_payments_forwarding' do |
|
0 commit comments