summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2016-11-30 12:49:50 +0100
committerAzul <azul@riseup.net>2016-11-30 13:23:13 +0100
commit6851b606bdc985565104d41a48f1ecc81d132227 (patch)
treed2eaf93312ae2c308397071fec5035c16ba98a68
parent4159b6dd0df8e370fe95ca0c173552dd311cac3a (diff)
test: more meaningful error messages in case of failures
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--test/remote/nicknym_source_test.rb14
2 files changed, 11 insertions, 5 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 024fb9f..28975f9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -25,4 +25,4 @@ before_script:
test:
script:
- - bundle exec rake test
+ - TEST_OPTS=-v bundle exec rake test
diff --git a/test/remote/nicknym_source_test.rb b/test/remote/nicknym_source_test.rb
index e2896ca..7840e10 100644
--- a/test/remote/nicknym_source_test.rb
+++ b/test/remote/nicknym_source_test.rb
@@ -18,9 +18,7 @@ class RemoteNicknymSourceTest < CelluloidTest
def test_successful_query
response = source.query(email_with_key)
skip if response.status == 404
- json = JSON.parse response.content
- assert_equal email_with_key.to_s, json["address"]
- refute_empty json["openpgp"]
+ assert_pgp_key_in response
rescue HTTP::ConnectionError => e
skip e.to_s
end
@@ -28,13 +26,21 @@ class RemoteNicknymSourceTest < CelluloidTest
def test_not_found
response = source.query(email_without_key)
skip if response.status == 200
- assert response.status == 404
+ assert_equal 404, response.status
rescue HTTP::ConnectionError => e
skip e.to_s
end
protected
+ def assert_pgp_key_in(response)
+ json = JSON.parse response.content
+ assert_equal email_with_key.to_s, json["address"]
+ refute_empty json["openpgp"]
+ rescue JSON::ParserError
+ skip "invalid json response: #{response.content}"
+ end
+
def source
@source ||= Nickserver::Nicknym::Source.new
end