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
|
Shindo.tests('Excon Response Validation') do
env_init
with_server('good_ipv4') do
tests('good responses with complete headers') do
100.times do
res = Excon.get('http://127.0.0.1:9292/chunked/simple')
returns(true) { res.body == "hello world" }
returns(true) { res.status_line == "HTTP/1.1 200 OK\r\n" }
returns(true) { res.status == 200}
returns(true) { res.reason_phrase == "OK" }
returns(true) { res.remote_ip == "127.0.0.1" }
end
end
end
with_server('error') do
tests('error responses with complete headers') do
100.times do
res = Excon.get('http://127.0.0.1:9292/error/not_found')
returns(true) { res.body == "server says not found" }
returns(true) { res.status_line == "HTTP/1.1 404 Not Found\r\n" }
returns(true) { res.status == 404}
returns(true) { res.reason_phrase == "Not Found" }
returns(true) { res.remote_ip == "127.0.0.1" }
end
end
end
env_restore
end
|