# encoding: utf-8 require 'spec_helper' require 'spec_helper_features' describe 'Lookup proxy for url' do context '/v1/lookup' do let(:valid_pac_file) do <<-EOS.strip_heredoc.chomp function FindProxyForURL(url, host) { return "DIRECT"; } EOS end let(:pac_file_return_nil) do <<-EOS.strip_heredoc.chomp function FindProxyForURL(url, host) { return ""; } EOS end let(:git_repo) { File.join(working_directory, 'git_repo.git') } before :each do repo = GitRepository.create(git_repo) repo.add_content('file.pac', valid_pac_file) end before :each do config = Class.new do include FeduxOrg::Stdlib::Filesystem def root_directory ::File.expand_path('../../../', __FILE__) end def local_storage ::File.join(working_directory, 'git_repo.git') end end.new LocalPac.config = config Capybara.app = LocalPac::App::LookupController end it 'looks up proxy for valid url' do search_for 'http://www.example.org', 'You asked me to look up' end it 'returns a error message for a invalid url' do visit('/file.pac') within('#search') do fill_in 'url', :with => '§ASDF$$' end click_on('Search') expect(page).to have_content('Invalid URL...') end it 'returns a error message for a invalid url on the second page' do visit('/file.pac') within('#search') do fill_in 'url', :with => 'http://www.example.org' end click_on('Search') within('#search') do fill_in 'url', :with => '§ASDF$$' end click_on('Search') expect(page).to have_content('Invalid URL...') end it 'returns a error message for a invalid url' do visit('/file.pac') within('#search') do fill_in 'url', :with => '' end click_on('Search') expect(page).to have_content('Invalid URL...') end end end