proxy_manager 0.0.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/README.md +43 -18
- data/lib/proxy_manager/proxy.rb +93 -0
- data/lib/proxy_manager.rb +1 -18
- data/proxy_manager.gemspec +4 -6
- data/spec/proxy_manager/proxy_spec.rb +60 -0
- data/spec/proxy_manager_spec.rb +6 -0
- data/spec/spec_helper.rb +3 -6
- data/spec/support/proxies.txt +2 -3
- metadata +10 -48
- data/Gemfile.lock +0 -77
- data/doc/ProxyManager/Main.html +0 -870
- data/doc/ProxyManager.html +0 -357
- data/doc/_index.html +0 -125
- data/doc/class_list.html +0 -54
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -57
- data/doc/css/style.css +0 -339
- data/doc/file.README.html +0 -162
- data/doc/file_list.html +0 -56
- data/doc/frames.html +0 -26
- data/doc/index.html +0 -162
- data/doc/js/app.js +0 -219
- data/doc/js/full_list.js +0 -178
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -119
- data/doc/top-level-namespace.html +0 -112
- data/lib/proxy_manager/main.rb +0 -107
- data/lib/tasks/proxy_manager_tasks.rake +0 -4
- data/spec/proxy_manager/proxy_manager_spec.rb +0 -76
- data/spec/support/bad_proxies.txt +0 -0
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'proxy_manager'
|
3
|
-
|
4
|
-
describe ProxyManager do
|
5
|
-
it { expect(subject.root).not_to be_empty }
|
6
|
-
|
7
|
-
context 'proxies' do
|
8
|
-
let(:list) { [['0.0.1.0', 9000], ['0.0.0.1', 2000], ['0.0.0.0', 7000]] }
|
9
|
-
let(:proxies_file) { File.join(subject.root, 'spec', 'support', 'proxies.txt') }
|
10
|
-
let(:bad_proxies_file) { File.join(subject.root, 'spec', 'support', 'bad_proxies.txt') }
|
11
|
-
let(:proxy) { subject.load(['0.0.1.0:9000', '0.0.0.1:2000', '0.0.0.0:7000']) }
|
12
|
-
|
13
|
-
it 'should return list' do
|
14
|
-
expect(proxy.list).to match_array list
|
15
|
-
end
|
16
|
-
|
17
|
-
context '#connectable' do
|
18
|
-
it 'should response' do
|
19
|
-
expect(proxy).to respond_to(:connectable?)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should receive array' do
|
23
|
-
expect(proxy.connectable?(['google.com', 80])).to be_true
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should receive string' do
|
27
|
-
expect(proxy.connectable?('google.com:80')).to be_true
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context '#get' do
|
32
|
-
it 'should response' do
|
33
|
-
expect(proxy).to respond_to(:get)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should return array' do
|
37
|
-
expect(proxy.get).to be_a Array
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should return many proxies' do
|
41
|
-
expect { proxy.get(3) }.not_to raise_error
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
it { expect(proxy.bad_list).to be_a Array }
|
46
|
-
|
47
|
-
context 'when load from file' do
|
48
|
-
let(:proxy) { subject.load(proxies_file, bad_proxies_file) }
|
49
|
-
|
50
|
-
it 'should return list' do
|
51
|
-
expect(proxy.list).to match_array list
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'and save file' do
|
55
|
-
before { @source = File.read(proxies_file) }
|
56
|
-
|
57
|
-
it 'should update proxies source' do
|
58
|
-
proxy.get(2)
|
59
|
-
|
60
|
-
source = ''
|
61
|
-
proxy.list.each_with_index do |p, index|
|
62
|
-
source << "#{p[0]}:#{p[1]}"
|
63
|
-
source << "\n" if proxy.list[index + 1]
|
64
|
-
end
|
65
|
-
|
66
|
-
expect(File.open(proxies_file, "rb").read).to eq(source)
|
67
|
-
end
|
68
|
-
|
69
|
-
after do
|
70
|
-
File.open(proxies_file, 'w').write(@source)
|
71
|
-
File.open(bad_proxies_file, 'w').truncate(0)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
File without changes
|