blob: 76337d4369fdedf21e647edd467cbcdc3c883788 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
require 'test_helper'
require 'nickserver/nicknym/source'
require 'nickserver/email_address'
class NicknymSourceTest < Minitest::Test
def test_initialization
assert source
end
def test_available_for_domain
adapter.expect :get, [200, '{"services": ["mx"]}'],
['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
def test_successful_query
adapter.expect :get, [200, 'dummy body'],
['https://nicknym.leap_powered.tld:6425',
{query: {address: email_stub.to_s}}]
response = source.query(email_stub)
assert_equal 200, response.status
assert_equal 'dummy body', response.content
adapter.verify
end
protected
def source
Nickserver::Nicknym::Source.new(adapter)
end
def adapter
@adapter ||= Minitest::Mock.new
end
def email_stub
@email_stub ||= Nickserver::EmailAddress.new 'test@leap_powered.tld'
end
end
|