Skip to content

Webmock 1.4.0 fails Patron/SSL related spec #53

Closed
graaff opened this Issue Oct 18, 2010 · 5 comments

2 participants

@graaff
graaff commented Oct 18, 2010

I'm getting the following failure when running the webmock 1.4.0 specs:

1)
Patron::TimeoutError in 'Webmock with Patron when web connect is allowed should make a real https request if request is not stubbed'
SSL connection timeout
/var/tmp/portage/dev-ruby/webmock-1.4.0/work/all/webmock-1.4.0/spec/../lib/webmock/http_lib_adapters/patron.rb:19:in handle_request_without_webmock'
/var/tmp/portage/dev-ruby/webmock-1.4.0/work/all/webmock-1.4.0/spec/../lib/webmock/http_lib_adapters/patron.rb:19:in
handle_request'
/usr/lib64/ruby/gems/1.8/gems/patron-0.4.9/lib/patron/session.rb:182:in request'
/var/tmp/portage/dev-ruby/webmock-1.4.0/work/all/webmock-1.4.0/spec/patron_spec_helper.rb:12:in
http_request'
./spec/webmock_spec.rb:47:
/usr/lib64/ruby/1.8/timeout.rb:53:in `timeout'

Finished in 23.212296 seconds

When I follow the URL mentioned in that spec I can reach the site without problem, even though it seems to redirect to some other SSL url.

On a related note, in Gentoo we offer our users the ability to routinely run tests while installing packages, but we cannot garantuee a network connection, which would lead to this test (and possibly others) to fail when there is no network connectivity. It would be great if there was an easy way to inhibit such specs, or perpaps to run them against a local SSL server that is set up as part of the specs.

@bblimke
Owner
bblimke commented Oct 25, 2010

Good point. Some of these specs which are making real network requests fail sometimes due to the timeout.
I'll find out if it's easy to have local test server and if it's enough for webmock specs.
Would it be useful to have different categories of specs. The ones which connect to the network and those who don't?

@bblimke
Owner
bblimke commented Oct 26, 2010

The solution with a local test webserver would have some issues.
First, specs won't be able to verify if webmock allows connections everywhere or just to the localhost.
Second, it's not trivial to start and HTTPS server in pure ruby to test https connections.

Instead I'm planning to do the following:

1) Set higher connection timeout in specs, where possible.
2) Check if there is a network connectivity before running specs,
and if there is no connectivity then print a warning message and only run specs with stubbed or local connections.

This should solve the problem of running specs while installing packages.

@graaff
graaff commented Oct 28, 2010

I'm not sure if it will be easy to reliably test for a network connection, but certainly having categories of specs would work well, and on Gentoo we could then decide to just run the ones not requiring a live network.

@bblimke
Owner
bblimke commented Oct 28, 2010

I was thinking about something as simple as opening a tcp socket to www.example.com 80, with a timeout to verify connectivity.

@bblimke
Owner
bblimke commented Oct 30, 2010

You can now run rake spec NO_CONNECTION=true to only run specs which do not make real network connections.
In addition I check for network connection to www.example.com and if there is no connectivity, only stubbed examples run.
WebMock specs now use RSpec 2.

These changes will be available in next webmock release, hopefully next week.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.