fbe 0.0.23 → 0.0.24

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: b13ad3c8a5578c4a9e248948cab63ae21caeea7052d96260f2be85a43ee6f3b8
4
- data.tar.gz: 90f8b081a67be3fd2f94a92cea890abb9b93f9b4b11a37a7bc6502f704c16510
3
+ metadata.gz: 37b5cbcd563d2e31074d5f6625d32fd118a5302a4bcd021492639573e657b03e
4
+ data.tar.gz: 1045c3932e3952740ed611c42e0ed034de522281496cb7a5bc9953b1aa821eef
5
5
  SHA512:
6
- metadata.gz: 9ea216f0e9be56b06ae8e350ea89b341f9d9fc230ca7785f5b0c0a494fcba3de913143e9c0c5d7074eea3ad368520bfaa462f891c5daf744b4ababbf05e600e8
7
- data.tar.gz: 28c70598550a0e68ad1315fee0adce8ebeb31a7eb400f348181c0f916b3b5aac646a1d4f8d51d79f70e5553f3a4a88b33ba4afd67f2075a735cb578ea5312f0c
6
+ metadata.gz: 4fb03336064109e32074c267d9a21520e1e24e5b4ced00ab38f06df2b6f6d80f9d9c4cb899fb2e35cf3706d78f2d24b99351e6a096b0eafe00aced686b7bda31
7
+ data.tar.gz: 898b56d6e5ad162e52fa457582014106d9155499a10d5b8b5448f41bf8dc094cf16df3d2ef13d9601eec606b0293ca3f276fd750897069e0a1f4c383d26d1cc6
data/Gemfile CHANGED
@@ -32,4 +32,5 @@ gem 'rubocop-performance', '1.21.1', require: false
32
32
  gem 'rubocop-rspec', '3.0.3', require: false
33
33
  gem 'simplecov', '0.22.0', require: false
34
34
  gem 'simplecov-cobertura', '2.1.0', require: false
35
+ gem 'webmock', '3.23.1', require: false
35
36
  gem 'yard', '0.9.36', require: false
data/Gemfile.lock CHANGED
@@ -55,6 +55,9 @@ GEM
55
55
  builder (3.3.0)
56
56
  concurrent-ruby (1.3.3)
57
57
  connection_pool (2.4.1)
58
+ crack (1.0.0)
59
+ bigdecimal
60
+ rexml
58
61
  crass (1.0.6)
59
62
  decoor (0.0.1)
60
63
  diff-lcs (1.5.1)
@@ -87,7 +90,8 @@ GEM
87
90
  ffi (1.17.0-x64-mingw-ucrt)
88
91
  ffi (1.17.0-x86_64-darwin)
89
92
  ffi (1.17.0-x86_64-linux-gnu)
90
- gli (2.21.3)
93
+ gli (2.21.5)
94
+ hashdiff (1.1.0)
91
95
  i18n (1.14.5)
92
96
  concurrent-ruby (~> 1.0)
93
97
  io-console (0.7.2)
@@ -241,6 +245,10 @@ GEM
241
245
  verbose (0.0.2)
242
246
  loog (~> 0.2)
243
247
  tago (~> 0.0)
248
+ webmock (3.23.1)
249
+ addressable (>= 2.8.0)
250
+ crack (>= 0.3.2)
251
+ hashdiff (>= 0.4.0, < 2.0.0)
244
252
  webrick (1.8.1)
245
253
  yaml (0.3.0)
246
254
  yard (0.9.36)
@@ -263,6 +271,7 @@ DEPENDENCIES
263
271
  rubocop-rspec (= 3.0.3)
264
272
  simplecov (= 0.22.0)
265
273
  simplecov-cobertura (= 2.1.0)
274
+ webmock (= 3.23.1)
266
275
  yard (= 0.9.36)
267
276
 
268
277
  BUNDLED WITH
