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.
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :proxy_manager do
3
- # # Task goes here
4
- # end
@@ -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