summaryrefslogtreecommitdiff
path: root/test/unit/nicknym/source_test.rb
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2016-08-30 12:38:43 +0200
committerAzul <azul@riseup.net>2016-08-31 12:14:52 +0200
commit625416ac16a1216240fc4c48aa19802ef8a967a1 (patch)
treef3a4a54627fcae49bf896f5f58e60b506f9a55d4 /test/unit/nicknym/source_test.rb
parentb22e23eb9f5a1cb3e37ab2a26b1091183574f4e4 (diff)
wip: key lookup by address via leaps nicknym
I added a RequestHandler that uses Nicknym::Source - but that has not been implemented yet.
Diffstat (limited to 'test/unit/nicknym/source_test.rb')
-rw-r--r--test/unit/nicknym/source_test.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/unit/nicknym/source_test.rb b/test/unit/nicknym/source_test.rb
new file mode 100644
index 0000000..586dc0e
--- /dev/null
+++ b/test/unit/nicknym/source_test.rb
@@ -0,0 +1,33 @@
+require 'test_helper'
+require 'nickserver/nicknym/source'
+
+class NicknymSourceTest < Minitest::Test
+
+ def test_initialization
+ assert source
+ end
+
+ def test_available_for_domain
+ adapter.expect :get, [200, 'dummy body'],
+ ['https://leap_powered.tld/provider.json']
+ assert source.available_for?('leap_powered.tld')
+ adapter.verify
+ end
+
+ def test_not_available_for_domain
+ adapter.expect :get, [404, nil],
+ ['https://remote.tld/provider.json']
+ assert !source.available_for?('remote.tld')
+ adapter.verify
+ end
+
+ protected
+
+ def source
+ Nickserver::Nicknym::Source.new(adapter)
+ end
+
+ def adapter
+ @adapter ||= Minitest::Mock.new
+ end
+end