File: complete_responses.rb

package info (click to toggle)
ruby-excon 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,240 kB
  • sloc: ruby: 7,970; makefile: 5
file content (31 lines) | stat: -rw-r--r-- 1,050 bytes parent folder | download | duplicates (4)
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