class ProxyTester::Cli::Test
Public Instance Methods
rspec()
click to toggle source
# File lib/proxy_tester/cli/test.rb, line 8 def rspec ProxyTester.config = ProxyTester::Config.new(options[:config_file]) if options[:config_file] ProxyTester.config.log_level = options[:log_level] if options[:log_level] ProxyTester.config.debug_mode = options[:debug_mode] if options[:debug_mode] ProxyTester.config.test_cases_directory = options[:test_cases_directory] if options[:test_cases_directory] ProxyTester.config.lock ProxyTester.ui_logger.level = ProxyTester.config.log_level ProxyTester.enable_debug_mode if ProxyTester.config.debug_mode ProxyTester::RspecRunner.new(tags: options[:tags], test_cases_directory: ProxyTester.config.test_cases_directory).run end
url(*urls)
click to toggle source
# File lib/proxy_tester/cli/test.rb, line 29 def url(*urls) ProxyTester.config = ProxyTester::Config.new(options[:config_file]) if options[:config_file] ProxyTester.config.log_level = options[:log_level] if options[:log_level] ProxyTester.config.debug_mode = options[:debug_mode] if options[:debug_mode] ProxyTester.config.lock ProxyTester.ui_logger.level = ProxyTester.config.log_level ProxyTester.enable_debug_mode if ProxyTester.config.debug_mode proxies = options[:proxy].collect { |p| HttpProxy.new(p) } unless options[:user].blank? user = User.new user.name = options[:user] while user.password.blank? user.password = HighLine.new.ask("Enter password for proxy user \"#{user.name}\": ") { |q| q.echo = '*' } end puts '' proxies.each { |p| p.use_user user } end output = options.fetch(:output, $stdout) if output.kind_of? String output = File.open(output, 'w') else output = $stdout end Actions::ClearEnvironment.new.run proxies.each do |p| ProxyTester.ui_logger.debug "Using proxy \"#{p.to_string}\"" ProxyTester.ui_logger.debug "Using user \"#{user.to_string}\"" action = Actions::FetchUrls.new( urls: urls, timeout: options[:timeout], count: options[:count], proxy: p, concurrent: options[:concurrent], output: output, ) action.run end end