blob: c063108e1524edd45440dee474cfe058edf3087e (
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
|
require 'nickserver/request'
module RequestHandlerTestHelper
protected
def assert_refuses(opts = {})
assert_nil handle(request(opts))
end
def assert_handles(opts = {})
assert handle(request(opts))
end
def assert_queries_for(*query_args, &block)
source_class.stub :new, source_expecting_query_for(*query_args), &block
end
def source_expecting_query_for(*query_args)
@source ||= Minitest::Mock.new
@source.expect :query, 'response', query_args
@source
end
def assert_responds_with_error(msg, opts)
response = handle(request(opts))
assert_equal 500, response.status
assert_equal "500 #{msg}\n", response.content
end
def handle(request)
handler.call(request)
end
def request(opts = {})
params = {'address' => [opts[:email]]}
headers = {'Host' => opts[:domain]}
Nickserver::Request.new params, headers
end
end
|