diff options
-rw-r--r-- | lib/nickserver/dispatcher.rb | 2 | ||||
-rw-r--r-- | test/integration/dispatcher_test.rb | 7 | ||||
-rw-r--r-- | test/remote/celluloid_http_test.rb | 2 | ||||
-rw-r--r-- | test/remote/hkp_source_test.rb | 2 |
4 files changed, 11 insertions, 2 deletions
diff --git a/lib/nickserver/dispatcher.rb b/lib/nickserver/dispatcher.rb index 07571d5..f9801d1 100644 --- a/lib/nickserver/dispatcher.rb +++ b/lib/nickserver/dispatcher.rb @@ -66,7 +66,7 @@ module Nickserver if exc puts " Error: #{exc}" Nickserver::Response.new 502, - %Q|{"error": "#{exc}"}| + JSON.dump(error: exc.to_s) end end diff --git a/test/integration/dispatcher_test.rb b/test/integration/dispatcher_test.rb index 4757e83..b551e87 100644 --- a/test/integration/dispatcher_test.rb +++ b/test/integration/dispatcher_test.rb @@ -59,7 +59,7 @@ class Nickserver::DispatcherTest < Minitest::Test handle address: ['valid@email.tld'], headers: { "Host" => "http://nickserver.me" } stub_nicknym_raises hkp_source.expect :query, nil, [Nickserver::EmailAddress] - assert_response response(status: 502, content: "HTTP::ConnectionError") + assert_response http_connection_error end def test_email_via_nicknym @@ -126,6 +126,11 @@ class Nickserver::DispatcherTest < Minitest::Test response status: 500, content: "500 #{msg}\n" end + def http_connection_error + response status: 502, + content: JSON.dump(error: "HTTP::ConnectionError") + end + def response(options) Nickserver::Response.new(options[:status], options[:content]) end diff --git a/test/remote/celluloid_http_test.rb b/test/remote/celluloid_http_test.rb index 46a5259..d5d33b4 100644 --- a/test/remote/celluloid_http_test.rb +++ b/test/remote/celluloid_http_test.rb @@ -17,6 +17,8 @@ class Nickserver::Adapters::CelluloidHttpTest < Minitest::Test url = Nickserver::Config.hkp_url status, _body = adapter.get url assert_equal 404, status + rescue HTTP::ConnectionError => e + skip "could not talk to hkp server: #{e}" end protected diff --git a/test/remote/hkp_source_test.rb b/test/remote/hkp_source_test.rb index aabc4d3..a4761fb 100644 --- a/test/remote/hkp_source_test.rb +++ b/test/remote/hkp_source_test.rb @@ -45,5 +45,7 @@ class RemoteHkpSourceTest < Minitest::Test assert_equal 200, status yield keys end + rescue HTTP::ConnectionError => e + skip "could not talk to hkp server: #{e}" end end |