zold-ruby-sdk 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce7aea32407824fee9aaac411bc6ffaf1bbc34d4ab5c6b11d8cbf90c76b2af3b
4
- data.tar.gz: 914288435490d8e465b10698890e95e45cfbd6f4a4ff6e604382fff67ba9e7ab
3
+ metadata.gz: 6c43838a9818389a034a4fa45bf2b7e988f95702ced3f9f3759effc307466117
4
+ data.tar.gz: d334479f1a9723a1d6f3861d572153c8923e1eadd07d4ee9d8f2c3c393b0fd46
5
5
  SHA512:
6
- metadata.gz: 39a715a9c6a203b6fcc7a6b80b58d70550940c287754dad1adbf6afe1ff142f8f793ddd9238d639073124c527fa682ec8733c1a3179c4eb9a1372deef3c4dca7
7
- data.tar.gz: e71cf1f3c7a711eddc44b81a30d0ff2f06ba6844665d977dc825ed7297b571e6abd5e082cc25cce5288303b262ce9de0c33da6a24396c53f47fe11bcd3f96172
6
+ metadata.gz: f24952817a9b8eed5457ed9e0752e783def9d2210bde45f8d8d9b6083483bf1964555cd88e07d950b796b8bdfb2ac94bd75d8dc83e2ab23e2a24845d084900c6
7
+ data.tar.gz: 8fbcd9afbf6b1d7df9a0304cd3fafe0beeecf416c01160ae2950e0b35e88159bec633de21f28839971ee0226c176023039a10a4f6786148faeaa09f98af7a257
data/.rubocop.yml CHANGED
@@ -11,7 +11,7 @@ Style/ClassAndModuleChildren:
11
11
  Metrics/AbcSize:
12
12
  Max: 45
13
13
  Metrics/BlockLength:
14
- Max: 30
14
+ Max: 40
15
15
  Metrics/MethodLength:
16
16
  Max: 40
17
17
  Metrics/ClassLength:
data/lib/zold/wts.rb CHANGED
@@ -216,7 +216,7 @@ class Zold::WTS
216
216
  end
217
217
 
218
218
  def clean(http)
219
- error = http.headers['X-Zold-Error']
219
+ error = (http.headers || {})['X-Zold-Error']
220
220
  raise error unless error.nil?
221
221
  unless http.code == 200 || http.code == 302
222
222
  @log.debug(http.body)
@@ -22,6 +22,7 @@
22
22
 
23
23
  require 'loog'
24
24
  require 'minitest/autorun'
25
+ require 'webmock/minitest'
25
26
  require_relative '../../lib/zold/wts'
26
27
 
27
28
  # WTS test.
@@ -32,6 +33,7 @@ class TestWTS < Minitest::Test
32
33
  KEY = '0000000000000000-b416493aefae4ca487c4739050aaec15'
33
34
 
34
35
  def test_pulls
36
+ WebMock.allow_net_connect!
35
37
  wts = Zold::WTS.new(KEY, log: Loog::VERBOSE)
36
38
  job = wts.pull
37
39
  wts.wait(job)
@@ -39,6 +41,7 @@ class TestWTS < Minitest::Test
39
41
  end
40
42
 
41
43
  def test_finds_transactions
44
+ WebMock.allow_net_connect!
42
45
  wts = Zold::WTS.new(KEY, log: Loog::VERBOSE)
43
46
  job = wts.pull
44
47
  wts.wait(job)
@@ -46,11 +49,13 @@ class TestWTS < Minitest::Test
46
49
  end
47
50
 
48
51
  def test_retrieves_wallet_id
52
+ WebMock.allow_net_connect!
49
53
  wts = Zold::WTS.new(KEY, log: Loog::VERBOSE)
50
54
  assert(!wts.id.nil?)
51
55
  end
52
56
 
53
57
  def test_retrieves_balance
58
+ WebMock.allow_net_connect!
54
59
  wts = Zold::WTS.new(KEY, log: Loog::VERBOSE)
55
60
  job = wts.pull
56
61
  wts.wait(job)
@@ -58,15 +63,24 @@ class TestWTS < Minitest::Test
58
63
  end
59
64
 
60
65
  def test_retrieves_usd_rate
66
+ WebMock.allow_net_connect!
61
67
  wts = Zold::WTS.new(KEY, log: Loog::VERBOSE)
62
68
  rate = wts.usd_rate
63
69
  assert(!rate.nil?)
64
70
  end
65
71
 
66
72
  def test_works_with_fake
73
+ WebMock.allow_net_connect!
67
74
  wts = Zold::WTS::Fake.new
68
75
  job = wts.pull
69
76
  wts.wait(job)
70
77
  assert(!wts.balance.zero?)
71
78
  end
79
+
80
+ def test_works_with_webmock
81
+ WebMock.disable_net_connect!
82
+ stub_request(:get, 'https://wts.zold.io/usd_rate').to_return(body: '1.234')
83
+ wts = Zold::WTS.new('fake', log: Loog::VERBOSE)
84
+ assert_equal(1.234, wts.usd_rate)
85
+ end
72
86
  end
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
29
29
  s.rubygems_version = '2.2'
30
30
  s.required_ruby_version = '>=2.5'
31
31
  s.name = 'zold-ruby-sdk'
32
- s.version = '0.2.0'
32
+ s.version = '0.2.1'
33
33
  s.license = 'MIT'
34
34
  s.summary = 'Zold score'
35
35
  s.description = 'Ruby SDK for Zold online wallets management system (WTS)'
@@ -52,4 +52,5 @@ Gem::Specification.new do |s|
52
52
  s.add_development_dependency 'rspec-rails', '3.8.1'
53
53
  s.add_development_dependency 'rubocop', '0.62.0'
54
54
  s.add_development_dependency 'rubocop-rspec', '1.31.0'
55
+ s.add_development_dependency 'webmock', '3.5.1'
55
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold-ruby-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-05 00:00:00.000000000 Z
11
+ date: 2019-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: loog
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - '='
165
165
  - !ruby/object:Gem::Version
166
166
  version: 1.31.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: webmock
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 3.5.1
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '='
179
+ - !ruby/object:Gem::Version
180
+ version: 3.5.1
167
181
  description: Ruby SDK for Zold online wallets management system (WTS)
168
182
  email: yegor256@gmail.com
169
183
  executables: []