diff options
author | Azul <azul@riseup.net> | 2016-09-12 16:34:25 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2016-09-12 16:34:57 +0200 |
commit | ec875169b0231d84bb8c55bbe91c52b896561f1e (patch) | |
tree | bb4b47a79d32744bda8d66b2c02e9343bfc61698 /test/test_helper.rb | |
parent | bc8ddfa1c49b438a563a8a8b9e0472944f71c71c (diff) |
test: separate remote tests into own directory
Dropped the webmock dependency. We have our own http adapter. So we can
stub that to inject a mock. As an added bonus this does not mess with
other http requests.
Also wrote down testing strategy. Not completely implemented yet.
Diffstat (limited to 'test/test_helper.rb')
-rw-r--r-- | test/test_helper.rb | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb index 9f2c581..6bf3854 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -4,9 +4,6 @@ require 'rubygems' require 'kernel_ext' require 'bundler/setup' require 'minitest/autorun' -silence_warnings do - require 'webmock/minitest' -end require 'celluloid/test' require 'minitest/pride' require 'minitest/hell' @@ -20,9 +17,6 @@ class Minitest::Test def setup Nickserver::Config.load - - # by default, mock all non-localhost network connections - WebMock.disable_net_connect!(allow_localhost: true) end def file_content(filename) @@ -33,38 +27,6 @@ class Minitest::Test "%s/files/%s" % [File.dirname(__FILE__), filename] end - def real_network - unless ENV['ONLY_LOCAL'] == 'true' - WebMock.allow_net_connect! - yield - WebMock.disable_net_connect! - end - end - - def stub_sks_vindex_reponse(uid, opts = {}) - options = {status: 200, body: ""}.merge(opts) - stub_http_request(:get, Nickserver::Config.hkp_url).with( - query: {op: 'vindex', search: uid, exact: 'on', options: 'mr', fingerprint: 'on'} - ).to_return(options) - end - - def stub_sks_get_reponse(key_id, opts = {}) - options = {status: 200, body: ""}.merge(opts) - stub_http_request(:get, config.hkp_url).with( - query: {op: 'get', search: "0x"+key_id, exact: 'on', options: 'mr'} - ).to_return(options) - end - - def stub_couch_response(uid, opts = {}) - # can't stub localhost, so set couch_host to anything else - config.stub :couch_host, 'notlocalhost' do - options = {status: 200, body: ""}.merge(opts) - query = "\?key=#{"%22#{uid}%22"}&reduce=false" - stub_http_request(:get, /#{Regexp.escape(config.couch_url)}.*#{query}/).to_return(options) - yield - end - end - def config Nickserver::Config end |