proxy_fetcher 0.10.2 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -5
- data/Rakefile +4 -2
- data/gemfiles/nokogiri.gemfile +8 -6
- data/gemfiles/oga.gemfile +8 -6
- data/lib/proxy_fetcher.rb +30 -30
- data/lib/proxy_fetcher/client/client.rb +10 -3
- data/lib/proxy_fetcher/client/request.rb +4 -4
- data/lib/proxy_fetcher/configuration.rb +12 -11
- data/lib/proxy_fetcher/document.rb +0 -9
- data/lib/proxy_fetcher/document/adapters.rb +1 -1
- data/lib/proxy_fetcher/document/adapters/abstract_adapter.rb +3 -12
- data/lib/proxy_fetcher/document/adapters/nokogiri_adapter.rb +1 -1
- data/lib/proxy_fetcher/document/adapters/oga_adapter.rb +1 -1
- data/lib/proxy_fetcher/document/node.rb +2 -2
- data/lib/proxy_fetcher/exceptions.rb +6 -6
- data/lib/proxy_fetcher/manager.rb +2 -2
- data/lib/proxy_fetcher/providers/base.rb +42 -22
- data/lib/proxy_fetcher/providers/free_proxy_list.rb +30 -10
- data/lib/proxy_fetcher/providers/free_proxy_list_ssl.rb +7 -16
- data/lib/proxy_fetcher/providers/gather_proxy.rb +9 -17
- data/lib/proxy_fetcher/providers/http_tunnel.rb +11 -19
- data/lib/proxy_fetcher/providers/proxy_list.rb +8 -16
- data/lib/proxy_fetcher/providers/xroxy.rb +9 -17
- data/lib/proxy_fetcher/proxy.rb +4 -4
- data/lib/proxy_fetcher/utils/http_client.rb +10 -8
- data/lib/proxy_fetcher/utils/proxy_list_validator.rb +3 -1
- data/lib/proxy_fetcher/utils/proxy_validator.rb +1 -1
- data/lib/proxy_fetcher/version.rb +3 -3
- data/proxy_fetcher.gemspec +19 -16
- data/spec/proxy_fetcher/client/client_spec.rb +72 -57
- data/spec/proxy_fetcher/configuration_spec.rb +11 -11
- data/spec/proxy_fetcher/document/adapters_spec.rb +8 -8
- data/spec/proxy_fetcher/document/node_spec.rb +4 -4
- data/spec/proxy_fetcher/providers/base_spec.rb +9 -9
- data/spec/proxy_fetcher/providers/free_proxy_list_spec.rb +2 -2
- data/spec/proxy_fetcher/providers/free_proxy_list_ssl_spec.rb +2 -2
- data/spec/proxy_fetcher/providers/gather_proxy_spec.rb +2 -2
- data/spec/proxy_fetcher/providers/http_tunnel_spec.rb +2 -2
- data/spec/proxy_fetcher/providers/multiple_providers_spec.rb +4 -4
- data/spec/proxy_fetcher/providers/proxy_list_spec.rb +2 -2
- data/spec/proxy_fetcher/providers/xroxy_spec.rb +2 -2
- data/spec/proxy_fetcher/proxy_spec.rb +14 -14
- data/spec/proxy_fetcher/version_spec.rb +2 -0
- data/spec/spec_helper.rb +10 -10
- data/spec/support/manager_examples.rb +21 -21
- metadata +14 -8
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe ProxyFetcher::Configuration do
|
6
6
|
before { ProxyFetcher.config.reset! }
|
7
7
|
after { ProxyFetcher.config.reset! }
|
8
8
|
|
9
|
-
context
|
10
|
-
it
|
9
|
+
context "custom HTTP client" do
|
10
|
+
it "successfully setups if class has all the required methods" do
|
11
11
|
class MyHTTPClient
|
12
12
|
def self.fetch(url)
|
13
13
|
url
|
@@ -17,7 +17,7 @@ describe ProxyFetcher::Configuration do
|
|
17
17
|
expect { ProxyFetcher.config.http_client = MyHTTPClient }.not_to raise_error
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it "failed on setup if required methods are missing" do
|
21
21
|
MyWrongHTTPClient = Class.new
|
22
22
|
|
23
23
|
expect { ProxyFetcher.config.http_client = MyWrongHTTPClient }
|
@@ -25,8 +25,8 @@ describe ProxyFetcher::Configuration do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
context
|
29
|
-
it
|
28
|
+
context "custom proxy validator" do
|
29
|
+
it "successfully setups if class has all the required methods" do
|
30
30
|
class MyProxyValidator
|
31
31
|
def self.connectable?(*)
|
32
32
|
true
|
@@ -36,7 +36,7 @@ describe ProxyFetcher::Configuration do
|
|
36
36
|
expect { ProxyFetcher.config.proxy_validator = MyProxyValidator }.not_to raise_error
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
39
|
+
it "failed on setup if required methods are missing" do
|
40
40
|
MyWrongProxyValidator = Class.new
|
41
41
|
|
42
42
|
expect { ProxyFetcher.config.proxy_validator = MyWrongProxyValidator }
|
@@ -44,8 +44,8 @@ describe ProxyFetcher::Configuration do
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
context
|
48
|
-
it
|
47
|
+
context "custom provider" do
|
48
|
+
it "fails on registration if provider class already registered" do
|
49
49
|
expect { ProxyFetcher::Configuration.register_provider(:xroxy, Class.new) }
|
50
50
|
.to raise_error(ProxyFetcher::Exceptions::RegisteredProvider)
|
51
51
|
end
|
@@ -58,13 +58,13 @@ describe ProxyFetcher::Configuration do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
context
|
61
|
+
context "custom HTML parsing adapter" do
|
62
62
|
it "fails if adapter can't be installed" do
|
63
63
|
old_adapter = ProxyFetcher.config.adapter.dup
|
64
64
|
|
65
65
|
class CustomAdapter < ProxyFetcher::Document::AbstractAdapter
|
66
66
|
def self.install_requirements!
|
67
|
-
require
|
67
|
+
require "not_existing_gem"
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -1,26 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe ProxyFetcher::Document::Adapters do
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
expect(described_class.lookup(
|
6
|
+
describe "#lookup" do
|
7
|
+
it "returns predefined adapters if symbol or string passed" do
|
8
|
+
expect(described_class.lookup("nokogiri")).to eq(ProxyFetcher::Document::NokogiriAdapter)
|
9
9
|
|
10
10
|
expect(described_class.lookup(:oga)).to eq(ProxyFetcher::Document::OgaAdapter)
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it "returns self if class passed" do
|
14
14
|
expect(described_class.lookup(Struct)).to eq(Struct)
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it "raises an exception if passed value is blank" do
|
18
18
|
expect { described_class.lookup(nil) }.to raise_error(ProxyFetcher::Exceptions::BlankAdapter)
|
19
|
-
expect { described_class.lookup(
|
19
|
+
expect { described_class.lookup("") }.to raise_error(ProxyFetcher::Exceptions::BlankAdapter)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "raises an exception if adapter doesn't exist" do
|
23
|
-
expect { described_class.lookup(
|
23
|
+
expect { described_class.lookup("wrong") }.to raise_error(ProxyFetcher::Exceptions::UnknownAdapter)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe ProxyFetcher::Document::Node do
|
6
|
-
context
|
7
|
-
it
|
8
|
-
node = ProxyFetcher::Document::Node.new(
|
6
|
+
context "overridable methods" do
|
7
|
+
it "raises an error" do
|
8
|
+
node = ProxyFetcher::Document::Node.new("")
|
9
9
|
|
10
10
|
%w[content html].each do |method|
|
11
11
|
expect { node.public_send(method) }.to raise_error do |error|
|
@@ -1,37 +1,37 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe ProxyFetcher::Providers::Base do
|
6
6
|
before { ProxyFetcher.config.reset! }
|
7
7
|
after { ProxyFetcher.config.reset! }
|
8
8
|
|
9
|
-
it
|
9
|
+
it "does not allows to use not implemented methods" do
|
10
10
|
NotImplementedCustomProvider = Class.new(ProxyFetcher::Providers::Base)
|
11
11
|
|
12
12
|
ProxyFetcher::Configuration.register_provider(:provider_without_methods, NotImplementedCustomProvider)
|
13
13
|
ProxyFetcher.config.provider = :provider_without_methods
|
14
14
|
|
15
15
|
expect { ProxyFetcher::Manager.new }.to raise_error(NotImplementedError) do |error|
|
16
|
-
expect(error.message).to include(
|
16
|
+
expect(error.message).to include("provider_url")
|
17
17
|
end
|
18
18
|
|
19
19
|
# implement one of the methods
|
20
20
|
NotImplementedCustomProvider.class_eval do
|
21
|
-
def
|
22
|
-
|
21
|
+
def provider_url
|
22
|
+
"http://provider.com"
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
expect { ProxyFetcher::Manager.new }.to raise_error(NotImplementedError) do |error|
|
27
|
-
expect(error.message).to include(
|
27
|
+
expect(error.message).to include("xpath")
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
31
|
+
it "logs failed to load proxy providers" do
|
32
32
|
CustomProvider = Class.new(ProxyFetcher::Providers::Base) do
|
33
33
|
def load_proxy_list(*)
|
34
|
-
doc = load_document(
|
34
|
+
doc = load_document("https://google.com", {})
|
35
35
|
doc.xpath('//table[contains(@class, "table")]/tr[(not(@id="proxy-table-header")) and (count(td)>2)]')
|
36
36
|
end
|
37
37
|
end
|
@@ -44,7 +44,7 @@ describe ProxyFetcher::Providers::Base do
|
|
44
44
|
|
45
45
|
allow_any_instance_of(HTTP::Client).to receive(:get).and_raise(StandardError)
|
46
46
|
|
47
|
-
expect(logger).to receive(:warn).with(
|
47
|
+
expect(logger).to receive(:warn).with(%r{Failed to process request to http[s:/]})
|
48
48
|
|
49
49
|
ProxyFetcher::Manager.new
|
50
50
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe ProxyFetcher::Providers::FreeProxyList do
|
6
6
|
before :all do
|
@@ -9,5 +9,5 @@ describe ProxyFetcher::Providers::FreeProxyList do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
it_behaves_like
|
12
|
+
it_behaves_like "a manager"
|
13
13
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe ProxyFetcher::Providers::FreeProxyListSSL do
|
6
6
|
before :all do
|
7
7
|
ProxyFetcher.config.provider = :free_proxy_list_ssl
|
8
8
|
end
|
9
9
|
|
10
|
-
it_behaves_like
|
10
|
+
it_behaves_like "a manager"
|
11
11
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe ProxyFetcher::Providers::GatherProxy do
|
6
6
|
before :all do
|
7
7
|
ProxyFetcher.config.provider = :gather_proxy
|
8
8
|
end
|
9
9
|
|
10
|
-
it_behaves_like
|
10
|
+
it_behaves_like "a manager"
|
11
11
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe ProxyFetcher::Providers::HTTPTunnel do
|
6
6
|
before :all do
|
7
7
|
ProxyFetcher.config.provider = :http_tunnel
|
8
8
|
end
|
9
9
|
|
10
|
-
it_behaves_like
|
10
|
+
it_behaves_like "a manager"
|
11
11
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe "Multiple proxy providers" do
|
6
6
|
before { ProxyFetcher.config.reset! }
|
7
7
|
after { ProxyFetcher.config.reset! }
|
8
8
|
|
9
|
-
it
|
10
|
-
proxy_stub = ProxyFetcher::Proxy.new(addr:
|
9
|
+
it "combine proxies from multiple providers" do
|
10
|
+
proxy_stub = ProxyFetcher::Proxy.new(addr: "192.168.1.1", port: 8080)
|
11
11
|
|
12
12
|
# Each proxy provider will return 2 proxies
|
13
13
|
ProxyFetcher::Configuration.providers_registry.providers.each do |_name, klass|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe ProxyFetcher::Providers::ProxyList do
|
6
6
|
before :all do
|
7
7
|
ProxyFetcher.config.provider = :proxy_list
|
8
8
|
end
|
9
9
|
|
10
|
-
it_behaves_like
|
10
|
+
it_behaves_like "a manager"
|
11
11
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe ProxyFetcher::Providers::XRoxy do
|
6
6
|
before :all do
|
7
7
|
ProxyFetcher.config.provider = :xroxy
|
8
8
|
end
|
9
9
|
|
10
|
-
it_behaves_like
|
10
|
+
it_behaves_like "a manager"
|
11
11
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe ProxyFetcher::Proxy do
|
6
|
-
let(:proxy) { described_class.new(addr:
|
6
|
+
let(:proxy) { described_class.new(addr: "192.169.1.1", port: 8080, type: "HTTP") }
|
7
7
|
|
8
|
-
it
|
9
|
-
proxy = described_class.new(addr:
|
8
|
+
it "can initialize a new proxy object" do
|
9
|
+
proxy = described_class.new(addr: "192.169.1.1", port: 8080, type: "HTTP")
|
10
10
|
|
11
11
|
expect(proxy).not_to be_nil
|
12
|
-
expect(proxy.addr).to eq(
|
12
|
+
expect(proxy.addr).to eq("192.169.1.1")
|
13
13
|
expect(proxy.port).to eq(8080)
|
14
|
-
expect(proxy.type).to eq(
|
14
|
+
expect(proxy.type).to eq("HTTP")
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it "checks schema" do
|
18
18
|
proxy.type = ProxyFetcher::Proxy::HTTP
|
19
19
|
expect(proxy.http?).to be_truthy
|
20
20
|
expect(proxy.https?).to be_falsey
|
@@ -34,28 +34,28 @@ describe ProxyFetcher::Proxy do
|
|
34
34
|
expect(proxy.ssl?).to be_truthy
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
38
|
-
proxy.addr =
|
37
|
+
it "not connectable if IP addr is wrong" do
|
38
|
+
proxy.addr = "192.168.1.0"
|
39
39
|
expect(proxy.connectable?).to be_falsey
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
42
|
+
it "not connectable if there are some error during connection request" do
|
43
43
|
allow_any_instance_of(HTTP::Client).to receive(:head).and_raise(HTTP::TimeoutError)
|
44
44
|
expect(proxy.connectable?).to be_falsey
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
47
|
+
it "returns URI::Generic" do
|
48
48
|
expect(proxy.uri).to be_a(URI::Generic)
|
49
49
|
|
50
50
|
expect(proxy.uri.host).not_to be_empty
|
51
51
|
expect(proxy.uri.port).not_to be_nil
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
54
|
+
it "returns URL" do
|
55
55
|
expect(proxy.url).to be_a(String)
|
56
56
|
end
|
57
57
|
|
58
|
-
it
|
59
|
-
expect(proxy.url(scheme: true)).to include(
|
58
|
+
it "returns URL with scheme" do
|
59
|
+
expect(proxy.url(scheme: true)).to include("://")
|
60
60
|
end
|
61
61
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
SimpleCov.add_filter
|
5
|
-
SimpleCov.add_filter
|
3
|
+
require "simplecov"
|
4
|
+
SimpleCov.add_filter "spec"
|
5
|
+
SimpleCov.add_filter "version"
|
6
6
|
|
7
|
-
if ENV[
|
8
|
-
require
|
7
|
+
if ENV["CI"] || ENV["TRAVIS"] || ENV["COVERALLS"] || ENV["JENKINS_URL"]
|
8
|
+
require "coveralls"
|
9
9
|
Coveralls.wear!
|
10
10
|
else
|
11
11
|
SimpleCov.start
|
12
12
|
end
|
13
13
|
|
14
|
-
require
|
14
|
+
require "bundler/setup"
|
15
15
|
Bundler.setup
|
16
16
|
|
17
|
-
require
|
17
|
+
require "proxy_fetcher"
|
18
18
|
|
19
|
-
Dir[
|
19
|
+
Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
|
20
20
|
|
21
|
-
adapter = ENV[
|
21
|
+
adapter = ENV["BUNDLE_GEMFILE"][%r{.+/(.+)\.gemfile}i, 1] || :nokogiri
|
22
22
|
puts "Configured adapter: '#{adapter}'"
|
23
23
|
|
24
24
|
ProxyFetcher.configure do |config|
|
@@ -26,5 +26,5 @@ ProxyFetcher.configure do |config|
|
|
26
26
|
end
|
27
27
|
|
28
28
|
RSpec.configure do |config|
|
29
|
-
config.order =
|
29
|
+
config.order = "random"
|
30
30
|
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.shared_examples
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
RSpec.shared_examples "a manager" do
|
4
|
+
before :all do
|
5
|
+
@cached_manager = ProxyFetcher::Manager.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "loads proxy list on initialization by default" do
|
9
|
+
expect(@cached_manager.proxies).not_to be_empty
|
7
10
|
end
|
8
11
|
|
9
12
|
it "doesn't load proxy list on initialization if `refresh` argument was set to false" do
|
@@ -11,11 +14,10 @@ RSpec.shared_examples 'a manager' do
|
|
11
14
|
expect(manager.proxies).to be_empty
|
12
15
|
end
|
13
16
|
|
14
|
-
it
|
15
|
-
|
16
|
-
expect(manager.proxies).to all(be_a(ProxyFetcher::Proxy))
|
17
|
+
it "returns valid Proxy objects" do
|
18
|
+
expect(@cached_manager.proxies).to all(be_a(ProxyFetcher::Proxy))
|
17
19
|
|
18
|
-
|
20
|
+
@cached_manager.proxies.each do |proxy|
|
19
21
|
expect(proxy.addr).to match(/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/i)
|
20
22
|
expect(proxy.port).to be_a_kind_of(Numeric)
|
21
23
|
expect(proxy.type).not_to be_empty
|
@@ -25,12 +27,11 @@ RSpec.shared_examples 'a manager' do
|
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
|
-
it
|
29
|
-
|
30
|
-
expect(manager.raw_proxies).to all(be_a(String))
|
30
|
+
it "returns raw proxies (HOST:PORT)" do
|
31
|
+
expect(@cached_manager.raw_proxies).to all(be_a(String))
|
31
32
|
end
|
32
33
|
|
33
|
-
it
|
34
|
+
it "cleanup proxy list from dead servers" do
|
34
35
|
allow_any_instance_of(ProxyFetcher::Proxy).to receive(:connectable?).and_return(false)
|
35
36
|
|
36
37
|
manager = ProxyFetcher::Manager.new
|
@@ -45,7 +46,7 @@ RSpec.shared_examples 'a manager' do
|
|
45
46
|
expect(manager.inspect).to eq(manager.to_s)
|
46
47
|
end
|
47
48
|
|
48
|
-
it
|
49
|
+
it "returns first proxy" do
|
49
50
|
manager = ProxyFetcher::Manager.new
|
50
51
|
|
51
52
|
first_proxy = manager.proxies.first
|
@@ -54,16 +55,16 @@ RSpec.shared_examples 'a manager' do
|
|
54
55
|
expect(manager.proxies.first).not_to eq(first_proxy)
|
55
56
|
end
|
56
57
|
|
57
|
-
it
|
58
|
+
it "returns first valid proxy" do
|
58
59
|
manager = ProxyFetcher::Manager.new(refresh: false)
|
59
60
|
|
60
|
-
proxies = Array.new(5) { instance_double(
|
61
|
+
proxies = Array.new(5) { instance_double("ProxyFetcher::Proxy", connectable?: false) }
|
61
62
|
manager.instance_variable_set(:@proxies, proxies)
|
62
63
|
|
63
|
-
connectable_proxy = instance_double(
|
64
|
+
connectable_proxy = instance_double("ProxyFetcher::Proxy")
|
64
65
|
allow(connectable_proxy).to receive(:connectable?).and_return(true)
|
65
66
|
|
66
|
-
manager.proxies[0..2].each { |proxy| proxy.instance_variable_set(:@addr,
|
67
|
+
manager.proxies[0..2].each { |proxy| proxy.instance_variable_set(:@addr, "192.168.1.1") }
|
67
68
|
manager.proxies[2] = connectable_proxy
|
68
69
|
|
69
70
|
expect(manager.get!).to eq(connectable_proxy)
|
@@ -73,15 +74,14 @@ RSpec.shared_examples 'a manager' do
|
|
73
74
|
expect(manager.proxies.size).to be(1)
|
74
75
|
end
|
75
76
|
|
76
|
-
it
|
77
|
+
it "returns nothing if proxy list is empty" do
|
77
78
|
manager = ProxyFetcher::Manager.new(refresh: false)
|
78
79
|
|
79
80
|
expect(manager.get).to be_nil
|
80
81
|
expect(manager.get!).to be_nil
|
81
82
|
end
|
82
83
|
|
83
|
-
it
|
84
|
-
|
85
|
-
expect(manager.random).to be_an_instance_of(ProxyFetcher::Proxy)
|
84
|
+
it "returns random proxy" do
|
85
|
+
expect(@cached_manager.random).to be_an_instance_of(ProxyFetcher::Proxy)
|
86
86
|
end
|
87
87
|
end
|