-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce method to get driver hosts to be ignored by VCR, WebMock #109
Comments
Well, they aren' t currently public methods, but you could:
Especially now that you can require only the drivers you want to use, I'm not sure it makes sense for the project to roll this up into a single method... |
Thanks thats interesting. So you can get all of the # With activesupport gem
driver_urls = Webdrivers::Common.subclasses.map { |driver| driver.send(:base_url) }
# Without activesupport
driver_urls = (ObjectSpace.each_object(Webdrivers::Common.singleton_class).to_a - [Webdrivers::Common]).map { |driver| driver.send(:base_url) } Which reduces the config a little to: VCR.configure { |config| config.ignore_hosts(*driver_urls) }
WebMock.disable_net_connect!(allow_localhost: true, allow: driver_urls) |
Ok, I just merged in code that will make |
Thanks @titusfortner! Here's some code using the newly-public methods for anyone who stumbles on this issue and wants to know how to use them with VCR and WebMock: # With activesupport gem
driver_urls = Webdrivers::Common.subclasses.map(&:base_url)
# Without activesupport gem
driver_urls = (ObjectSpace.each_object(Webdrivers::Common.singleton_class).to_a - [Webdrivers::Common]).map(&:base_url)
VCR.configure { |config| config.ignore_hosts(*driver_urls) }
WebMock.disable_net_connect!(allow_localhost: true, allow: driver_urls) (I tried updating the wiki page but it looks like its not open for public edits.) |
Hi @eliotsykes, I have updated the wiki with the information you have provided - https://github.com/titusfortner/webdrivers/wiki/Using-with-VCR-or-WebMock Let me know if anything can be improved. Thanks! |
This is now available in 3.9.4 |
Also, ftr, I changed the wiki so that anyone can add to it. |
Hey folks, I’ve tried this but it didn’t work. However, extracting just the host made it work: driver_urls = Webdrivers::Common.subclasses.map do |driver|
Addressable::URI.parse(driver.base_url).host
end |
@gnclmorais When I try and use
Feel like |
According to [1], chromedriver-helper is unmaintained. Its former maintainer encourages using webdrivers [2]. As part of this change, we allow connections to update drivers in the WebMock config. See [3] for details about this. [1] https://github.com/flavorjones/chromedriver-helper#notice-this-gem-is-out-of-support-as-of-2019-03-31 [2] https://github.com/titusfortner/webdrivers [3] titusfortner/webdrivers#109 REDMINE-17242
Resolves: $ docker-compose run --rm osem bundle exec rspec --tag js … WebMock::NetConnectNotAllowedError See titusfortner/webdrivers#109 for details.
Resolves openSUSE#2557: $ docker-compose run --rm osem bundle exec rspec --tag js … WebMock::NetConnectNotAllowedError See titusfortner/webdrivers#109 for details.
Resolves openSUSE#2557: $ docker-compose run --rm osem bundle exec rspec --tag js … WebMock::NetConnectNotAllowedError See titusfortner/webdrivers#109 for details.
Consider adding a method to webdrivers to return all of the driver hosts that ought to be ignored by testing tools like VCR and WebMock.
This would simplify the supporting config as follows:
This code was modified from the code provided at https://github.com/titusfortner/webdrivers/wiki/Using-with-VCR-or-WebMock
The text was updated successfully, but these errors were encountered: