http-requestor 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  require "net/http"
2
2
  require "net/https"
3
3
  require "uri"
4
+ require File.dirname(__FILE__) + "/http_requestor_multipart"
4
5
 
5
6
  module HTTP
6
7
  class Requestor
@@ -1,5 +1,4 @@
1
1
  require "../lib/http_requestor"
2
- require "../lib/http_requestor_multipart"
3
2
  require "test/unit"
4
3
 
5
4
  class HttpRequestorTest < Test::Unit::TestCase
@@ -8,37 +7,26 @@ class HttpRequestorTest < Test::Unit::TestCase
8
7
  end
9
8
 
10
9
  def test_should_post_file_properly
11
- headers = {"application_api_key" => "bltc5b185cd6884ae87", "application_uid" => "blt2f37284c14b6b453"}
12
- uri = "http://localhost:3000/v3/classes/files/objects.json"
10
+ uri = "https://www.google.co.in/searchbyimage/upload"
13
11
  f=File.open("testfile.txt", "w+")
14
12
  f.syswrite("This is testing")
15
13
  f.close
16
- data = {:object => {:title => "This is from http-requestor", :file1 => File.open("testfile.txt")}}
14
+ data = {:encoded_image => File.open("images.jpg")}
17
15
 
18
- assert_equal("201", HTTP::Requestor.multipart_request(uri, "post", data, headers).code)
16
+ assert_equal("302", HTTP::Requestor.multipart_request(uri, "post", data).code)
19
17
  end
20
18
 
21
19
  def test_should_post_file_properly_with_instance_method_used
22
- http = HTTP::Requestor.new("http://localhost:3000")
23
-
24
- headers = {"application_api_key" => "bltc5b185cd6884ae87", "application_uid" => "blt2f37284c14b6b453"}
25
- path = "/v3/classes/files/objects.json"
26
- f=File.open("testfile.txt", "w+")
27
- f.syswrite("This is testing")
28
- f.close
29
- data = {:object => {:title => "This is from http-requestor", :file1 => File.open("testfile.txt")}}
30
-
31
- assert_equal("201", http.post_multipart(path, data, headers).code)
20
+ http = HTTP::Requestor.new("https://www.google.co.in")
21
+ path = "/searchbyimage/upload"
22
+ data = {:encoded_image => File.open("images.jpg")}
23
+ assert_equal("302", http.post_multipart(path, data).code)
32
24
  end
33
25
 
34
26
  def test_should_post_multiple_files
35
- headers = {"application_api_key" => "bltc5b185cd6884ae87", "application_uid" => "blt2f37284c14b6b453"}
36
- uri = "http://localhost:3000/v3/classes/multiplefiles/objects.json"
37
- f=File.open("testfile.txt", "w+")
38
- f.syswrite("This is testing")
39
- f.close
40
- data = {:object => {:title => ["Title 1", "Title 2"], :file => [File.open("testfile.txt"), File.open("testfile.txt")]}}
27
+ uri = "http://www.imaaage.com/upload.php"
28
+ data = {:image => [File.open("images.jpg"), File.open("images.jpg")]}
41
29
 
42
- assert_equal("201", HTTP::Requestor.multipart_request(uri, "post", data, headers).code)
30
+ assert_equal("200", HTTP::Requestor.multipart_request(uri, "post", data).code)
43
31
  end
44
32
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-requestor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-23 00:00:00.000000000Z
12
+ date: 2012-11-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mime-types
16
- requirement: &27297132 !ruby/object:Gem::Requirement
16
+ requirement: &28185828 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 1.17.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *27297132
24
+ version_requirements: *28185828
25
25
  description: ! " A Wrapper around Net/HTTP which allows you to perform HTTP Requests.\n
26
26
  \ Gives you a simple API interface to send multipart requests.\n"
27
27
  email: rohit0981989@gmail.com
@@ -34,7 +34,7 @@ files:
34
34
  - MIT-LICENSE
35
35
  - README.rdoc
36
36
  - test/http_requestor_test.rb
37
- - test/testfile.txt
37
+ - test/images.jpg
38
38
  homepage: http://github.com/rohit9889/http-requestor
39
39
  licenses:
40
40
  - MIT
@@ -62,4 +62,4 @@ specification_version: 3
62
62
  summary: A Wrapper around Net/HTTP which allows you to perform HTTP Requests.
63
63
  test_files:
64
64
  - test/http_requestor_test.rb
65
- - test/testfile.txt
65
+ - test/images.jpg
@@ -1 +0,0 @@
1
- This is testing