lib/tap/test/http_test.rb in tap-http-0.0.1 vs lib/tap/test/http_test.rb in tap-http-0.1.0
- old
+ new
@@ -9,12 +9,11 @@
# Webrick server that echos requests, and providing methods to
# validate echoed requests.
#
module HttpTest
- # The test-specific web server. All request to the server
- # are echoed back.
+ # Server echos back all requests.
class Server
include Singleton
include WEBrick
attr_accessor :server_thread, :server
@@ -141,153 +140,9 @@
hash.each_pair do |key,values|
values = values.kind_of?(Array) ? values : [values]
values.each { |value| query << "#{key}=#{value}" }
end
URI.encode(query.join('&'))
- end
-
- module RequestLibrary
- def get_request
- msg = <<-_end_of_message_
-GET /path?str=value&int=123&yaml=---+%0A-+a%0A-+b%0A-+c%0A&float=1.23 HTTP/1.1
-Host: www.example.com
-Keep-Alive: 300
-Connection: keep-alive
- _end_of_message_
- end
-
- def _get_request
- { :url => "http://www.example.com/path",
- :http_version => '1.1',
- :request_method => 'GET',
- :headers => {
- "Host" => "www.example.com",
- "Keep-Alive" => 300,
- "Connection" => 'keep-alive'},
- :params => {
- 'str' => 'value',
- 'int' => 123,
- 'float' => 1.23,
- 'yaml' => ['a', 'b', 'c']}
- }
- end
-
- def get_request_with_multiple_values
- msg = <<-_end_of_message_
-GET /path?one=value&one=123&one=---+%0A-+a%0A-+b%0A-+c%0A&two=1.23 HTTP/1.1
-Host: www.example.com
-Keep-Alive: 300
-Connection: keep-alive
- _end_of_message_
- end
-
- def _get_request_with_multiple_values
- { :url => "http://www.example.com/path",
- :http_version => '1.1',
- :request_method => 'GET',
- :headers => {
- "Host" => "www.example.com",
- "Keep-Alive" => 300,
- "Connection" => 'keep-alive'},
- :params => {
- 'one' => ['value', 123, ['a', 'b', 'c']],
- 'two' => 1.23}
- }
- end
-
- def multipart_request
- msg = <<-_end_of_message_
-POST /path HTTP/1.1
-Host: www.example.com
-Content-Type: multipart/form-data; boundary=1234567890
-Content-Length: 305
-
---1234567890
-Content-Disposition: form-data; name="str"
-
-string value
---1234567890
-Content-Disposition: form-data; name="int"
-
-123
---1234567890
-Content-Disposition: form-data; name="float"
-
-1.23
---1234567890
-Content-Disposition: form-data; name="yaml"
-
----
-- a
-- b
-- c
---1234567890--
-_end_of_message_
-
- msg.gsub(/\n/, "\r\n")
- end
-
- def _multipart_request
- { :url => "http://www.example.com/path",
- :http_version => '1.1',
- :request_method => 'POST',
- :headers => {
- "Host" => 'www.example.com',
- "Content-Type" => "multipart/form-data; boundary=1234567890",
- "Content-Length" => 305},
- :params => {
- 'str' => 'string value',
- 'int' => 123,
- 'float' => 1.23,
- 'yaml' => ['a', 'b', 'c']}
- }
- end
-
- def multipart_request_with_multiple_values
- msg = <<-_end_of_message_
-POST /path HTTP/1.1
-Host: www.example.com
-Content-Type: multipart/form-data; boundary=1234567890
-Content-Length: 302
-
---1234567890
-Content-Disposition: form-data; name="one"
-
-string value
---1234567890
-Content-Disposition: form-data; name="one"
-
-123
---1234567890
-Content-Disposition: form-data; name="two"
-
-1.23
---1234567890
-Content-Disposition: form-data; name="one"
-
----
-- a
-- b
-- c
---1234567890--
-_end_of_message_
-
- msg.gsub(/\n/, "\r\n")
- end
-
- def _multipart_request_with_multiple_values
- { :url => "http://www.example.com/path",
- :http_version => '1.1',
- :request_method => 'POST',
- :headers => {
- "Host" => 'www.example.com',
- "Content-Type" => "multipart/form-data; boundary=1234567890",
- "Content-Length" => 302},
- :params => {
- 'one' => ['string value', 123, ['a', 'b', 'c']],
- 'two' => 1.23}
- }
- end
end
end
end
end