require 'spec_helper' include GitTrend RSpec.describe GitTrend::Scraper do describe 'proxy settings' do before do allow(ENV).to receive(:[]).with('http_proxy').and_return('http://proxy_user:proxy_pass@192.168.1.99:9999') @scraper = Scraper.new end subject { @scraper.instance_variable_get(:@agent) } its(:proxy_addr) { should eq '192.168.1.99' } its(:proxy_user) { should eq 'proxy_user' } its(:proxy_pass) { should eq 'proxy_pass' } its(:proxy_port) { should eq 9999 } end describe '#get' do context 'when a network error occurred' do before do @scraper = Scraper.new stub_request(:get, Scraper::BASE_URL) .to_return(status: 500, body: '[]') end it { expect { @scraper.get }.to raise_error(Exception) } end end end