data/lib/fbe/octo.rb CHANGED
@@ -57,9 +57,14 @@ def Fbe.octo(options: $options, global: $global, loog: $loog)
57
57
  }
58
58
  }
59
59
  stack = Faraday::RackBuilder.new do |builder|
60
- builder.use(Faraday::Retry::Middleware)
61
- builder.use(Faraday::HttpCache, serializer: Marshal, shared_cache: false)
60
+ builder.use(
61
+ Faraday::Retry::Middleware,
62
+ exceptions: Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [Octokit::TooManyRequests],
63
+ max: 5, interval: 1
64
+ )
65
+ builder.use(Faraday::HttpCache, serializer: Marshal, shared_cache: false, logger: Loog::NULL)
62
66
  builder.use(Octokit::Response::RaiseError)
67
+ builder.use(Faraday::Response::Logger, Loog::NULL)
63
68
  builder.adapter(Faraday.default_adapter)
64
69
  end
65
70
  o.middleware = stack
data/lib/fbe.rb CHANGED
@@ -27,5 +27,5 @@
27
27
  # License:: MIT
28
28
  module Fbe
29
29
  # Current version of the gem (changed by .rultor.yml on every release)
30
- VERSION = '0.0.23'
30
+ VERSION = '0.0.24'
31
31
  end
@@ -24,6 +24,7 @@
24
24
 
25
25
  require 'minitest/autorun'
26
26
  require 'judges/options'
27
+ require 'webmock/minitest'
27
28
  require 'loog'
28
29
  require_relative '../test__helper'
29
30
  require_relative '../../lib/fbe/octo'
@@ -54,8 +55,34 @@ class TestOcto < Minitest::Test
54
55
  assert_equal(100, o.rate_limit.remaining)
55
56
  end
56
57
 
58
+ def test_caching
59
+ WebMock.disable_net_connect!
60
+ global = {}
61
+ o = Fbe.octo(loog: Loog::NULL, global:, options: Judges::Options.new)
62
+ stub_request(:get, 'https://api.github.com/users/yegor256')
63
+ .to_return(status: 200, body: '{}', headers: { 'Cache-Control' => 'public, max-age=60', 'etag' => 'abc' })
64
+ .times(1)
65
+ .then
66
+ .to_raise('second request should be cached, not passed to GitHub API!')
67
+ o.user('yegor256')
68
+ o.user('yegor256')
69
+ end
70
+
71
+ def test_retrying
72
+ WebMock.disable_net_connect!
73
+ global = {}
74
+ o = Fbe.octo(loog: Loog::NULL, global:, options: Judges::Options.new)
75
+ stub_request(:get, 'https://api.github.com/users/yegor256')
76
+ .to_raise(Octokit::TooManyRequests.new)
77
+ .times(1)
78
+ .then
79
+ .to_return(status: 200, body: '{}')
80
+ o.user('yegor256')
81
+ end
82
+
57
83
  def test_with_broken_token
58
84
  skip # it's a "live" test, run it manually if you need it
85
+ WebMock.enable_net_connect!
59
86
  global = {}
60
87
  options = Judges::Options.new({ 'github_token' => 'incorrect-value' })
61
88
  o = Fbe.octo(loog: Loog::NULL, global:, options:)
@@ -64,6 +91,7 @@ class TestOcto < Minitest::Test
64
91
 
65
92
  def test_commit_pulls
66
93
  skip # it's a "live" test, run it manually if you need it
94
+ WebMock.enable_net_connect!
67
95
  o = Fbe.octo(loog: Loog::NULL, global: {}, options: Judges::Options.new)
68
96
  assert_equal(1, o.commit_pulls('zerocracy/fbe', '0b7d0699bd744b62c0731064c2adaad0c58e1416').size)
69
97
  assert_equal(0, o.commit_pulls('zerocracy/fbe', '16b3ea6b71c6e932ba7666c40ca846ecaa6d6f0d').size)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko