Sha256: e6093be1e7c46a4c3767f706740c71aaa6049d42b39bb5d0fd6eea7c57c75971
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
require 'spec_helper' require 'proxy_manager' describe ProxyManager::Proxy do let(:list) { [['127.0.0.1', 80], ['127.0.0.1', 8080]] } let(:proxies_file) { File.join(ProxyManager.root, 'spec', 'support', 'proxies.txt' ) } subject { ProxyManager::Proxy.new(['127.0.0.1:80', '127.0.0.1:8080']) } context '#get' do its(:get) { should be_a Array } it 'should return many proxies' do expect { subject.get(3) }.not_to raise_error end end context '#get!' do it { should respond_to :get! } end context '#list' do its(:list) { should match_array list } end context '::connectable' do it 'should receive array' do expect(ProxyManager::Proxy.connectable?(['127.0.0.1', 8080])).to be_false end it 'should receive string' do expect(ProxyManager::Proxy.connectable?("127.0.0.1:8080")).to be_false end end context 'when load from file' do subject { ProxyManager::Proxy.new(proxies_file) } its(:list) { should match_array list } context 'and save file' do let(:source) { IO.read(proxies_file) } it 'should update proxies source' do subject.get(2) source = '' subject.list.each { |p| source << "#{p[0]}:#{p[1]}\n" } source.sub!(/\n$/, '') expect(IO.read(proxies_file)).to eq(source) end after { IO.write(proxies_file, source) } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
proxy_manager-1.0.1 | spec/proxy_manager/proxy_spec.rb |
proxy_manager-1.0.0 | spec/proxy_manager/proxy_spec.rb |