喘气的比利和多个水豚会议

时间:2019-07-24 01:26:42

标签: web-scraping rspec capybara

我正在尝试使用RSpec来测试使用Capybara从网站读取数据的库。

我想使用PuffingBilly来记录该库中的交互,但是我根本无法让PuffingBilly做出响应,因为我认为它专注于RSpec正在使用的Capybara实例。

如何让PuffingBilly阻止其他Capybara :: Session发出的请求?

回溯

6:从/home/jessethebuilder/.rvm/gems/ruby-2.5.3/gems/puffing-billy-2.1.1/lib/billy/proxy.rb:19:在开始时的块中 5:从/home/jessethebuilder/.rvm/gems/ruby-2.5.3/gems/puffing-billy-2.1.1/lib/billy/proxy.rb:70:inmain_loop'4:从/ home / jessethebuilder /。 rvm / gems / ruby​​-2.5.3 / gems / eventmachine-1.2.7 / lib / eventmachine.rb:195:in run' 3:从/home/jessethebuilder/.rvm/gems/ruby-2.5.3/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:inrun_machine'2:从/home/jessethebuilder/.rvm/gems/ ruby-2.5.3 / gems / puffing-billy-2.1.1 / lib / billy / proxy.rb:76:在main_loop中的块中 1:从/home/jessethebuilder/.rvm/gems/ruby-2.5.3/gems/eventmachine-1.2.7/lib/eventmachine.rb:531:instart_server'/home/jessethebuilder/.rvm/gems/ruby-2.5 .3 / gems / eventmachine-1.2.7 / lib / eventmachine.rb:531:在`start_tcp_server'中:无接受器(端口正在使用或需要root特权)(RuntimeError)

配置(spec / spec_helper.rb)

Billy.configure do |c|
  c.cache = true
  c.cache_request_headers = false
  c.ignore_params = []
  c.path_blacklist = []
  c.merge_cached_responses_whitelist = []
  c.persist_cache = true
  c.ignore_cache_port = true # defaults to true
  c.non_successful_cache_disabled = false
  c.non_successful_error_level = :warn
  c.non_whitelisted_requests_disabled = false
  c.cache_path = 'spec/fixtures/billy/req_cache/'
  c.certs_path = 'spec/fixtures/billy/req_certs/'
  c.proxy_host = 'localhost'
  c.proxy_port = 4461
  # c.proxied_request_host = 'localhost'
  # c.proxied_request_port = 4461
  c.record_requests = true
  c.cache_request_body_methods = ['post', 'patch', 'put', 'get']
end

1 个答案:

答案 0 :(得分:1)

要使膨化比利与库中的Capybara会话进行交互,您需要使用膨化比利代理选项配置用于该会话的驱动程序

请参见https://github.com/oesmith/puffing-billy#customising-the-javascript-driver