Sha256: aed271523eb4db32989f39d1cf071cc38fc53367d1f05e6c4612f240da0891b3

Contents?: true

Size: 821 Bytes

Versions: 2

Compression:

Stored size: 821 Bytes

Contents

require 'spec_helper'

describe ProxyFetcher::Proxy do
  before :all do
    @manager = ProxyFetcher::Manager.new
  end

  let(:proxy) { @manager.proxies.first }

  it 'checks schema' do
    expect(proxy.http?).to be_falsey.or(be_truthy)
    expect(proxy.https?).to be_falsey.or(be_truthy)
  end

  it 'not connectable if IP addr is wrong' do
    allow_any_instance_of(ProxyFetcher::Proxy).to receive(:addr).and_return('192.168.1.1')
    expect(proxy.connectable?).to be_falsey
  end

  it "not connectable if server doesn't respond to head" do
    allow_any_instance_of(Net::HTTP).to receive(:start).and_return(false)
    expect(proxy.connectable?).to be_falsey
  end

  it 'returns URI::Generic' do
    expect(proxy.uri).to be_a(URI::Generic)
  end

  it 'returns URL' do
    expect(proxy.url).to be_a(String)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
proxy_fetcher-0.1.4 spec/proxy_fetcher/proxy_spec.rb
proxy_fetcher-0.1.3 spec/proxy_fetcher/proxy_spec.rb