Closed jessethebuilder closed 2 years ago
Looks like you're getting help on SO already. Please update this issue if you need more help here (or close it if it gets resolved).
@jessethebuilder have you been able to resolve this issue?
Having a similar issue and not figuring out the resolution over here... I'm not sure what the right setup is to make it work with existing VCR infrastructure in Capybara RSpec feature specs
# rails_helper.rb
require "billy/capybara/rspec"
Billy.configure do |c|
c.cache = true
c.cache_request_headers = false
c.ignore_params = ["http://www.google-analytics.com/__utm.gif",
"https://r.twimg.com/jot",
"http://p.twitter.com/t.gif",
"http://p.twitter.com/f.gif",
"http://www.facebook.com/plugins/like.php",
"https://www.facebook.com/dialog/oauth",
"http://cdn.api.twitter.com/1/urls/count.json"]
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/req_cache/'
c.certs_path = 'spec/req_certs/'
c.proxy_host = 'example.com' # defaults to localhost
c.proxy_port = 12345 # defaults to random
c.proxied_request_host = nil
c.proxied_request_port = 80
c.cache_whitelist = []
c.record_requests = true # defaults to false
c.cache_request_body_methods = ['post', 'patch', 'put'] # defaults to ['post']
end
js_driver = ENV["VISIBLE"] ? :selenium_headless_billy : :selenium_billy
# From puffing-billy; uses Firefox
Capybara.javascript_driver = js_driver
Capybara.server = :webrick
# spec/features/some test spec.rb
RSpec.describe "Some feature", :vcr do
scenario "Some test with a browser which makes network requests in the JS", :js do
# ...
end
end
be rspec engines/member/spec/features/card_management_spec.rb:29
Run options: include {:locations=>{"./engines/member/spec/features/card_management_spec.rb"=>[29]}}
Randomized with seed 52190
Card Management
from account
#<Thread:0x00007f88e5f9a568 /Users/joemsak/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/puffing-billy-2.4.1/lib/billy/proxy.rb:19 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
6: from /Users/joemsak/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/puffing-billy-2.4.1/lib/billy/proxy.rb:19:in `block in start'
5: from /Users/joemsak/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/puffing-billy-2.4.1/lib/billy/proxy.rb:70:in `main_loop'
4: from /Users/joemsak/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in `run'
3: from /Users/joemsak/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in `run_machine'
2: from /Users/joemsak/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/puffing-billy-2.4.1/lib/billy/proxy.rb:76:in `block in main_loop'
1: from /Users/joemsak/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:531:in `start_server'
/Users/joemsak/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:531:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
I just discovered this gem today, please let me know if I missed or misunderstood anything, please let me know what I should do next. Thanks!
Think I got it working actually. Looks like I missed some of the example config from the README that I shouldn't have left in!
Note to future readers, don't leave these in:
c.proxy_host = 'example.com' # defaults to localhost
c.proxy_port = 12345 # defaults to random
I am trying to use RSpec to test a library that uses Capybara to read data from websites, so it is not the instance of Capybara that RSpec uses.
I have the proxy_port set to the port my library's Capybara instance, but then I get this error: 'no acceptor (port is in use or requires root privileges)'
I have an open question on SO for this: https://stackoverflow.com/questions/57174059/puffing-billy-and-multiple-capybara-session/57174811?noredirect=1#comment100918975_57174811