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 | |
parent | 22c6c80310a8d3d3abbd1006598b4fbaec98ffd0 (diff) |
style: rubocop mostly auto-correct
Diffstat (limited to 'test/support')
-rw-r--r-- | test/support/celluloid_test.rb | 2 | ||||
-rw-r--r-- | test/support/functional_test.rb | 16 | ||||
-rw-r--r-- | test/support/http_adapter_helper.rb | 2 | ||||
-rw-r--r-- | test/support/http_stub_helper.rb | 40 | ||||
-rw-r--r-- | test/support/request_handler_test_helper.rb | 6 |
5 files changed, 37 insertions, 29 deletions
diff --git a/test/support/celluloid_test.rb b/test/support/celluloid_test.rb index ddcfcbb..a00edff 100644 --- a/test/support/celluloid_test.rb +++ b/test/support/celluloid_test.rb @@ -1,5 +1,4 @@ class CelluloidTest < Minitest::Test - def setup super Celluloid.boot @@ -10,5 +9,4 @@ class CelluloidTest < Minitest::Test Celluloid.shutdown super end - end diff --git a/test/support/functional_test.rb b/test/support/functional_test.rb index 4ebc40a..ceabfea 100644 --- a/test/support/functional_test.rb +++ b/test/support/functional_test.rb @@ -2,28 +2,27 @@ require 'minitest/autorun' require 'minitest/pride' class FunctionalTest < Minitest::Test - protected def nickserver_pid - status = nickserver "status" + status = nickserver 'status' /process id (\d*)\./.match(status)[1] end def assert_running - status = nickserver "status" - assert_includes status, "Nickserver running" + status = nickserver 'status' + assert_includes status, 'Nickserver running' end def assert_stopped - status = nickserver "status" - assert_includes status, "No nickserver processes are running." + status = nickserver 'status' + assert_includes status, 'No nickserver processes are running.' end def assert_command_runs(command) out = nickserver command - assert ($?.exitstatus == 0), - "failed to run 'nickserver #{command}':\n #{out}" + assert ($CHILD_STATUS.exitstatus == 0), + "failed to run 'nickserver #{command}':\n #{out}" end def nickserver(command) @@ -37,5 +36,4 @@ class FunctionalTest < Minitest::Test def self.path_to_executable File.expand_path(File.dirname(__FILE__) + '/../../bin/nickserver') end - end diff --git a/test/support/http_adapter_helper.rb b/test/support/http_adapter_helper.rb index 6817e1e..a22b696 100644 --- a/test/support/http_adapter_helper.rb +++ b/test/support/http_adapter_helper.rb @@ -1,7 +1,6 @@ require 'nickserver/adapters/celluloid_http' module HttpAdapterHelper - def setup super @adapter = Nickserver::Adapters::CelluloidHttp.new @@ -15,5 +14,4 @@ module HttpAdapterHelper protected attr_reader :adapter - end 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 diff --git a/test/support/request_handler_test_helper.rb b/test/support/request_handler_test_helper.rb index c063108..292f99c 100644 --- a/test/support/request_handler_test_helper.rb +++ b/test/support/request_handler_test_helper.rb @@ -1,7 +1,6 @@ require 'nickserver/request' module RequestHandlerTestHelper - protected def assert_refuses(opts = {}) @@ -33,9 +32,8 @@ module RequestHandlerTestHelper end def request(opts = {}) - params = {'address' => [opts[:email]]} - headers = {'Host' => opts[:domain]} + params = { 'address' => [opts[:email]] } + headers = { 'Host' => opts[:domain] } Nickserver::Request.new params, headers end - end |