[openstreetmap/openstreetmap-website] Use Webmock to intercept http requests in tests (#1350)

Andy Allan notifications at github.com
Sun Oct 30 10:26:14 UTC 2016

I found while offline that many of the tests make real http requests. Using [webmock](https://github.com/bblimke/webmock) means these are disabled by default, and need to be explicitly stubbed - this ensures that http requests aren't accidentally overlooked when they are written while online.

Later I found that some http requests were being mocked out using the stub_http_requests method, so I've refactored that to use webmock too. I also refactored some gravatar tests to improve their clarity, and removed their http fixture since it was just dummy responses anyway.
You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * Add webmock to intercept real http connections during tests
  * Stub out requests to hostip.info during tests
  * Stub out requests to gravatar.com during tests.
  * Use webmock to power the with_http_stubs helper
  * Refactor the gravatar email changes to use webmock stubbing

-- File Changes --

    M Gemfile (1)
    M Gemfile.lock (11)
    M lib/osm.rb (5)
    M test/controllers/site_controller_test.rb (2)
    M test/controllers/user_controller_test.rb (61)
    M test/http/geocoder_ca.yml (14)
    D test/http/gravatar.yml (7)
    M test/http/nominatim.yml (10)
    M test/http/npemap.yml (4)
    M test/integration/oauth_test.rb (4)
    M test/integration/page_locale_test.rb (1)
    M test/integration/user_creation_test.rb (2)
    M test/integration/user_roles_test.rb (4)
    M test/integration/user_terms_seen_test.rb (4)
    M test/test_helper.rb (26)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20161030/0f06f114/attachment.html>

More information about the rails-dev mailing list