I'm getting the following failure when running the webmock 1.4.0 specs:
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
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.
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?
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.
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.
I was thinking about something as simple as opening a tcp socket to www.example.com 80, with a timeout to verify connectivity.
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.
rake spec NO_CONNECTION=true
These changes will be available in next webmock release, hopefully next week.