-
Notifications
You must be signed in to change notification settings - Fork 170
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
WebMock and puffing-billy #44
Comments
Just realized in other issues below that there's no need to re-register the :webkit driver. That still hasn't resolved the issue I was seeing, though. |
Have you tried using localhost:8089 (i.e., no http:// prefix) in your whitelist entry? AFAIK, the whitelist only matches host:port, not full urls. |
Yeah I added that in there too, and a bunch of other variations like this: Billy.config.whitelist = [/.*/,"#{server.host}:#{server.port}", 'http://localhost:8089', '//localhost:8089/static', 'localhost:8089', 'localhost', server.host] the /.*/ was attempting to whitelist everything. Is there an option like that? Basically at this point I want it to only stub external requests if I want it to. if I do a visit 'http://www.google.com' could that be related also? Do you guys happen to have an IRC channel or something you hang out on? I feel like it's quite difficult to get a hold of you or @ronwsmith unless I'm lucky! |
Hmm, are you using another proxy server for anything? It sounds like your setup is quite unique. Try tailing your logs, via What does your Lastly, I don't think you'll get real-time support for any gems :) A day or two response is typical for ones under active development. |
this is the output i'm getting atm: puffing-billy: Proxy listening on http://localhost:54085 I created a billy.rb file in the features/support/ folder that gets required when I run cucumber. require_relative '../support/webmock' ### I require this because we use WebMock and it doesnt like one of these calls. server = Capybara.current_session.server Billy.configure do |c| So... right now it seems like the problem lies with these two requests: as you can see in the config, I tried adding in those links to the c.ignore_params array, but this is still happening. I did notice however that the log says "Listening on proxy" and the port is different than my capybara server. Is that just the EM ip? Any ideas on how to further troubleshoot this? Thx for the quick replies! |
Yes the different IP is EM and is expected. I think the root of the issue is the "Firefox is configured to use a proxy server that is refusing connections" error, which is likely outside of puffing-billy. Do you have or require any other proxy servers to hit your web site outside of puffing-billy? It potentially is also webmock blocking requests. I've had to set allow_net_connect! in my spec_helper to get "external" requests to process correctly. |
Yeah, essentially my require_relative '../support/webmock' basically requires a file which does this: WebMock.disable_net_connect!(:allow_localhost => true) Which... afaik shouldn't affect those assets from being loaded. Is there any other data I can look into to better troubleshoot this? |
AFAIK, WebMock doesn't play well with Billy. It hooks into the http client Olly On Wednesday, March 26, 2014, Josiah Anjos notifications@github.com wrote:
|
Ah you guys are right. I did WebMock.allow_net_connect! and everything did render... I would like to keep both though... Do you guys have any experience with using both? Having WebMock allow puffing-billy to do all its magic? Edit: Also, changed the title to reflect the actual issue! |
Great, glad we narrowed it down! Unfortunately, I don't think they will ever work together nicely as they are sort of different solutions for the same issue -- both are intercepting requests and performing some action. Perhaps look into using the stubbing feature of puffing-billy to eliminate whatever need you have for webmock. |
Well, correct me if I'm wrong, but isn't puffing-billy more browser centric, and webmock is more about API calls your app makes? Can puffing-billy do what webmock does for the API? |
You are correct but it's not only API calls for webmock, it's anything in the same thread (whereas browsers are running in a different thread). What I do is limit webmock to unit tests and puffing-billy to feature tests and I turn webmock off and on in before and after blocks for |
Hmm... Gotcha. I was hoping to make puffing-billy a general thing for our cucumber tests, but it looks like it's going to have to be something more localized/specific for some scenarios. We have some cases where we use webmock to return specific data for our api calls during acceptance/feature tests, so if we can't use both, I may have to come up with a custom way of setting up this data. Maybe even in a Before do, checking if the current driver is :webkit_billy, then to do a WebMock.allow_net_connect! or something of the sorts. |
Suggestion does not work in my case. Looks like Webmock kills billy proxy server. I made proxy start/stop for each rspec. proxy runs with fixed TCP port.
|
@aivils, what exactly are you trying to do? Your setup looks overly complicated so my initial assumption is that your test is trying to do too much. Can you provide a (scrubbed) example spec? |
I try to run multiple tests from a single *.rb file
When i use pure puffing-billy, then both tests run fine. When i use puffing-billy and webmock, then 1st test is ok but 2nd test failed because browser reported "cannot connect to proxy server". Anyway each single test runs fine. |
I was able to keep my existing Webmock setting and just enabled puffing billy for a test there i needed it as follows: context 'with proxy', driver: :poltergeist_billy do
scenario 'the user can share the link via facebook', billy: true do
#test logic
end
end my Rspec config RSpec.configure do |config|
config.around(:each, billy: true) do |example|
WebMock.allow_net_connect!
example.run
WebMock.disable_net_connect!(allow_localhost: true)
end
end hope this might help others with same issues ;) |
Few years late, but just stumbled across this: If you're not using EventMachine (or WebMock for any other EM requests): WebMock::HttpLibAdapters::EmHttpRequestAdapter.disable! in spec_helper.rb will disable WebMock's interception of EM HTTP requests, allowing upstream proxy requests to go through. Pretty blunt, but it works. |
You can also do:
|
I'm trying to set up puffing-billy on my local repo, and I'm running into a few issues. I am basically registering the webkit driver like this:
Capybara.register_driver :webkit do |app|
Capybara::Webkit::Driver.new(app)
end
And then I am adding the @billy tag to my scenarios, and I've got a Before hook just like the one you guys have in the readme, which sets the current_driver and javascript_drivers to be :webkit_billy
Now, my issue is that if I visit a page when the driver is just :webkit
I take a screenshot, and everything looks proper, all the assets are there, it looks good.
However; When I run it tagged with @billy, or if I set the current_driver and javascript_driver's to be :webkit_billy, all of the assets are not rendered...
I suspect it might be related to nginx, since the asset host is http://localhost:8089
I added this into a billy.rb file which is in features/support/
server = Capybara.current_session.server
Billy.config.whitelist = ["#{server.host}:#{server.port}/", 'http://localhost:8089']
Doesn't seem to help with my issue though. Should I add anything else beyond that? Am I missing some config settings to get this running properly with capybara-webkit?
just noticed @oesmith was active 20 min ago so I'm hoping to get someone's attention!
The text was updated successfully, but these errors were encountered: