diff options
author | Azul <azul@riseup.net> | 2017-09-23 11:07:32 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2017-09-23 16:53:27 +0200 |
commit | 40916407517f4bdb75a295caf29e02d4f403349b (patch) | |
tree | 8219567c0ecdf583fdd916594ec7915ab9eb2f19 /test/support/http_stub_helper.rb | |
parent | 22c6c80310a8d3d3abbd1006598b4fbaec98ffd0 (diff) |
style: rubocop mostly auto-correct
Diffstat (limited to 'test/support/http_stub_helper.rb')
-rw-r--r-- | test/support/http_stub_helper.rb | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/test/support/http_stub_helper.rb b/test/support/http_stub_helper.rb index cc9196e..ee50698 100644 --- a/test/support/http_stub_helper.rb +++ b/test/support/http_stub_helper.rb @@ -1,6 +1,7 @@ require 'nickserver/reel_server' module HttpStubHelper + protected def stubbing_http Nickserver::ReelServer::DEFAULT_ADAPTER_CLASS.stub :new, adapter do @@ -11,18 +12,35 @@ module HttpStubHelper def stub_nicknym_available_response(domain, response = {}) stub_http_get "https://#{domain}/provider.json", - response, - Hash + response, + Hash end - def stub_sks_vindex_reponse(uid, response = {}) - stub_http_get config.hkp_url, response, - query: {op: 'vindex', search: uid, exact: 'on', options: 'mr', fingerprint: 'on'} + def stub_sks_vindex_reponse(_uid, response = {}) + stub_http_get config.hkp_url, + response, + query: vindex_query end - def stub_sks_get_reponse(key_id, response = {}) - stub_http_get config.hkp_url, response, - query: {op: 'get', search: "0x"+key_id, exact: 'on', options: 'mr'} + def vindex_query + { op: 'vindex', + search: uid, + exact: 'on', + options: 'mr', + fingerprint: 'on' } + end + + def stub_sks_get_reponse(_key_id, response = {}) + stub_http_get config.hkp_url, + response, + query: sks_get_query + end + + def sks_get_query + { op: 'get', + search: '0x' + key_id, + exact: 'on', + options: 'mr' } end def stub_couch_response(uid, response = {}) @@ -30,12 +48,10 @@ module HttpStubHelper stub_http_get(/#{Regexp.escape(config.couch_url)}.*#{query}/, response) end - private - def stub_http_get(url, response, options = nil) - response = {status: 200, body: ""}.merge(response || {}) + response = { status: 200, body: '' }.merge(response || {}) adapter.expect :get, [response[:status], response[:body]], - [url, options].compact + [url, options].compact end def adapter |